As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [scikit-learn]

A machine-learning library for Python. Use this tag for any on-topic question that (a) involves scikit-learn either as a critical part of the question or expected answer, & (b) is not just about how to use scikit-learn.

Filter by
Sorted by
Tagged with
2 votes
1 answer
4k views

How do we use logistic regression (scikit-learn) to predict values

Logistic regression can help to predict a value whether it would happen or no. I'd like to know how can I do that using sklearn. I'd like to know the probability if this event would happen or no. I ...
user3378649's user avatar
  • 1,137
12 votes
1 answer
15k views

How do we predict rare events?

I am working on developing an insurance risk predictive model. These models are of "rare events" like airline no-show prediction, hardware fault detection, etc. As I prepared my data set, I tried to ...
user3378649's user avatar
  • 1,137
1 vote
2 answers
756 views

Streaming k-means

I want to perform something like streaming/online/out-of-core kmeans clustering on large data. Here is simple idea: Break all data into N chunks. Read from disk 1st chunk and calculate centroids ...
mrgloom's user avatar
  • 2,117
3 votes
1 answer
269 views

scikit learn: add lasso or ridge penalty only on subset of parameters

Is there a way of using the linear model api to add the lasso penalty for a subset of the parameters I am regressing? For example, consider a linear separable decomposition that I want to fit to some ...
mathtick's user avatar
  • 281
3 votes
1 answer
1k views

R equivalent of scikit's KFold

I'm trying to set up a basic k folds CV loop in R. In Python I'd use scikit's KFold. ...
ADJ's user avatar
  • 435
1 vote
1 answer
83 views

How Does a Disparity in Number of Documents (Training Data Points) Affect Text Classification?

