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
0 answers
11 views

QuantileRegressor from sklearn seems to ignore part of my input data

I have i.i.d. training data of the form $(X_i,A_i,Y_i)$, where $X_i$ is drawn from $\mathcal{N}(0,9)$, $A_i$ is drawn from the uniform distribution on $\left\{ 1,2,3,4\right\}$, and $Y_i$ is drawn, ...
0 votes
0 answers
7 views

Logistics regression decision boundary line does not seem to be correct? [closed]

Here's the data: ...
0 votes
1 answer
19 views

HiClass: Modelling a Hierarchical Classifier

My question is specifically directed to the hiClass Python package for hierarchical classification (I am not sure if it is right to ask here, since I am not reporting an issue). After reading answer ...
  • 253
0 votes
0 answers
33 views

How to derive Complement Naive Bayes rule

I have been trying to use probability rules to mathematically derive the complement naive bayes (CNB) classifier that is developed in this document by Rennie et al.. It is also currently implemented ...
0 votes
0 answers
17 views

how to set normalize_y properly in sklearn GPR

In description of GPR in sklearn, it says: ...
  • 145
1 vote
1 answer
22 views

why GradientBoosting Regressor predictions stagnate within a specific interval of values?

So I am using HistGradientBoostingRegressor (scikit learn) to predict temperature values. After training and testing, the model seems to provide predictions that ...
0 votes
1 answer
27 views

How to interpret NearestNeighbor results obtained using cosine similarity for tf-idf vectors

