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.

570 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10 votes
1 answer
3k views

Feature selection using chi squared for continuous features

I'm looking at univariate feature selection. A method that is often described, is to look at the p-values for a $\chi^2$-test. However, I'm confused as to how this works for continuous variables. 1. ...
Jondiedoop's user avatar
8 votes
0 answers
3k views

Which standard deviation of the cross-validation score?

When doing cross-validation for model selection, I found there are many ways to quote the "standard deviation" for the cross-validation scores (here "score" means an evaluation metric e.g. accuracy, ...
xiaoxiao87's user avatar
7 votes
0 answers
2k views

Zero-inflation with sklearn and continuous target?

My current data have quite a large amount of zeros (~60%), and I'm thinking of trying to implement a zero-inflated model of sorts with sklearn. While I've used zero-inflated poisson/negative binomial ...
bjr96571's user avatar
7 votes
1 answer
5k views

Improve precision/recall for class imbalance?

Trying to get better precision/recall for both classes ... any tips? I have heterogeneous features [a few num vars, a few cat vars, and 2 text vars] Target is a binary classification w/ class ...
thePurplePython's user avatar
6 votes
0 answers
4k views

Why SVM with gamma='scale' for RBF kernel works so well?

The intuitive explanation for the gamma parameter of the RBF kernel in SVMs is the following: Intuitively, the gamma parameter ...
Andreas K.'s user avatar
5 votes
0 answers
795 views

Results of cv.glmnet in R versus RidgeCV in scikit-learn

I'm having trouble reconciling different values for the ridge parameter that minimizes mean squared error when using RidgeCV in scikit-learn (Python) and cv.glmnet (R). First a few things to note: ...
optimusLime's user avatar
5 votes
0 answers
3k views

Summing predicted probabilities from logistic regression using 'one vs. rest'

I have a multiclass classification problem that I have solved using a 'one vs. rest' approach via binary logistic regression classifiers from Python's scikit-learn package. In my problem, there are 3 ...
Mathews24's user avatar
  • 469
5 votes
0 answers
8k views

Correct number of components in GMM according to BIC and AIC plots

I have applied GMM(Gaussian Mixture Model) to my data set and I have plotted the resulting BIC(Bayesian Information Criterion) and AIC(Akaike Information Criterion) for different number of components. ...
user59419's user avatar
  • 261
5 votes
1 answer
953 views

Modeling trends with Gaussian Processes

I am trying to use Gaussian Process Regression to model data that has a clear upward rising trend. Here is a basic plot of the data - The most well-known example of the flexibility of GPs in such ...
statBeginner's user avatar
  • 1,561
4 votes
0 answers
965 views

Do you need to adjust the probability if you use the 'class_weight' parameter in LogisticRegression-sklearn?

I have a imbalanced dataset and I want the the output as probabilities and not labels. Hence using Logistic Regression seemed to be the obvious choice. However the classsifer started predicting all ...
Axelius's user avatar
  • 330
4 votes
0 answers
3k views

Sklearn / GridsearchCV: roc_auc score better with evaluating against accuracy than roc_auc

I've run into the following problem which is kinda puzzling me. I've two GridSearch classes configured, one with the scoring set to roc_auc and the other using ...
Jasper's user avatar
  • 215
4 votes
0 answers
836 views

What data assumptions are made when using an isolation forest?

I am performing anomaly detection with a high-dimensional zero-inflated data-set. This rules out options like standard Gaussian anomaly detection as no amount of transformation can make my features "...
Darrrrrren's user avatar
4 votes
0 answers
778 views

Counter intuitive behavior from scikit-learn's SGDClassifier

I am working with SGDClassifier from Python library scikit-learn, a function which implements linear classification with a ...
Daneel Olivaw's user avatar
3 votes
2 answers
670 views

How to adjust the classification thresholds in a multiclass classification problem?

I am facing a multiclass classification problem where I have 4 classes and one of them dominates over the others. I use a KNN classification model and the majority of the instances are being ...
Rirro Romeu's user avatar
3 votes
1 answer
394 views

Question about the output results of Scikit-learn's adjusted rand index

There is a problem that the calculation of ARI using the Adjusted_rand_score function in Scikit-learn does not match the results of the ARI calculation based on the paper proposed by Hubert et al1. ...
S. Baba's user avatar
  • 31
3 votes
0 answers
105 views

Avoiding data leakage in preprocessing and handling unseen values in test data

I've been reading up on avoiding data leakage in the preprocessing step of a machine-learning/data-science pipeline, specifically that it is wrong to apply preprocessing to both training and test data ...
njp's user avatar
  • 131
3 votes
0 answers
46 views

Cluster Algorithm for multidimensional data

My goal is to cluster data (20000 samples with a range from 0.0 to 1.0, and 14 dimensions/features). Since I don't know the number of clusters, I tried using MeanShift and DBSCAN. My problem with ...
Flitschi's user avatar
3 votes
1 answer
653 views

Does Sklean have a Gaussian Discriminant Analysis (GDA)

I was trying to look for the Gaussian Discriminant Analysis in sklearn however I was unsuccessful and I was wondering what it the name of it. I was about to find the LinearDiscriminantAnalysis and ...
Alisha Patel's user avatar
3 votes
0 answers
142 views

KFold CV and Monte-Carlo CV performance for a regression problem

I've ran the following code on google colaboratory. Succintly, I've used some housing prices for a typical regression problem, and then trained the same simple neural network, but with different Cross-...
An old man in the sea.'s user avatar
3 votes
0 answers
274 views

mean squared error or brier score?

i have a classification problem using xgboost, i was optimizing on brier score or 'neg_brier_score' in sklearn. however what is the difference between 'neg_brier_score' and '‘neg_mean_squared_error’ ...
mathella's user avatar
3 votes
0 answers
673 views

Understanding probability calibration with isotonic regression in sklearn

After reading sklearn manual it was not very obvious for me to understand how Isotonic regression works in the case of probability calibration (using CalibratedClassifierCV). I briefly read sklearn's ...
Rodvi's user avatar
  • 926
3 votes
0 answers
272 views

SVM Scaling problem with One-Class SVM

I'm trying to mess around with a one-class SVM implementation I hacked together from ArduinoSVM. I'm using an RBF kernel and training the model with just "in" datapoints with sklearn. First, as is ...
foldone's user avatar
  • 31
3 votes
0 answers
965 views

Why are the Polynomial Features used in a Linear Regression model not working as expected as the degree increases?

I'm fitting several polynomial regression models of varying degree. The smaller degree models (1 to 7) are behaving as expected. However, as the model increases in degree (8 or higher), the fitted ...
Featurea's user avatar
3 votes
0 answers
669 views

OneVsRestClassifier and predict_proba

I have an interesting problem. I am working with a MULTICLASS problem (~90 classes), and have settled on using OneVsRestClassifier wrapper around a RandomForestClassifier. When I call a ....
Greem666's user avatar
  • 131
3 votes
0 answers
171 views

Why does lasso return unstable features when using the same data?

I am using scikit-learn to shrink my data set having around 800 features. It is a very noisy data (market and economic data) To my best knowledge, lasso returns same features for the same data set. ...
mlee_jordan's user avatar
3 votes
0 answers
205 views

How to aggregate calibration curves which were created in cross validation?

When looking into Scikit's CalibratedClassifierCV I noticed that the object needs to keep multiple calibrated classifiers in memory to average the results in real time. I understand that these ...
sapo_cosmico's user avatar
3 votes
1 answer
340 views

How to evaluate the results of a multilabel classifier using the predicted probabilities?

I can use sklearn accuracy_score to evaluate de predicted values of my multilabel classifier. But how can I evaluate the predicted probabilities obtained with predict_proba?
Hohenheimsenberg's user avatar
3 votes
0 answers
1k views

Mini_batches with scikit-learn MLPRegressor

I'm trying to build a regression model with ANN with scikit-learn using sklearn.neural_network.MLPRegressor. I have a 1000 data samples, which I want to split like ...
shep4rd's user avatar
  • 41
3 votes
0 answers
57 views

Is LinearDiscriminantAnalysis legit for classifying images?

this was moved from SO, hope this is a better place to ask :) on this context: LDA = LinearDiscriminantAnalysis I tried classifying images' descriptors with SVM SVC linear kernel which gave bad ...
CIsForCookies's user avatar
3 votes
0 answers
11k views