I have collected a fairly clean set of data (5,410 documents) to train a text classifier. I am now attempting to improve my classification success. (Note: When I trained/tested the classifier from ...
Bee Smears's user avatar
6 votes
1 answer
2k views

"Robust" normalization of features from multiple groups and unknown distributions prior to learning

I'm working on a machine learning project involving statistical analysis (and later discriminatory classification) of different proteins (samples) drawn from multiple, potentially overlapping classes /...
GrimSqueaker's user avatar
6 votes
2 answers
16k views

Prediction with scikit and an precomputed kernel (SVM)

I am kind of a newbie in the MachineLearning area and evaluating some tools etc. to get a feeling for it. For a project I am using a tool that creates a precomputed kernel (gram matrix) and also is ...
basti's user avatar
  • 163
5 votes
1 answer
318 views

What is the right attitude toward open source machine learning toolkits?

There are lots of machine learning toolkits nowadays, such as weka, sklearn, R libs. If we choose to use these toolkits, besides that it is convenient, sometimes ...
crazyminer's user avatar
0 votes
2 answers
211 views

Regression Tree when target is a ratio

I am learning a regression tree for data of the form $(x_i,y_i)$: $x_i = (1, 0, 1, ...., 1 , 1)$ a multiple input vector and $y$ is a ratio of the number of observations divided by the number of ...
Michel G's user avatar
17 votes
4 answers
33k views

Using BIC to estimate the number of k in KMEANS

I am currently trying to compute the BIC for my toy data set (ofc iris (: ). I want to reproduce the results as shown here (Fig. 5). That paper is also my source for the BIC formulas. I have 2 ...
Kam Sen's user avatar
  • 540
27 votes
4 answers
43k views

How to compute the standard errors of a logistic regression's coefficients

I am using Python's scikit-learn to train and test a logistic regression. scikit-learn returns the regression's coefficients of the independent variables, but it does not provide the coefficients' ...
Gyan Veda's user avatar
  • 936
3 votes
1 answer
1k views

Name of algorithm (or paper) that scikit-learn cluster.estimate_bandwidth() function implements for meanshift bandwidth selection

Can someone tell me the name of the algorithm (or paper) that sklearn.cluster.estimate_bandwidth implements and is used by the meanshift algorithm implemented in Scikit-Learn to automatically select ...
lightalchemist's user avatar
3 votes
2 answers
9k views

How to construct the feature weight vector (or decision boundary) from a linear SVM classifier with scikit?

I use the following code to train an SVM classifier: clf = svm.SVC(kernel='linear') clf.fit(train_mat, train_labels) It fits the data and saves the info in the <...
idoda's user avatar
  • 217
3 votes
0 answers
105 views

Logistic Regression not quite working

I'm playing around with logistic regression (using scikit-learn, which uses liblinear) I created some example data sets, and it often works well. Since I created the data sets, I already know the ...
tg3's user avatar
  • 31
2 votes
3 answers
1k views

what to do with 0.5 class probabilities ? [closed]

I am currently training a random forest regressor (scikit learn) on the Titanic dataset. My question is related to this issue (https://stackoverflow.com/questions/19984957/scikit-predict-default-...
Scratch's user avatar
  • 772
5 votes
3 answers
3k views

Heuristic Feature Selection for Gradient Boosting

If I am trying to select from two different sets of features for a Gradient Boosting Machine, but I do not want to run through training an entire model on each set, could I differentiate performance ...
user3253885's user avatar
2 votes
0 answers
2k views

Dimension Reduction using PCA and Random Forests

I an using scikit-learn as a toolset. I have 1K features as candidates and am trying to reduce the feature set as I believe the majority is noise (but am not sure). I wanted to somehow automate ...
Chris Rigano's user avatar
12 votes
4 answers
51k views

Principal Component Analysis and Regression in Python

I'm trying to figure out how to reproduce in Python some work that I've done in SAS. Using this dataset, where multicollinearity is a problem, I would like to perform principal component analysis in ...
Clay's user avatar
  • 255
5 votes
2 answers
8k views

Is it possible to train a one-class SVM to have zero training error?

I'm trying to work on an anomaly detection problem, so I am currently exploring my options on which algorithm is best to use for me. I've been looking at the one-class SVM in the scikit-learn library ...
sgdsgyhetwaraw's user avatar
1 vote
1 answer
1k views

How to interpret scikit learn classification tree?

I'm currently trying to work with scikit-learn classification tree. I followed the example on iris dataset : http://scikit-learn.org/stable/modules/tree.html and everything is working fine. I do ...
Scratch's user avatar
  • 772
2 votes
0 answers
3k views

Features in sklearn logistic regression

I have some problem with adding own features to sklearn.linear_model.LogisticRegression. But anyway lets see some example code: ...
Aku's user avatar
  • 21
0 votes
1 answer
2k views

Scikit-Learn GaussianHMM decode vs score [closed]

What Exactly is the difference between decode and score? The documentation seems pretty sparse regarding this. My guess is that: decode represents the probability of the best sequence of states for a ...
A.D's user avatar
  • 2,394
2 votes
1 answer
324 views

Assigning tags to documents

I am dealing with a text classification problem. Where I need to assign tags to a document. The amount of tags I need to assign varies from 1 to 5. I am struggling somewhat on how I should tackle this ...
Learner's user avatar
  • 123
2 votes
1 answer
3k views

Comparing different classifiers (using ski-kit cross validation values)

Thanks for taking the time to read this I'm new to Machine Learning and so am going through a Kaggle competition to help me improve but I have a question. How can I compare different classifiers?? My ...
Azureaus's user avatar
8 votes
1 answer
18k views

How to compare dbscan clusters / choose epsilon parameter

I am currently trying to make a DBSCAN clustering using scikit learn in python. I would like to compare the different outputs when varying the epsilon parameter in order to choose the right epsilon ...
Scratch's user avatar
  • 772
12 votes
1 answer
5k views

Can Random Forests do much better than the 2.8% test error on MNIST?

I haven't found any literature on the application of Random Forests to MNIST, CIFAR, STL-10, etc. so I thought I'd try them with the permutation-invariant MNIST myself. In R, I tried: ...
MWB's user avatar
  • 1,271
12 votes
1 answer
30k views

Clustering inertia formula in scikit learn

I would like to code a kmeans clustering in python using pandas and scikit learn. In order to select the good k, I would like to code the Gap Statistic from Tibshirani and al 2001 (pdf). I would like ...
Scratch's user avatar
  • 772
6 votes
3 answers
5k views

scikit-learn score metric on the coefficient of determination $R^2$

I am using scikit-learn in Python and they define a quantity called score. It's defined in the middle of the documentation page. Reproduced here: Returns the ...
user35233's user avatar
3 votes
1 answer
370 views

How do I find co-occurring labels?

I have a matrix that is of the shape n_samples by n_features, where n_samples ~ 7000 and <...
ericmjl's user avatar
  • 205
7 votes
2 answers
8k views

Scikit-learn's Gaussian Processes: How to include multiple hyperparameters in kernel/cov function?

I'm using the scikit-learn's implementation of Gaussian processes. A simple thing to do is to combine multiple kernels as a linear combination to describe your time series properly. So I'd like to ...
hadsed's user avatar
  • 171
4 votes
1 answer
4k views

What is the objective Scikit-learn's Random Forest classifier is optimizing at each node?

I would like to ask what is the specific objective function that Scikit-learn's Random Forest classifier is optimizing at each node for the "Entropy" option. My understanding is that entropy is used ...
lightalchemist's user avatar
2 votes
1 answer
435 views

Scikit linear model predictions not matching

I'm using scikits linear model for modelling two input variables and one output variable. I suspect that the two input variables have a quadratic relationship with the output variable. So I created ...
user1893354's user avatar
  • 1,855
5 votes
2 answers
14k views

Lasso cross validation

I want to perform cross validation to find the regularization parameter for Lasso. I am using scikit-learn library in python. I first generate the dataset and then perform k-fold cross-validation. ...
Shishir Pandey's user avatar
1 vote
1 answer
331 views

What is the min_density parameter in scikit-learn Random Forest/ExtraTrees for?

The ExtraTreesClassifier and Random Forest in Scikit learn library has a parameter "min_density". Its default value is set to 0.1. I cannot figure out what this min_density parameter means and how ...
lightalchemist's user avatar
22 votes
2 answers
47k views

Random forest is overfitting?

I'm experimenting with random forests with scikit-learn and I'm getting great results of my training set, but relatively poor results on my test set... Here is the problem (inspired from poker) which ...
Uwat's user avatar
  • 567
26 votes
2 answers
34k views

How to use scikit-learn's cross validation functions on multi-label classifiers

I'm testing different classifiers on a data set where there are 5 classes and each instance can belong to one or more of these classes, so I'm using scikit-learn's multi-label classifiers, ...
chippies's user avatar
  • 603
3 votes
2 answers
713 views

Learning from one positive

Say that in a binary classification problem you have several negatives and only one positive. What types of models are good to learn from this data, and predict the label for a new instance? ...
Amelio Vazquez-Reina's user avatar
10 votes
2 answers
14k views

By using SMOTE the classification of the validation set is bad

I want to do classification with 2 classes. When I classify without smote I get: ...
Olivier_s_j's user avatar
  • 1,185
5 votes
3 answers
13k views

Having trouble understanding cross-validation results from scikit-learn

Actually, my question may just be about cross-validation in general. Here's what I'm doing: I'm trying to come up with a model using scikit-learn to learn on some data I've got. I've decided to use an ...
Shaun Lippy's user avatar
6 votes
3 answers
255 views

Sharing a model trained on confidential data

I have a regularized logistic regression model using scikit-learn and would like to share it with others, however the data it is trained on is confidential and must remain protected. The model uses ...
Alexander Measure's user avatar
5 votes
0 answers
13k views

Scikit-learn reports memory error when fitting Gaussian process model [closed]

I want to fit a Gaussian Process with about 50,000 training examples and 130 features using Scikit-learn. Right now, I only have 1 theta hyperparameters as I run the process with all defaults. But I ...
siamii's user avatar
  • 2,007
42 votes
4 answers
126k views

Polynomial regression using scikit-learn

I am trying to use scikit-learn for polynomial regression. From what I read polynomial regression is a special case of linear regression. I was hopping that maybe one of scikit's generalized linear ...
Mihai Damian's user avatar
7 votes
1 answer
7k views

What is the way to represent factor variables in scikit-learn while using Random Forests?

I am solving a classification problem using Random Forests. For that I have decided to use Python library scikit-learn. But I am new to both Random Forest algorithm and this tool. My data contains ...
Prince Kumar's user avatar
45 votes
2 answers
191k views

Mean absolute percentage error (MAPE) in Scikit-learn [closed]

How can we calculate the Mean absolute percentage error (MAPE) of our predictions using Python and scikit-learn? From the docs, we have only these 4 metric functions for Regressions: metrics....
Nyxynyx's user avatar
  • 975
7 votes
2 answers
2k views

Why do categorical predictor variables in regression need to be recoded as multiple predictors?

I'm learning about machine learning using Python's library scikit learn, and in their tutorial here they mentioned about a categorical variable color which can have ...
Nyxynyx's user avatar
  • 975
13 votes
4 answers
30k views

Why is svm not so good as decision tree on the same data?

I am new to machine learning and try to use scikit-learn(sklearn) to deal with a classification problem. Both DecisionTree and SVM can train a classifier for this problem. I use ...
JavaNoScript's user avatar
0 votes
2 answers
825 views

In SVM, what are the labels and how do you get them from the data?

I'm working on a school project and have decided to use SVM for stock market prediction. I have a 1000x5 matrix of stock quotes containg data for open, close, high, low, volume data. From what I know,...
BDuelz's user avatar
  • 103
6 votes
1 answer
5k views

How are categorical variables used when fitting a decision tree in scikit-learn?

I am used to R, in which you can use factor(variable) to indicate a categorical variable. However, in scikit-learn, trying to pass a variable of strings causes the DecisionTreeClassifier to give an ...
Killian_OC's user avatar
4 votes
1 answer
1k views

Simple text classifier: classification taking forever?

I work for a small tech startup, and I want to classify our users into demographics based on the domain of their email address. When users sign up to our site, they can enter a job category or pick "...
BenDundee's user avatar
  • 639