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
1 vote
2 answers
131 views

Can SVM overfit even with cross-validation?

I am using SVM regressor models to fit some chemical data related to spectroscopy (I cannot say exactly what data because it is an ongoing research in my group). To combat overfitting, I have used 5-...
S R Maiti's user avatar
  • 163
0 votes
0 answers
202 views

What's a good rule of thumb for choosing a sufficient number of quantiles in quantile transformation?

I'm a currently developing a regression model based on the Choquet Integral. To tackle outliers I am using the Quantile Transformer, provided by scikit-learn. I was wondering how the quantile number ...
Glenbreaks's user avatar
2 votes
1 answer
451 views

Data preparation (preprocessing and data cleaning) before or after train-test split with scikit learn?

I have been practicing Data Science/Machine Learning, and I am confused about when to complete the following tasks when using train-test split in scikit learn: EDA Filling in missing data Removing ...
Hokage's user avatar
  • 21
1 vote
0 answers
15 views

Standardization on production dataset

Say I trained a Logistic regression model on a training dataset (sample = 2000), using Standardization. I than test the model on a test dataset (sample = 400) using the Standardization parameter ...
o_p's user avatar
  • 11
9 votes
4 answers
2k views

Is it required to train the model in entire data after cross validation?

I have a model trained as follows. ...
NAS_2339's user avatar
  • 213
0 votes
0 answers
38 views

How can I add information about historical rates of occurrences to class probabilities?

first some introduction: I have a trained a probabilistic softmax model using the sklearn multinomial logistic regression which predicts the class probabilities (class $A, ~B$ or $~C$) of any object ...
Justin Dhooghe's user avatar
2 votes
1 answer
31 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
0 votes
1 answer
83 views

Reconstruct IR Spectra Based on PLS Model

I am currently using the scikit-learn package in python to setup PLS models (sklearn.cross_decomposition.PLSRegression) to predict the concentration of different substances based on IR spectra. In ...
PotatoOwl's user avatar
0 votes
1 answer
340 views

F2 score or the Area under the Precision-Recall-Curve as a scoring metric

I have a dataset with which I want to perform binary classification. The distribution of the target class is imbalanced: 20% positive labels, 80% negative labels. The positive class is more important ...
Daniel's user avatar
  • 145
0 votes
1 answer
1k views

What are the main difference between a QQ plot and a probability plot for measuring nomality? [duplicate]

I am trying to evaluate the normality of the distribution of my model's residuals. I have been using statsmodels.api.qqplot and ...
Archie's user avatar
  • 205
2 votes
1 answer
397 views

Scikit-learn QuantileRegressor memory allocation error. No issue with statsmodel QuantReg with the same data

I'm trying to fit a quantile regression model to my input data. I would like to use sklearn, but I am getting a memory allocation error when I try to fit the model. The same data with the statsmodels ...
Archie's user avatar
  • 205
0 votes
1 answer
235 views

How to properly impute values on the test set using imputer (missForest)

I'm trying to impute some missing values on my dataset $X$. So first I shuffle and split data to obatin the train set X_train and the test set ...
thesecond's user avatar
  • 288
1 vote
1 answer
149 views

How to transform prediction std of gaussian process back to origin

I am looking for a way of rescaling the predictions of my Gaussian Process Model back to the original scale. The data is scaled for training using a ...
sensation96's user avatar
2 votes
1 answer
61 views

What does it mean having 1 as best k parameter in K-NN?

I'm working with a large dataset (761 rows and about 57k-60k features) and after doing a feature selection to select the best 10 features I'm using different ML algorithms to classify some cases. In ...
Julen's user avatar
  • 23
0 votes
1 answer
187 views

Hyperparameter tunning in SelectKBest feature selector

I am working with a pretty large dataset containing 760 rows and arround 58k-60k features and I'd like to perform a feature selection to reduce the dimensionality of those. After stardardising the ...
Julen's user avatar
  • 23
1 vote
2 answers
209 views

Why are sklearn's cross_val_score values not increasing with the size of the training set?

I am working on a lithology identification project similar to the one described here. The idea is to train a model using well log data collected at a handful of drillholes, in order to predict the &...
Sheldon's user avatar
  • 113
0 votes
0 answers
266 views

Combinatorial Cross-Validation Embargo and Purged

There is a library on GitHub called timeseriescv which implements Combinatorial CV. I am trying to use it in conjunction with GridSearchCV. However, unlike normal sklearn cross validators which have a ...
DomIsAwesomee's user avatar
2 votes
1 answer
32 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
2 votes
0 answers
207 views