Variation Inflation Factor Gives inf

I have a dataset that contains 292 attributes. I want to calculate VIF to address multicollinearity in dataset. Here is a snippet which I have used to calculate VIF ...
Vivek Srinivasan's user avatar
3 votes
0 answers
161 views

Regularization and scaling feature matrix with weights

When using L1 or L2 regularization in a glm it is necessary to standardize the features to be variance 1. When applying weights to the glm, should the feature matrix be standardized so that it has a ...
JCWong's user avatar
  • 1,712
3 votes
0 answers
338 views

How to deal with variability in clustering. Multiple/Meta clustering?

I'm not sure what information is relevant here, so here is some background: I'm using Python 3 / sklearn, but I could probably use R if needed. I have a small sparse data-set (~1500 samples, ~1600 ...
pdanese's user avatar
  • 191
3 votes
0 answers
325 views

What are the most important parameters to tune in a deep belief network?

I am trying to create a Deep Belief Network (DBF) for a binary classification problem. The nolearn package provides a good library for implementing them. I see that there are very many parameters to ...
prashanth's user avatar
  • 4,007
3 votes
0 answers
2k views

How is the solver parameter and MLE related in Logistic regression for scikit-learn

I'm trying to understand the implementation of scikit-learn's Logistic Regression. I am new to the framework, and have only a basic understanding of logistic regression. http://scikit-learn.org/...
user3547551's user avatar
3 votes
0 answers
2k views

Processing data with different number of features

I have this classification/regression task but the most interesting thing is that the number of features for each record is different. Features are already extracted and already prepared thus the ...
David_MII's user avatar
3 votes
0 answers
637 views

Principal Component Regression on log returns exactly predicting last value of time series every time

I am trying to run PCR on a list of a few time series, and no matter which dates I run this on, I am getting a difference between my predicted and actual of zero for the last entry in every time ...
weskpga's user avatar
  • 31
3 votes
0 answers
598 views

Can I optimize for specificity using GridSearchCV in sklearn?

I am developing a fraud detection system for online purchases using random forests. My first concern was to optimize for recall, as the dataset was originally unbalanced (98% no fraud events and 2% ...
Manuel Q's user avatar
  • 153
3 votes
0 answers
524 views

Unequal misclassification costs for SVC?

I wonder if there is a way to specify custom cost function in sklearn/python? (atm I use sklearn SVC) My real problem has 7 different classes, but to make it more clear lets assume that I want to ...
Vitali's user avatar
  • 31
3 votes
0 answers
70 views

What is the best way to simultaneously fit multiple binomial and continuous predictors?

What is the most efficient way to fit a linear model w so that Y = w . X, where X is a ...
kingjr's user avatar
  • 31
3 votes
0 answers
98 views

Car out of route

I have one KML file that describes the movement of a car. Data comes from sensor in the car, contains wrong or noisy measurements. I want to filter the wrong measurements, i.e. throw away the ...
Duygu's user avatar
  • 41
3 votes
0 answers
5k views

How to use RFECV for feature selection and cross validation

I am still very new to machine learning and trying to figure things out myself. I am using SciKit learn and have a data set of tweets with around 20,000 features (n_features=20,000). So far I achieved ...
cirnelle's user avatar
3 votes
0 answers
2k views

Naive Bayes and text classification: which probability model and vectorizer combination makes sense?

I am wondering which combinations of Naive models can be paired with different vectorizing methods so that it makes sense. Let's say we have a simple binary spam-classification task. Multinomial ...
user avatar
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
3 votes
1 answer
222 views

How much higher accuracy of train than test is enough to consider the model overfitted?

Considering a dataset of 920 samples with 40 features in a binary classification problem. The dataset is the heart disease dataset publicly available here. I preprocessed the dataset discarding ...
Javiss's user avatar
  • 131
2 votes
0 answers
38 views

Confusion about the code for choosing "stumps" in Adaboost algorithm

(I actually asked the following question on Stack Overflow recently: https://stackoverflow.com/questions/76842431/confusion-about-the-code-for-choosing-stumps-in-adaboost-algorithm but then I ...
Richard's user avatar
  • 121
2 votes
0 answers
32 views

How to choose the potential hyperparameters for GridSearchCV on RandomForestClassifier? Will default always be the best?

I'm fairly new to machine learning, and I know similar questions have been asked but I can't find an answer that satisfies my curiosity. I'm working on a Random Forest Classifier model in python, and ...
Sasha Halpern's user avatar
2 votes
0 answers
222 views

Does scikit-learn support plotting calibration curve for multiclass classifier?

I have trained a multi class classifier and calibrated the classified using scikit-learn library's CalibratedClassifierCV class. To check how well the probabilities are calibrated, I tried plotting ...
yodasoda18's user avatar
2 votes
1 answer
46 views

add more data to training set

I am using the LinearSVC() available on scikit learn to classify texts into a max of 7 seven labels. So, it is a multilabel classification problem. I am training on a small amount of data and testing ...
Natália Resende's user avatar
2 votes
1 answer
47 views

Understanding Stacked Generalization

I am trying to figure out how stacked generalization works? I think we train n models on the same dataset and get their class probabilities. Then these class probabilities are fed into another model. ...
deniyore's user avatar
2 votes
1 answer
34 views

Different precisions in predicting two classes with logistic regression

I am using the kaggle's stroke dataset trying to predict the stroke target feature, according to multiple predictive features. https://www.kaggle.com/datasets/...
Programming Noob's user avatar

1
2 3 4 5
12