scikit-learn

TypeError: fit() missing 1 required positional argument: 'y' (using sklearn - ExtraTreesRegressor)

Deadly 提交于 2021-02-05 10:46:25
问题 Just trying out the Sklearn python library and I re-purposed some code I was using for Linear regression to fit a regression tree model as an example I saw (here's the example code): def fit(self, X, y): """ Fit a Random Forest model to data `X` and targets `y`. Parameters ---------- X : array-like Input values. y: array-like Target values. """ self.X = X self.y = y self.n = self.X.shape[0] self.model = ExtraTreesRegressor(**self.params) self.model.fit(X, y) Here's the code I've written

How is the hidden layer size determined for MLPRegressor in SciKitLearn?

|▌冷眼眸甩不掉的悲伤 提交于 2021-02-05 09:43:44
问题 Lets say I'm creating a neural net using the following code: from sklearn.neural_network import MLPRegressor model = MLPRegressor( hidden_layer_sizes=(100,), activation='identity' ) model.fit(X_train, y_train) For the hidden_layer_sizes , I simply set it to the default. However, I don't really understand how it works. What is the number of hidden layers in my definition? Is it 100? 回答1: From the docs: hidden_layer_sizes : tuple, length = n_layers - 2, default (100,) The ith element represents

How is the hidden layer size determined for MLPRegressor in SciKitLearn?

别说谁变了你拦得住时间么 提交于 2021-02-05 09:43:02
问题 Lets say I'm creating a neural net using the following code: from sklearn.neural_network import MLPRegressor model = MLPRegressor( hidden_layer_sizes=(100,), activation='identity' ) model.fit(X_train, y_train) For the hidden_layer_sizes , I simply set it to the default. However, I don't really understand how it works. What is the number of hidden layers in my definition? Is it 100? 回答1: From the docs: hidden_layer_sizes : tuple, length = n_layers - 2, default (100,) The ith element represents

Loading images in Keras for CNN from directory but label in CSV file

孤街浪徒 提交于 2021-02-05 09:34:27
问题 I have a set of image files in a directory train_images = './data/images' and train_labels = './data/labels.csv' For example - There are 1000 images in train_images as 377.jpg,17814.jpg .... and so on. And the class they correspond to are saved in a different CSV file. EDIT - Here are a few rows from the CSV file - >> ID Class 0 377.jpg MIDDLE 1 17814.jpg YOUNG 2 21283.jpg MIDDLE 3 16496.jpg YOUNG 4 4487.jpg MIDDLE Here I.D is the image file name and the class is the class it is associated to

Why is Bokeh's plot not changing with plot selection?

被刻印的时光 ゝ 提交于 2021-02-05 09:29:17
问题 Struggling to understand why this bokeh visual will not allow me to change plots and see the predicted data. The plot and select (dropdown-looking) menu appears, but I'm not able to change the plot for items in the menu. Running Bokeh 1.2.0 via Anaconda. The code has been run both inside & outside of Jupyter. No errors display when the code is run. I've looked through the handful of SO posts relating to this same issue, but I've not been able to apply the same solutions successfully. I wasn't

DBSCAN Clustering - Exporting the clustered outcome to a new column issue

可紊 提交于 2021-02-05 09:23:11
问题 I have made a code using python under Iris Data set - the clustering technique i used is DBSCAN. I need to take out the desired outcome in to a new column. I have the graphical chart of the clustering. Needed to take out the total data set with updated new cluster column. In K-Means, I could do that by running the below iris_frame['NEW_COLUMN'] = pd.Series(y, index=iris_frame.index) In Hierarchical clustering i could take out the desired outcome from the below formula from scipy.cluster

How to install auto-sklearn on GoogleColab?

痞子三分冷 提交于 2021-02-05 08:09:12
问题 I'd like to use auto-sklearn.I used the code from this document.All packages are installed. But I got an error like this. !curl https://raw.githubusercontent.com/automl/auto-sklearn/master/requirements.txt | xargs -n 1 -L 1 pip install !pip install auto-sklearn import autosklearn.classification --------------------------------------------------------------------------- ImportError Traceback (most recent call last) <ipython-input-9-f7b2b884019b> in <module>() 24 from keras.callbacks import

Scikit-learn: “The least populated class in y has only 1 member”

邮差的信 提交于 2021-02-05 07:52:25
问题 I am trying to do a Random Forest Regression using Scikit-learn. The first step after loading the data using Pandas is to split the data into a test set and a training set. However, I get the error: The least populated class in y has only 1 member I've searched Google and found various instances of this error, but I still can't seem to get an understanding of what this error means. training_file = "training_data.txt" data = pd.read_csv(training_file, sep='\t') y = data.Result X = data.drop(

naive bayes classifier dynamic training

做~自己de王妃 提交于 2021-02-05 07:43:17
问题 Is it possible (and how if it is) to dynamically train sklearn MultinomialNB Classifier? I would like to train(update) my spam classifier every time I feed an email in it. I want this (does not work): x_train, x_test, y_train, y_test = tts(features, labels, test_size=0.2) clf = MultinomialNB() for i in range(len(x_train)): clf.fit([x_train[i]], [y_train[i]]) preds = clf.predict(x_test) to have similar result as this (works OK): x_train, x_test, y_train, y_test = tts(features, labels, test

how to assess the confidence score of a prediction with scikit-learn

青春壹個敷衍的年華 提交于 2021-02-05 06:15:41
问题 I have write down a simple code that takes One arguments "query_seq", further methods calculates descriptor and in the end predictions can be made using "LogisticRegression" (or any other algorithm provided with the function) algorithms as "0 (negative for given case)" or "1 (positive for given case)" def main_process(query_Seq): LR = LogisticRegression() GNB = GaussianNB() KNB = KNeighborsClassifier() DT = DecisionTreeClassifier() SV = SVC(probability=True) train_x, train_y,train_l = data