Train-Test Split with nested groups and multiple balancing factors

I have a large (~15,000) sample of data from individuals nested within families (with about half the data points sharing a family). I want to split the sample in to a training and test set so I can ...
mrpeverill's user avatar
2 votes
1 answer
410 views

sklearn's permutation_importance returns surprising result

I have simulated normally distributed data (x_1 = np.random.normal(0, 1, size=1000)) and used it to create a dependent variable with a linear combination of the ...
JK31's user avatar
  • 63
1 vote
0 answers
97 views

Defining a spatiotemporal (time-varying) kernel using GaussianProcessRegressor [closed]

(I edit the question to make it more specific and clear) High-level idea I want to implement the idea of capturing the correlation between two data points $x$ and $x'$ that can be different at two ...
mr_m's user avatar
  • 11
3 votes
1 answer
303 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
1 vote
0 answers
33 views

Is there a stochastic AdaBoost?

In sklearn, the AdaBoostClassifier and AdaBoostRegressor classes do not have the subsample and max_features parameters, which are responsible for the stochastic approach to building a boosting model. ...
Владислав Гаджиханов's user avatar
3 votes
2 answers
2k views

XGBRegressor score (R2) vs. eval_metric (RMSE)

According to the API Reference, XGBRegressor().score() returns R2. However, according to the XGBoost Paramters page, the default ...
wplo's user avatar
  • 31
6 votes
1 answer
472 views

Why does univariate Mahalanobis distance not match z-score?

I am using Mahalanobis distance for outlier detection. Sometimes my dataset only has 1 feature, sometimes many more. I believe the univariate Mahalanobis distance should be equal to the z-score of the ...
kwinkunks's user avatar
  • 329
2 votes
1 answer
196 views

Random Forest Generating Bad Predictions: What might the issue be?

I'm using sklearn's RandomForestRegressor to try and model a relationship that involves three Feature variables (x1,x2,x3) and ...
Austin Prater's user avatar
1 vote
0 answers
66 views

Detect exact position of a word or number in a sentence with machine learning

I'm trying to come up with an ML model/s to detect if a sentence has sensitive data(telephone number, IBAN, address, etc.) and also get the position of said sensitive data. For Example "My name ...
Metalizer's user avatar
0 votes
0 answers
23 views

How to step-into the learning process of support vector machines

OK, with the intention to produce a balanced class distribution for an imbalanced binary problem based on SVC, I created this custom function. Basically, it takes binary imbalance data, fits an ...
arilwan's user avatar
  • 263
1 vote
0 answers
375 views

Using curve_fit for Non-Linear, Multi-Variate Models [Python] [closed]

Warning: ML Noob. I have a 3D dataset (data at the bottom) with 2 feature variables and 1 target variable. Polynomial Regression produced unsatisfactory results and it seems that the relationship of ...
Austin Prater's user avatar
1 vote
0 answers
33 views

Why would I get a non-zero value for mutual information for one variable, say x_m (belonging to (x_1, ..., x_n)), to target y, if x_m is a constant?

I have n 'features', (x_1, ..., x_n) and a target variable y. I use sklearn's mutual information score for feature selection to determine which features are the most important for the target y. I get ...
Socorro's user avatar
  • 71
0 votes
0 answers
31 views

Non-parametric equivalent of SelectKBest f_classif option

I'm doing a project where I am comparing various feature selection methods to see if they improve performance compared to the original dataset with 747 columns. One I want to try is the ANOVA method, ...
Julia Ballester's user avatar
1 vote
1 answer
308 views

XGBoost Regression on a normal distribution variable produces a one sided distribution (only positive values)

I'm running a scikit-learn XGBoostRegressor with an RMSE loss function, on a variable with a distribution that is close to symmetric around 0 (think normal distribution, with a positive mean that ...
eran's user avatar
  • 131
2 votes
0 answers
245 views

Duality gap calculation in Scikit-learn implementation of Lasso

I am writing a custom variation of Lasso regression, using sklearn's Lasso implementation as a "source of inspiration". And I don't quite understand the very last line in the calculation of ...
Boris Burkov's user avatar
0 votes
0 answers
195 views

How to tune hyperparamters and use CalibratedClassifierCV correctly

Let's say that I have a classifier C ( for example a random forest classifier) and a Dataset. From what I understand I can: prefit the classifier on a portion of data and then "calibrate it"...
Tsadoq's user avatar
  • 33
0 votes
1 answer
97 views

