Questions tagged [scikit-learn]

Scikit-learn is a Python module comprising of simple and efficient tool for machine learning, data mining and data analysis. It is built on NumPy, SciPy, and matplotlib. It is distributed under the 3-Clause BSD license.

Filter by
Sorted by
Tagged with
1
vote
1answer
21 views

Decision Trees Should We Discard Low Importance Features?

I just started to work with feature selection. Let's say I have a decision tree model. I get its feature importances by tree.feature_importances_. In my model out ...
0
votes
0answers
5 views

What information is encoded in embedding vector lengths?

I have started to investigate word2vec and related embedding strategies. The word2vec training loss is a function of cosine distance and not Euclidean distance. In fact I have been reading various ...
1
vote
1answer
22 views
1
vote
1answer
20 views

Ball Tree and Pseudometrics

The docs for sklearn.neighbors.DistanceMetric state that in order to be used within the BallTree, the distance must be a true metric (i.e. be non-negative, 0 ...
1
vote
0answers
22 views

SKLearn Boston dataset gradient descent not working

I am trying to compare some simple methods for linear regression as an exercise. I have already used LinearRegression from the SKLearn library in python as well as the formula of linear regression. ...
0
votes
0answers
11 views

Dimensionality Reduction. How to explain dynamics of feature subset based on all features data?

I have features: f1..f1000. I want to explain dynamics of particular features subset: f1-f5 based on all features data (based on ...
0
votes
0answers
8 views

Scale a column with respect to the deviation in another

I have a dataset consisting of 644 features and the temperature that the features where captured at. I know that the temperature will effect the value of some of the features. Is it possible to scale ...
1
vote
1answer
22 views

Isolation forest - grouped by

I'm trying to use isolation forest algorithm for outliers detection. Data has 2 columns: id and REV. Below code gives me ...
0
votes
1answer
37 views

Decision tree classifier prediction changes from one run of the model to the next

I'm running a very basic gender ['male', 'female'] classifier using the sklearn DecisionTreeClassifier based on ...
1
vote
2answers
30 views

ScikitLearn - RandomForestRegressor score different in and out of grid search

I am using RandomForestRegressor (scikit-learn python package). I am looking for the best values for hyperparameters ...
0
votes
1answer
10 views

Getting different precisions for same neural network with same dataset and hyperparameters in sklearn mlp classifier

I get WAY DIFFERENT results in each run despite using random state for making sure that network outputs same result for same hyper parameters, here is some sample outputs(I've printed the hyper ...
2
votes
1answer
27 views

values passed to user-defined distance function by KNeighborsClassifier is wrong

I have a data-set in which all features are binary and the class of each data-point is also binary. I am trying to use KNearestClassifier with a user-defined distance function as follows: ...
0
votes
0answers
20 views

Sklearn ValueError: X has 2 features per sample; expecting 11

I try to visualizing multiple logistic regression but I get the above error. I'm practicing on red wine quality data set from kaggle. Here is a full traceback: ...
1
vote
0answers
21 views

Choosing weights on random forest for imbalanced data with the aim to minimize false positives

I am currently dealing with a binary classification task on imbalanced data with the following distribution: ...
0
votes
1answer
20 views

Adding machine learning classifier at the end of CNN layer

I wanted to use the CNN as feature extractor for my images and then fed these features to some machine learning classifiers such as SVM, decision tree and KNN. However when I was trying with SVM I got ...
0
votes
1answer
18 views

How do I interpret the given classification report?

The given classification report was obtained from running a Random Forest binary classifier on the test data. There is huge class imbalance in the training data. How do I interpret the given ...
0
votes
1answer
22 views

What is the best way to optimize the parameters in a Sklearn classifier, when I have little data?

What is the best way to optimize the parameters in a Sklearn classifier when I only have a data set with 684 rows and 177 columns, and the column I want to predict has 3 labels? I know I should split ...
2
votes
1answer
17 views

incremental learning vs transfer learning

Can anyone explain me how incremental learning differs from transfer learning with example? Also does Transfer learning limited to neural networks?
1
vote
1answer
22 views

String handling by OneHotEncoder

I am reading everywhere on new questions and blogs that since version 0.20, OneHotEncoder is able to handle string features. Moreover, the documentation is what looks more ambiguous. Here are the ...
0
votes
1answer
36 views

sckit-learn Cross validation and model retrain

I want to train a model and also perform cross validation in scikit-learn, If i want to access the model (For instance to see the parameter's selected and weights or to predict) i will need to fit it ...
0
votes
0answers
19 views

Scikit MultinomialNB predict_proba Gives Same Label Multiple Times

I'm training a fairly simple model... ...
0
votes
1answer
23 views

Unable to understand the usage of labels argument in sklearn.metrics.f1_score

I am trying to model a dataset with RandomForest Classifier. My dataset has 3 classes viz. A, B, C. 'A' is the negative class ...
0
votes
0answers
19 views

SVM - Shuffle image data before GridSearchCV or not?

I have different image datasets, most of them are sorted by class, others are already mixed. For each of these data sets, I would like to train one SVM (in Python with Scikit-Learn), whereby in each ...
0
votes
2answers
45 views

Applying and Visualizing k means clustering on a data set that has 9 features

I had a data set of images that I have extracted 9 numerical features that I want to apply k means clustering or hierarchical clustering to. I'm just not sure how to go about it. The tutorials I have ...
0
votes
0answers
22 views

The Difference between One Hot Encoding and LabelEncoder? [duplicate]

I am working on a ML problem to predict house prices and Zip Code is one feature which will be useful. I am also trying to use ...
1
vote
1answer
27 views

Using of 100s of Binary features in regression model

I have 100s of columns with binary values [0, 1] plus some extra columns without binary values. I am trying to do regression model but the model performance is very low. For non-binary features, I ...
1
vote
0answers
34 views

Combining the output of two models

I have two models that predict a person's activity (seating, walking, taking stairs, and sleeping) based on a person's motion and the video. Model 1 is trained on a ...
0
votes
2answers
31 views

Confusion on result of K-Fold Cross Validation and Independent Test set

I am relatively new in Machine Learning. I am using Random Forest and SVM for a project. Where I did a ...
1
vote
0answers
23 views

SVC classification not working at all on MNIST dataset

I'm sure I probably did something stupid but I'm trying to fit a simple SVC classifier on MNIST dataset as an example, and it completely failed by only predicting result 1 (sometimes 7 depends on how ...
0
votes
1answer
17 views

What does the KFold error mean and how to get confusion matrix from Kfold random forest implementation?

from sklearn.model_selection import KFold num_folds = 10 seed = 77 kf = KFold(n_splits=num_folds,random_state=77,shuffle=False) rfc=RandomForestClassifier(...
2
votes
0answers
24 views

Why are the regions/decision boundaries overlapping with multi-class classification using SVM in sci-kit?

I am using the SVM in scikit-learn library for doing multiclass classification. I am wondering why these regions (decision boundaries) are overlapping (as seen in the picture below)? Could someone ...
1
vote
1answer
28 views

Are more classes more favorable than a single combined class?

Imagine the following scenario. Train a classifier that classifies an object into one of these n+m classes: ...
0
votes
0answers
10 views

Want to understand how Local outlier works

I am trying to understand how the local outlier factor algorithm works. I have not been able to find a decent and easy explanation of the same. I came across the post: Local Outlier Factor For ...
3
votes
1answer
28 views

Is the distance in Nearest Neighbors a good measure of similarity?

Let's train a Nearest Neighbor model with just one sample in it: In [48]: nn = NearestNeighbors().fit([[0, 1, 0, 0]]) So this one sample has just one significant ...
0
votes
1answer
38 views

Using a pipeline and transforming data with imputing and OneHotEncoding performs worse than get_dummies

I'm still in the process of learning, so I'm sorry if this doesn't make much sense. I'm doing Kaggle learns micro courses, and to work with missing tabular data we learned about using pipelines with ...
0
votes
0answers
8 views

How do I organize a multi-site multivariate time-series dataset for a Random Forest Regression?

I am trying to do a Random Forest Regression to forecast the next months value. I have a few years of data split by month. In each month I have about 1500 unique sites. There are 14 features.
-1
votes
2answers
27 views

What is sample and feature

I'm reading Scikit-learn and I can't understand sample and feature. (n_samples, n_features) Can anybody describe those by example?
2
votes
1answer
30 views

How does class_weight work in Decision Tree

The scikit-learn implementation of DecisionTreeClassifier has a parameter as class_weight. ...
0
votes
0answers
9 views

How to gauge overfit with MLPClassifier and cross_val_score?

I'm learning sklearn. When using MLPClassifier.fit() and MLPClassifier.predict() I would ...
1
vote
1answer
16 views

Multilabel classification for a learning to rank application

I am looking for some suggestions on Learning to Rank method for search engines. I created a dataset with the following data: ...
3
votes
1answer
52 views

Machine Learning: Balanced training set but highly unbalanced prediction set? How to adjust?

I am trying to train a model to detect gender in a dataset of CEO speeches. Here are the datasets that I have: Final Dataset: 20K CEO voices analyzed (around 95% male) Testing dataset (?): 1K CEO ...
0
votes
1answer
10 views

Splitting large multi class dataset using leave one out scheme into train and test

I am doing some supervised learning using neural networks, and i have a Targets array containing 1906 samples, which contain 664 unique values. min. count of each unique value==2, by design. Is there ...
1
vote
1answer
60 views

memory error in matrix cosine_similarity

I have (20905040, 7) of a dataset to recommend 10 different product to the user it could be larger than that but anyway I got memory error when processing the ...
1
vote
2answers
59 views

How does Decision Tree with Gini Impurity Calculate Root Node?

I couldn't figure out how it selected the root node with with <=7.5 and it's gini impurity is 0.45 but I tried to manually ...
0
votes
1answer
18 views

Getting a ValueError from train_test_split

I'm working on this dataset. I'm trying to select features using Random Forest. This is the relevant code: ...
2
votes
1answer
20 views

How can I count the number of occurrences of a category in dataset as part of an Sklearn Pipeline

Let us say we have a dataset with a feature such as Surname. arr['Surname'] = ['Smith', 'Jones', 'Johnson', 'Smith'] And I want to encode this categorical info ...
1
vote
0answers
13 views

Scikit-learn randomforestclassifier error on fitting

So I am trying to use the random forest classifier from scikit-learn and I use tfidfvectorizer to create a feature set, then use test_train_split to create X_train and Y_train. I pass this into the ...
0
votes
0answers
30 views

How to detect anomalies (errors and exceptions) in log files?

Is this a good approach? So I'm working on a Root Cause Analysis system which should help find the cause/the root error of failed system builds (packaged in a tarball), through the analysis of log ...
1
vote
1answer
40 views

How to normalize complex-valued data?

I'm taking the abs of all elements, compute the mean, subtract it off from the original values. I just feel that this is not correct and can change the vectors. I'm also dividing by the standard ...
1
vote
1answer
26 views

Sklearn train_test_split() error: Found input variables with inconsistent numbers of samples

I am fitting a regression model on randomly generated X1,x2 and Y be the sum of x1, x2 but I am getting this error ValueError: Found input variables with inconsistent numbers of samples: [2, ...