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
0
votes
0answers
21 views

Stacking of Machine Learning models using different data splits

I have one single dataset with 2 classes. I want to make a model for binary classification, and I am experimenting a bit. My intention is to use stacking on some models by using subsets of the 1 ...
0
votes
0answers
91 views

Multiclass Logistic Regression: How does sklearn model.coef_ return K well-identified sets of coefficients for K classes?

I am looking to fit a multinomial logistic regression model in Python using sklearn, some pseudo python code below (does not include my data): ...
0
votes
0answers
20 views

Getting Negative Values When Trying to Recover Standard Errors from Sparse Matrix with sklearn LinearRegression

I am using the answer given to this SO question to try to recover Standard Errors for a large linear regression from the LinearRegression() method in the python ...
0
votes
0answers
56 views

sklearn.model_selection : sampling issue with TimeSeriesSplit

I am new to sklearn and the TimeseriesSplit, I appologize in advance if that's a dumb question. I cannot find nowhere a way to solve my issue. To my understanding a sample is a row in the timeseries, ...
3
votes
1answer
85 views

What does it tell you when PCA cannot reduce the dimensionality of your dataset

I'm new to PCA and I'm trying to apply it to a dataset I have with 15 different features. I normalized my dataset before applying PCA and used the PCA method in the decomposition function from sklearn....
0
votes
0answers
143 views

how to interpret negative values in permutation importance report?

i am using a permutation report from sklearn. i train my model and optimize on 'mean_squared_error' this is actually negated in sklearn. when i get the perumutation importance report however how do i ...
1
vote
0answers
36 views

Interpretation of unreasonably high R-squared [closed]