Why is the top result obtained using cosine similarity extremely close to 0 not the expected 1? That implies complete orthogonality. Data: 100k documents/rows with 2000 features(TF_IDF values of ...
  • 111
2 votes
1 answer
218 views

Negative R squared but with close predictions

I'm getting a pretty bad $R^2$, negative in fact, but the graph, where predicted values are plotted over test values, looks very solid. How is this possible? I'm quite new to DS and have never faced ...
1 vote
1 answer
47 views

Is it still true that sklearn cannot be trusted for statistics and R implementations of many models are more trustworthy? [closed]

I came across this interesting r/statistics post here: As of the time of writing (Feb 2023) the post is 5 years old, but it is disturbing and makes me thing twice about blindly using sklearn. The top ...
1 vote
0 answers
52 views

How to structure combinations of dataframes for regression, without corruption/loss?

I have a data set, redacted sample below. My goal is linear regression. My question is: Have I created unintended results, due to how I structured the df, using concat and/or div? For example, ...
1 vote
0 answers
37 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 ...
0 votes
0 answers
35 views

Inverse Prediction with RANSAC with polynomial features

I am trying to fit a Ransac Regressor to a set of datapoints that looks like this: ...
  • 63
1 vote
1 answer
50 views

how to include minority class in all folds

I am working on an imbalance dataset with a 98:2 ratio (1M record in the majority class and 20K in the minority class) I am planning to run my model for 30 folds, I tried with stratified K folds but ...
  • 121
1 vote
1 answer
93 views

Massive difference between R's glmnet and Python's sklearn regarding Lasso regression

I have a burning question. First, in Python: ...
0 votes
0 answers
27 views

Is it better to use `StandardScaler` before using `MinMaxScaler`? [duplicate]

in sklearn, if I want to transform the data to range(-1, 1), do you think it is better to use StandardScaler before using ...
1 vote
1 answer
17 views

Difference between predcting multiple outputs and single output with random forest

I am trying to predict certain output features (6 in total) with random forest with the input features always being the same. I noticed that my random forest model always fits better when I am trying ...
0 votes
1 answer
110 views

How to treat duplicates while dealing with real data?

Let’s assume that samples in a dataset are characterized by ID, timestamp, features, and target and each sample is a real observation. After dropping totally-duplicated rows, how should duplicates (...
0 votes
0 answers
20 views

How to implement a linear regression (like the SMT toolbox) using sklearn's Gaussian Process?

The SMT package allows a poly option (see the documentation here and source code here), where a functional form (constant, linear, or quadratic) is assumed as a ...
0 votes
0 answers
36 views

Grid search with KFold CV and Early Stopping - which validation set?

I'm training a NN to solve a regression task. I want to perform a grid search with Kfold combined with early stopping, but the only way I found is by passing a new validation set (different from the ...
0 votes
0 answers
28 views

Correct NMF usage in context of recommender systems

I am trying to teach myself about the NMF models (in the context of recommender systems), and I have come across different suggestions on how to set up such a workflow, but I'm not sure if both are ...
  • 101
1 vote
1 answer
31 views

What is the best way of creating new features in a dataset?

I recently started working with sklearn, and found myself creating new features often (new features with K Bins, with various Encoders etc.). What I noticed though, is that is very difficult to ...
  • 11
0 votes
0 answers
19 views

why sklearn SelectFromModel estimator_.coef_ return a 2d-array

My data df_X has 11 features and y is multi-class label. I used multi-class SVM to select importance of features. ...
  • 1,181
1 vote
1 answer
39 views

How to find the contributing probability of individual features in a machine learning model?

In some machine learning models there is a predict_proba function for the overall class probability based on all of the features in the model. Is there a way to find the individual probability ...
  • 13
1 vote
0 answers
66 views

multioutput='variance_weighted' in scikit-learn r2_score: what does it calculate?

I am using scikit-learn r2_score function and I would like to understand what the option 'variance_weighted' calculates. In the documentation page it tells: Scores of all outputs are averaged, ...
-1 votes
1 answer
125 views

Scikit-learn and Keras' MLP very different with same hyperparameters

I'm using Multilayer Perceptron ANNs at the very beginning of my project (it's a binary classification problem). Because it's simpler, I started with Scikit-learn. I got a magic result, with my model ...
1 vote
0 answers
143 views

Correct way to interpret sklearn's calibration error and generate a numeric calibration loss/score

I have been using sklearn's CalibrationDisplay and think it is pretty cool. One thing I am wondering, though, is how I could potentially take that curve and make it an interpretable score. For example,...
  • 111
0 votes
0 answers
310 views

Silhouette Score with Noise (from DBSCAN)

I stumbled across this example on scikit-learn (1.2.0), where the silhouette score alongside some other metrics is computed for DBSCAN cluster assignments. These assignments include some Noise ...
  • 417
2 votes
1 answer
465 views

Scikit-learn: mutual info regression

My understanding of the mutual information between two random variables X and Y can be stated formally as follows: $$I(X ; Y) = H(X) — H(X | Y)$$ Where $I(X; Y)$ is the mutual information for $X$ and $...
  • 1,062
1 vote
1 answer
28 views

Calculating error metrics on log10(y) bayesian ridge regression model. Why does model perform better when trained on log10(y)?

I am using scikit learn's Bayesian ridge regression model and am training my model on log10(y), exponentiating (10 ** y_i) my predictions back to their original value, then calculating my error ...
1 vote
1 answer
68 views

How to handle with long-tail classification

I have a long tailed distribution with many classes, and the num of samples per class is ...
  • 57
1 vote
0 answers
61 views

Optimization of Box-Cox and Yeo-Johnson Log-Likelihood function

This question is a continuation of this question: Derivation of Box-Cox and Yeo-Johnson Log-Likelihood Functions. In order to derive the maximum lambda value in log-likelihood objective function for ...
  • 111
0 votes
1 answer
118 views

Get label names from loaded model in sklearn [closed]

Is it possible to get the label names from an sklearn SGDClassifier model that is loaded from a pickle file? ...
0 votes
0 answers
83 views

What is the difference between Linear Regression and Support Vector Regression?

My goal is to understand the advantages of Support Vector Machine. What I have in mind is that Support Vector Machine can have kernel Radial Basis Function ie ...
0 votes
1 answer
424 views

How to return feature_names_out with sklearn.preprocessing.FunctionTransformer? [closed]

My goal is to impute not with sklearn.impute.SimpleImputer. My goal is to impute with sklearn.preprocessing.FunctionTransformer. ...
0 votes
0 answers
25 views

Why feature selection based on multicollinearity decrease the metrics for LogisticRegression and other algoorithm?

My goal is to understand how to do feature selection. The problem is 'my beliefs' caused the metrics (ie for Classifier, the F1 Score) to drop. I am ready to drop these beliefs. How do you do feature ...
0 votes
0 answers
11 views

Imbalanced binary classification results discussion

Hello I'm wondering how do you consider these result For binary classification with class imbalance.(84% to 16). Accuracy 96 Precision 94 Recall 80 F1 86 Roc_auc 98
0 votes
0 answers
10 views

Intermediate results of an SVM in OvO scenario

SVM is primarily a binary classifier. For a multiclass classification problem, SVM supports transforms the problem into a binary ...
  • 253
1 vote
1 answer
179 views

How to get the threshold from PrecisionRecallDisplay?

My goal is to tune the Classifier with probability predict_proba() < threshold. Therefore, I need to get the threshold. The problem is ...
2 votes
1 answer
333 views

How to define a classification loss function for discrete ordinal values

Assume multi class classification task where we have 5 labels: 1, 2, 3, 4, 5. For simplicity, let's assume it is the rating of movies, number of stars. I am after a ...
  • 165
1 vote
0 answers
16 views

How do I assess the significance of classification accuracy, after determining hyperparameters with GridSearchCV and testing with train_test_split?

So I've recently learned that if I use GridSearchCV to select the best hyperparameters AND evaluate model performance, this can lead to an optimistically biased measure of performance due to ...
0 votes
0 answers
23 views

Test score better than train set (nested cross-validation)

I can't really figure out what is going on here. I'm using multiple repeats of nested cross-validation and my test score is consistently better than the best score of my inner loop grid search (i.e., ...
  • 345
0 votes
0 answers
20 views

Is dummy trap variable really a problem?

My goal is to encode a 'Education_Level' which have values 'Uneducated', 'High School', 'College', 'Graduate', 'Post-Graduate', 'Doctorate'. The problem is that if I drop the first column (in this ...
3 votes
2 answers
107 views

Is 'High School', 'Graduate', 'Unknown' ordinal or nominal data?

My goal is to Feature Engineering the column Education_Level. This is an obvious ordinal data. However, I am having difficulty to put Education_Level to choose <...
1 vote
1 answer
118 views

Confusion regarding K-fold Cross Validation

In K fold cross validation, we divide the dataset into k folds, where we train the model on k-1 folds and test the model on the remaining fold. We do so until all the folds were assigned as the test ...
  • 45
13 votes
5 answers
2k views

Is Median Absolute Percentage Error useless?

I'm working on a project focused on pricing houses. Looking online I see a lot of works and companies providing the performances of their model using the median instead of the mean (see for example ...
0 votes
1 answer
118 views

Meaning of colors in from sklearn DecisionTreeClassifier

I do not understand the meaning of colors in nodes/leaves when building decision trees by sklearn.tree DecisionTreeClassifier. Here's my code: ...
2 votes
1 answer
81 views

Regression of circular variable with scikit-learn

I am trying to use Support Vector Regression on a (neurophysiological) dataset where the position of points on a circular manifold in N dimensions is correlated with a circular variable (phase of an ...
  • 53
0 votes
0 answers
103 views

How to determine the ROC AUC score in sklearn for multi-class classification problems

In https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_auc_score.html, the multi-class ROC AUC score can be computed by multi_class='ovo' or ...
  • 989
0 votes
1 answer
28 views

Regressor predicting accuracy on previously seen data

I am applying various regression algorithms, such as RandomForestRegressor, AdaBoostRegressor, KNeighborsRegressor ...etc. I fit these models on training data (only 1 feature for simplicity), and ...
1 vote
0 answers
73 views

Lasso for a specific number of features

The goal of my project is to reduce a metabolomics dataset of around 1000 to sets of varying size in order to attempt to identify reduced feature sets that can serve as biomarkers for predicting ...
  • 345

1
2 3 4 5
35