How does sklearn.tree.DecisionTreeRegressor work?

I have successfully trained the model on a dataset, but I have some questions because the documentation here is very difficult to read: Does the splitter use a single scalar among the inputs, or ...
Yan Yang's user avatar
  • 123
1 vote
0 answers
43 views

How to find the optimal coefficients of the two predict_proba output matrices of two different classifiers using regression and maximizing accuracy? [closed]

I am performing classification, where there are six labels and two predict_proba (predicted probabilities) matrices as outputs. These two predict_proba matrices correspond to the outputs of two ...
cemrifki's user avatar
1 vote
1 answer
380 views

Lasso regression prediction on test set is predicting towards the mean of the train set?

I am using lasso regression to predict age (continuous data) from a set having 2112 numeric features (indepedent variable). The training dataset contains around 2773 participants. The mean of that ...
Echo's user avatar
  • 111
4 votes
1 answer
178 views

In elastic net regularisation, will dividing the OLS term the number of observations cause misleading results when cross-validating?

Two formulations of the elastic net regression function Consider sklearn's implementation of elastic net regularisation (Wikipedia link). From the docs, it works by ...
tobmo's user avatar
  • 71
1 vote
0 answers
149 views

Scikit-learn's Gaussian Processes Classifier: Specific kernels for specific features [closed]

Using GaussianProcessClassifier from sklearn, is it possible to specify different kernels for different features? For example, $X$ is an n X 2 matrix and I would to use the RBF for the first column ...
Glen's user avatar
  • 6,610
6 votes
1 answer
231 views

Number of samples in scikit-Learn cost function for Ridge/Lasso regression

I am using scikit-learn to train some regression models on data and noticed that the cost function for Lasso Regression is defined like this: , whereas the cost function for e.g. Ridge Regression is ...
Holgerillo's user avatar
1 vote
1 answer
1k views

Difference K-fold versus Blocked Cross-Validation?

In the paper "Evaluating time series forecasting models: an empirical study on performance estimation methods" by Cerqueira et al (2020), they mention k-fold cross-validation. Which they ...
strateeg32's user avatar
9 votes
3 answers
3k views

Stratification of the continuous y (target) variable in regression setting

Is it wise to stratify the continuous y (target) variable when you split your training and testing data from the total sample in regression setting? Here is the approach in python to do implement ...
ForestGump's user avatar
1 vote
0 answers
74 views

is nrmse scale-dependent?

Im trying to evaluate my regression models using a normalised version of the RMSE, nrmse = rmse(y, y_pred)/rmse(y, y_mean) where y_mean is the array of the same len as y filled with the mean value of ...
dogo's user avatar
  • 11
1 vote
1 answer
444 views

LinearRegression in Pytorch and sklearn, what is the differnece?

I am currently implementing Linear Regression in Pytorch and sklearn and I get two different Mean squared error (MSE) values for both. MSE is lower for Pytorch Linear Regression. Wanted to ask what ...
wowewow's user avatar
  • 41
3 votes
0 answers
99 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
0 votes
0 answers
26 views

Using target values in both (X and y) arguments of fit(X, y)

This question is based on SQL Server Machine Learning Services Ski Rental tutorial. We have a dataframe df: ...
PajLe's user avatar
  • 101
1 vote
1 answer
626 views

Linear Regression with Lasso Regularization by using scikitlearn and scipy.optimize

i am trying to apply lasso linear regression with both scikitlearn and scipy.optimize min method. However, i cannot reach same result. Code that i created with scipy.optimize can't shrink redundant ...
satnitla's user avatar
0 votes
1 answer
301 views

evaluating scoring metrics during hyperparameter tuning

I'm struggling with a couple of concepts related to hyperparameter tuning. I'm developing a model (gradient boosted tree) in python using sklearn. Currently, I'm in the process of using sklearn's ...
Tanner Ducharme's user avatar
0 votes
0 answers
191 views

class_weight='balanced' vs high f_beta score for imbalanced logistic regression in sklearn. Please help explain the difference

I have an imbalanced binary classification problem I am trying to solve with the LogisticRegression algorithm in sklearn. As the data is highly imbalanced I am looking at ways to treat the imbalance ...
kdbaseball8's user avatar
2 votes
1 answer
222 views

Derivatives of output w.r.t input on a neural network trained with standardized data

I'm using a neural network to model an unknown function for which I would also like to know the derivatives. The nn has four inputs and four outputs, and the training data is preprocessed using scikit-...
yac's user avatar
  • 25

1 2
3
4 5
36