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
160 views

svm.LinearSVC: larger max_iter number doesn't always increase the accuracy/precision/recall

Background: Supervised machine learning Data shape 10+ features, target = 1 or 0 only, 100,000+ samples (so should be no issue of over-sampling) 80% training, 20% testing train_test_split(X_train, ...
0
votes
1answer
43 views

sklearn.model_selection: GridSearchCV vs. KFold

Here is the explain of cv parameter in the sklearn.model_selection.GridSearchCV: cv : int, cross-validation generator or an iterable, optional Determines the cross-validation splitting ...
1
vote
1answer
34 views

Track underlying observation when using GridSearchCV and make_scorer

I'm doing a GridSearchCV, and I've defined a custom function (called custom_scorer below) to optimize for. So the setup is like this: ...
2
votes
1answer
53 views

Gradient Boosted Decision Trees How to Find Prediction of Each Tree?

I'm doing a project. I have a classification problem that I should solve using gradient boosted decision trees. What I want to do is create a matrix that gives prediction of each decision tree for ...
0
votes
1answer
61 views

Why my svm.SVC.fit( ) (linear kernal) run so long time?

I am using sklearn.svm.SVC( ) to train & test my dataset. 80% are used for training, 20% are used for testing. Here is my Python code: ...
0
votes
0answers
16 views

Model or algorithm for iterative optimization

Here is my problem : At every loop, I have new data that depends on the previous outputs. I need to approximate the function that optimizes (minimizes / maximizes) this new data on every iteration. ...
2
votes
2answers
106 views

Procedure for selecting optimal number of features with Python's Scikit-Learn

I have a dataset with 130 features (1000 rows) . I want to select the best features for my classifier. I started with RFE but Its taking too long, i done this: <...
0
votes
1answer
109 views

How to combine nlp and numeric data for a linear regression problem

I'm very new to data science (this is my hello world project), and I have a data set made up of a combination of review text and numerical data such as number of tables. There is also a column for ...
0
votes
2answers
47 views

How to do predict a new sms to be spam or not?

I have trained a model for spam classification - This is my code - ...
3
votes
2answers
41 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
14 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
27 views
1
vote
1answer
47 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
135 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
12 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
109 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
74 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
46 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
21 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
91 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
1answer
1k 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
1answer
110 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
92 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
24 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
29 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
0answers
123 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
157 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
50 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
27 views

Scikit MultinomialNB predict_proba Gives Same Label Multiple Times

I'm training a fairly simple model... ...
0
votes
1answer
31 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
33 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
63 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
25 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
36 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
79 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
42 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
50 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
57 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
66 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
30 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: ...
3
votes
1answer
35 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
87 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
15 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
56 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
259 views

How does class_weight work in Decision Tree

The scikit-learn implementation of DecisionTreeClassifier has a parameter as class_weight. ...
0
votes
0answers
27 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
27 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
58 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
32 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 ...