High CrossValidated community, I need your "brains" to explain a result related to my model(s). I have some data that contain physical quantities $y$ measured at specific points (e.g. ...
4
votes
3answers
58 views

What's the speed bottleneck in sklearn.svm.SVC.predict?

I'm working with some high resolution images of specimens in test tubes and I found that using an SVC to classify each pixel by HSV value helps me to a great job at segmenting out just the specimen ...
1
vote
1answer
72 views

How to get log-likelihood from squared deviance in Scikit Learn

The score() function computes D^2, the percentage of deviance explained, but I'd like to get the log-likelihood to calculate BIC. What's the formula to go from deviance to log-likelihood? Score ...
3
votes
1answer
61 views

Improving probability calibration of Random Forest for multiclass problem

I am working on getting good probability from Random Forest algorithm for better decision making. Currently, I have trained the RF model with default parameters and then applied isotonic regression ...
0
votes
0answers
6 views

Is it possible to identify which features contribute to the precision and recall for each label in sklearn's classification report output?

Below is an example of classification report output by sklearn. Is there an easy way to identify which features contribute to the precision and recall improvement for each label? I can start with ...
2
votes
0answers
116 views

Why is sklearn's CalibratedClassifierCV not labeled as an ensemble method? [closed]

I always wondered how CalibratedClassifierCV was supposed to achieve probability calibration without a dedicated calibration set (which is appealing since no data is lost for training the classifier). ...
1
vote
0answers
138 views

Custom scoring function random forest classification

I am using scikit-learn to build a classifier which receives an imput X (vector of size 784 which is a 28x28 image representing a hand-written digit from 0 to 9) and predicts the number that is ...
2
votes
0answers
45 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’ ...
1
vote
1answer
146 views

Can oversampling be moved outside stratified k-fold CV?

In a binary classification task, I am using imbalanced-learn's implementation of SMOTENC to oversample the positive class of a very imbalanced dataset. The total number of examples is very high, so ...
0
votes
0answers
162 views

How to properly implement precision and recall for multiclass classification in scikit-learn? (`average` and `labels` argument confusion)

I am trying to understand precision and recall for multiclass classifications. For the concept of True Positive or True Negative...
0
votes
1answer
35 views

scikit-learn linear regressor digests perfectly collinear features?

I am currently running this little piece of code: ...
2
votes
2answers
110 views

XGBoost Compared to Other Ensemble Methods Example

Scikit-learn has an example where it compares different "ensembles of trees" methods for classification on slices of their iris dataset. Being new to machine learning and having seen XGBoost ...
0
votes
0answers
33 views

Independent Component Analysis (ICA): fewer sources than features (fastICA)

I am trying to understand how the ICA by A. Hyvärinen, J. Karhunen, E. Oja (2001) works in practice. In particular, I have problems trying to understand its application to factor-analysis-kind of ...
3
votes
1answer
197 views

How does GridSearchCV(KernelDensity(), Params) find the optimal bandwidth?

I wanna know How GridSearchCV works? I mean this method gives a grid interval for the optional bandwidth params = {'bandwidth': np.linspace(0.1, 1, 100)}, but how does it evaluate each bandwidth value?...
0
votes
1answer
1k views

Constructing a model with SMOTE and sklearn pipeline

I have a very imbalanced dataset on which I'm trying to construct a LinearSVC model with SMOTE and standardization, using a Pipeline. I had already applied SMOTE and sklearn's StandardScaler with ...
1
vote
1answer
40 views

Why is the display of summary statistics changed after normalizing data? [duplicate]

I posted this question on stackoverflow.com and have not received any answer. In case I get an answer from one of them, I will inform on the other. I am using ...
1
vote
0answers
33 views

What does it mean to have 'R^2 larger than chance' (from sklearn docs)

See the following: From : https://scikit-learn.org/stable/modules/permutation_importance.html The part I'm unsure about is: Its validation performance, measured via the score, is significantly ...
0
votes
0answers
9 views

How to control for Co-variate shift in test data set compared to train data for regression task?

I am working on a regression project. But I am facing the problem of covariate shift in features due to time delay.Test data was collected a year later due to which there has been some change in ...
0
votes
0answers
45 views

Changing L2 regularization constant in logistic regression proportionally to the number of columns/rows in the dataset

I'm trying to use scikit LogisticRegression to solve a multiclass text classification problem with variying number of columns (unigrams) in the trainging datasets. From what I understood, L2 ...
3
votes
1answer
154 views

Should Scikit-Learn CalibratedClassifierCV isotonic mode use bucketed rates instead of the actual targets?

This is less a question about sklearn's implementation, and more theoretical. I find it weird that we'd do isotonic regression against target values in {0, 1} because that could result in very jagged ...
2
votes
1answer
385 views

what is the scoring variable called for aucpr?

i am trying to conduct a grid search for an imbalanced problem however i cannot find the aucpr (area under curve precision recall) scoring metric for gridsearch. e.g. you have 'roc-auc', 'neg-brier-...
0
votes
0answers
25 views

Questions about scikit-learn.org “Nested vs non-nested CV” example

I think I'm starting to get an idea about nested cross-validation, but I have a couple questions about this specific example. Isn't what we calculate in the outer loop a less biased performance ...
0
votes
0answers
8 views

Feature engineering of closely related text

I am trying to do multi class classification of text. For many reasons I can't paste the data, atleast now in open. The problem is there is a text of closely related subjects like Anatomy and ...
2
votes
1answer
66 views

Is n_estimators in BaggingRegressor() the number of trees or data subsets?

I'm learning about using the BaggingRegressor() from scikit learn (https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.BaggingRegressor.html) Its <...
1
vote
0answers
27 views

Using Cross Validation for Highly Seasonal Data with small sample

I'm having trouble getting good scores on cross validated metrics on time series regression models. Essentially, I am trying to model product purchases based on amount of money spent on different ...
0
votes
0answers
20 views

Is this the correct procedure for hyperparameter tuning and model evaluation?

As a follow up to my previous post (What is the correct procedure for nested cross-validation?) I wanted to see if my following nested cross-validation procedure is valid: Split my data into train/...
1
vote
0answers
87 views

Should I perform nested CV with Grid Search to make my ensemble model robust?

I'm doing classification of 8 types of hand gestures with stacking models. For that I initially split the data into training and test sets. Then I used GridSerachCV ...
0
votes
0answers
22 views

How does the base_estimator and n_estimators work in the AdaBoostRegressor function provided by Sklearn

I have questions related to the definitions of the base_estimator and n_estimators given in the scikit-learn documentation: <...
1
vote
1answer
39 views

Why does the last estimator of the Sklearn only get fit and not transformed? [closed]

Here is the documentation for the pipeline constructor from Sklearn website: Sequentially apply a list of transforms and a final estimator. Intermediate steps of the pipeline must be ‘transforms’, ...
0
votes
0answers
6 views

Multi target multi class classifcation

I have a problem which have been described precisly in this link https://stackoverflow.com/q/64238213/13669992 As of now I have tried sklearn Classifier Chain with Random Forest as base classifier but ...
0
votes
1answer
45 views

What is the correct procedure for nested cross-validation?

I am trying to use scikit-learn to make a classifier and then predict the accuracy of the classifier. My dataset is relatively small and I am unsure of the best parameters. Hence I turned to nested ...
1
vote
0answers
35 views

How can one use Grid Search without overfitting the model?

I checked several questions, like Overfitting during model selection - AutoML vs Grid search and Hyperparameter tuning using grid search/randomised search, but I don't think any of them answer my ...
2
votes
0answers
28 views

Is Normalized Mutual Info Score equivalent to V-measure when normalized by arithmetic mean

According to sklearn.metrics.v_measure_score, it says This score is identical to normalized_mutual_info_score with the 'arithmetic' option for averaging. In the ...
2
votes
1answer
27 views

I can't explain this precision score

I am printing out the precision score and confusion matrix using sklearn. ...
0
votes
1answer
60 views

How can I extract the correct hyper-plane from sklearn.svm's LinearSVC

I'm not certain I understand how sklearn's Linear SVC works. I had assumed that it would find an optimal hyper-plane to divide one class from another. I tried to recover the separating hyper-plane ...
0
votes
0answers
48 views

How does sample_weights work in Naive Bayes?

I want to use the sample_weights parameter in sklearn Naive Bayes classification. I have seen online that it can be used to balance data but I have also seen that it can be used to weight data with ...
1
vote
1answer
34 views

What's the formula behind Normalization function?

sklearn.preprocessing.Normalizer(norm=l2) I need to undone a normalization (Normalizer algorithm) within my dataset and I'd like to know which formula I should use for it. I've try both formulas (...
1
vote
1answer
29 views

What to do after knowing the model is overfitted?

So I was trying to run a model using scikit-learn. In order to tune the hyperparameters, I used RandomizedSearchCV, just like this: ...
2
votes
1answer
17 views

sklearn's SVM classification failure

I'm trying to fit a trivial classifier but I'm not sure what am I doing wrong. I'm providing scikit-learn's svm.SVC linear classifier with two samples of X=[[0.], [0.5]] and labels y=[0, 1] and I get ...
0
votes
0answers
28 views

How to properly measure accuracy with feature selection?

I applied a feature selector (with this great python package) in my dataset. This package uses the wrapper approach, where you define a classification model that runs on your data and find the best $k$...
0
votes
0answers
14 views

Implementations for Conditional Average Treatment Effects that can be trained incrementally

I am currently working on a very large dataset (billions of rows) of A/B test data and want to implement some methods to estimate conditional average treatment effects. I basically need a forecast ...
3
votes
1answer
120 views

Why is my Random Forest Regression performing worse in cross validation than on a baseline?

So I am trying to use a Random Forest Regression on a dataset with a mix of categorical and numeric data types. The predictors are in X_train and ...
0
votes
0answers
32 views

Need to implement train_test split before validation_curve/learning_curve in Sklearn?

I'm doing a regression using sklearn, and I wonder if there is a need to split my data set X and the target variable y into x_train, x_test, y_train, y_test before implementing the validation_curve ...
1
vote
1answer
39 views

Does it make sense train Linear Support Vector Regression with an epsilon of 0?

In the sklearn.svm.LinearSVR implementation, the default parameter of epsilon is 0.0. And the documentation says "if unsure,...

1 2 3
4
5
32