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
39 views

Explicit form of L2 regularization in sklearn.linear_model.LogisticRegressionCV [duplicate]

I am using LogisticRegressionCV of sklearn, and I would like to know the explicit form of the L2 regularization in Logistic Regression. In the official page of LogisticRegressionCV, it is written $Cs$ ...
HQMA's user avatar
  • 147
0 votes
0 answers
13 views

Nonetype object in string manipulation with python / sciklit-learn [closed]

When running the following code snippet: ...
Antonio Piemontese's user avatar
0 votes
2 answers
55 views

Am I finding redundant columns in my data using Factor Analysis

I have a pandas data frame with 50 columns and 10 rows. The columns represent events and the rows are days. If an event occurs in a day, then the corresponding cell is a "1", else, is a &...
slow_learner's user avatar
0 votes
1 answer
24 views

How to handle correlated variables before using Recursive Feature Elimination?

I have seen a few Kaggle notebooks that list without reason that RFE works better when removing correlated variables. I struggle to see the reason why so I conducted some of my own research and would ...
AvanishM's user avatar
1 vote
0 answers
74 views

Why does feature importance decrease for highly correlated variables?

I am investigating the relationship between correlation between features and its impact on their feature importances using sklearn's DecisionTreeClassifier algorithm. I manipulated the correlation of ...
AvanishM's user avatar
3 votes
1 answer
59 views

Can a ML classifier's prediction be understood as a probability?

When predicting classes with a machine learning classifier, such as scikit-learn's DecisionTreeClassifier or KNeighborsClassifier...
YPOC's user avatar
  • 165
0 votes
0 answers
19 views

How to compute the correlations of extra features with respect to the principal components

I have a dataset with 4 features and n observations. I have done a Principal Components Analysis using only 3 features. Now I need to find the correlation between the extra feature and the principal ...
Charly's user avatar
  • 1
0 votes
0 answers
31 views

What are the best ways to perform feature selection for a binary classification problem with extremely imbalanced dataset

I have a classification problem where the size of the dataset is about 1 million lines but the target group is only about 0.6% of the dataset. I have about 40 feature including both categorical and ...
peiman razavi's user avatar
2 votes
2 answers
66 views

Regression model with multiple rows per user to predict death

I'm trying to build a regression model for predicting mortality in users according to their lab reports, the thing is in my dataset each row is a different laboratory even for the same user, for ...
Khantus's user avatar
  • 23
0 votes
0 answers
11 views

Using PLS to determine relative contributions of different drivers to the variability of a source?

I have a several drivers that are influencing the variability of a source. The drivers are not independent of one another, so I cannot use linear regression. Instead, I used Partial Least Squares (PLS)...
Billiam's user avatar
1 vote
1 answer
59 views

Sklearn's LogisticRegression C hyperparameter issue

In sklearn user's guide for LogisticRegression it is said that: where C is so, shouldn't C hyperparameter be in front of the regularization term r(w) rather than in front of the sum?
Ivan Mitriakhin's user avatar
0 votes
0 answers
13 views

accuracy value under f1-score in classification report

Consider this y_true = [0, 1, 2, 2, 2] y_pred = [0, 0, 2, 2, 1] from sklearn.metrics import classification_report print(classification_report(y_true, y_pred)) ...
Zoso's user avatar
  • 123
1 vote
1 answer
32 views

sklearn.metrics.r2_score vs sklearn.LinearRegression.score [closed]

I'm using sklearn to calculate the coefficient of determination between X (true age) and Y (predicted age). But I'm getting two different values for two different methods, which to the best of my ...
reas0n's user avatar
  • 123
3 votes
1 answer
25 views

How to find correlations of the features in a dataframe? The features are of mixed types (nominal, ordinal, discrete, and continuous)

I am working with python using pandas, and seaborn libraries. I have a dataframe, that I am using for some machine learning. My dataframe has a target variable, along with several other features. ...
letdatado's user avatar
  • 325
0 votes
1 answer
38 views

How to get best ml model in data with not-normal right skewed distribution?

I am working with small amount of data: https://github.com/jeffheaton/data/blob/master/bupa.csv I want to predict y data which is drinks, who have not-normal right skewed distribution. There is a ...
Jaminka's user avatar
  • 11
1 vote
1 answer
33 views

Extracted variance is above 1 (CCA and redundancy analysis)

I tried to repeat the analysis from Stewart and Love 1968, to compute the Variance Extracted and redundancy index from CCA. Based on their paper (if I followed it correctly), Variance Extracted per ...
Polina Turishcheva's user avatar
1 vote
1 answer
124 views

How to interpret pairplots()

I have been working on a Classification problem. And I want to see how many features associate with the target variables. Let me share an example. I got this pairplot using ...
letdatado's user avatar
  • 325
1 vote
1 answer
89 views

Is Linear Regression a good algorithm or even applicable with the distribution shown in the scatter plot I have shared in this question?

I am trying to use Linear Regression on a dataset using scikit-learn with python. And my understanding is that Linear Regression requires "some linearity" to exist between independent and ...
letdatado's user avatar
  • 325
11 votes
7 answers
2k views

Why do we use Linear Models when tree based models often work better than linear models?

In Supervised Machine Learning, and specifically on Kaggle, it is usually seen that tree models often outperform linear models. And even in the tree-based models, it is usually XGBoost that ...
letdatado's user avatar
  • 325
0 votes
0 answers
42 views

Classification Threshold varies wildly when using ROC curves for threshold moving

I'm trying to do threshold moving to get the appropriate threshold for an imbalanced dataset. I have a 1D timeseries that I am applying a binary transformer-based classifier on. I have: ...
Techie5879's user avatar
1 vote
0 answers
9 views

Issues with gradient of standard deviation in GPR using skopt.learning.gaussian_process

I'm currently working on a Gaussian Process Regression (GPR) model using the implementation provided in skopt.learning.GaussianProcessRegressor which is a wrapper for the sklearn implementation. This ...
Dave's user avatar
  • 11
1 vote
0 answers
69 views

What is the scalings_ attribute in Linear Discriminant Analysis?

Learning to do Linear Discriminant Analysis with sklearn, and a bit confused about the scalings_ attribute of the fitted model. The LDA classifier can be written as ...
jacob's user avatar
  • 449
0 votes
0 answers
14 views

Random forest for feature selection over large inhomogeneous data set [duplicate]

I have a very large dataset (500,000 examples, 3000 features with a lot of missing values). I want to run a random forest algorithm for feature selection with sklearn. Unfortunately, I cannot load the ...
Constantinus Spanakis's user avatar
5 votes
1 answer
270 views

Is ROC curve unique?

ROC curve and the area under it (AUC) are routinely used to evaluate the performance of binary classifiers. However, it seems that both, the shape of the curve and the area, depend on the parameter ...
Roger V.'s user avatar
  • 3,893
0 votes
0 answers
26 views

best practices on optimizing feature transforms for a model

I have a regression model that Transforms some time series features using a different halflife for each feature Uses the transformed features along with some other features to create a prediction ...
Arran Duff's user avatar
3 votes
1 answer
64 views

Is my regularized logistic regression model overfit?

I have a dataset with the following characteristics: moderate sample size (~300 samples) moderate class imbalance (~20% positives) high-dimensional (the number of independent variables, again ~300, ...
ladislaw94's user avatar
0 votes
0 answers
25 views

Sklearn feature selection performs strangely with 2 groups (and with SVC)

Previously I've successfully performed support vector classification with recursive feature elimination in R using the e1071 package, but I'm now hoping to move over to SciKit Learn given that Python ...
Benjamin Taylor's user avatar
0 votes
0 answers
49 views

How does `sklearn.metrics.roc_curve` work without using model predictions? [duplicate]

I am trying to understand sklearn's function for computing the roc_curve. If I understand correctly, one needs the TPR and FPR to compute ROC. However, sklearn's function takes as input - ...
desert_ranger's user avatar
1 vote
0 answers
21 views

A method to categorize variations in time series of images

I am working with a time series of remote sensing images from a particular area. Temporal standard deviation (SD) of these images showed high fluctuations at some regions with SD of 1.17 while some ...
sat_P's user avatar
  • 11
0 votes
0 answers
22 views

Classification problem: Choosing medication to prevent side effects based on patient characteristics

I need your help to solve a classification problem. Typically, we have independent variables and we try to predict a target variable. I have a different type of problem to solve. In my case, let's ...
Mohamed kenani's user avatar
0 votes
0 answers
37 views

Why are my training and validation curves suspiciously close to one another (sklearn neural network)

I am trying to graph the accuracy, error and precision scores over epoch for a neural network and am using cross validation. However, my training and validation scores are practically on top of one ...
iron_carbon's user avatar
1 vote
1 answer
77 views

meaning of drop in OneHotEncoder

I am having a tough time as a newbie understanding the drop argument in OneHotEncoder. Does it drop the column with the non-...
heretoinfinity's user avatar
2 votes
1 answer
48 views

Adding a New Feature

My question is pretty straightforward and the task behind is related to binary classification. To add a new feature, do i first do train_test_split then add a new ...
Newbie's user avatar
  • 21
0 votes
0 answers
53 views

What is the splitting criterion in Regression trees (DecisionTreeRegressor sklearn) in the multi output case

I am using DecisionTreeRegressor and RandomForestRegressor from sklearn in a case where i have multiple output, but i did not find a reference article for the regression case (which is used by sklearn)...
Rayane Elimam's user avatar
0 votes
0 answers
37 views

How to test for significance of differences between metrics for two models? (Machine learning model selection)

Problem - I want to test whether the difference in a metric (say AUC) between two models is significant. I have one vector of binary class predictions from a custom function and one from sklearn....
mckerm1t's user avatar
0 votes
1 answer
115 views

How reliable is ```train_test_split```? Is there a way to optimize it?

Using train_test_split is a common practice while building a Machine Learning model. Nevertheless, partitioning your dataset to get train and test samples is an ...
Juan Flautista De Torrepacheco's user avatar
4 votes
2 answers
130 views

Scikitlearn: Why are hyperplane coefficients not available if kernel is not linear

I am interested in learning the math behind support vector machines. So far, I understand that SVMs attempt to find hyperplanes that maximize the margin distance between support vectors associated ...
Elsayeda's user avatar
3 votes
1 answer
182 views

What is the best way to meaningfully compare the feature importances between parametric (Logit) and non-parametric models (RFs/XGB)?

I have applied 3 different models (Logit, RF and XGB) to my dataset with the aim of investigating their individual predictive performance. I have found the feature importance of the logistic ...
Henrique Castro Sampaio's user avatar
1 vote
1 answer
55 views

Representing Nested Models as an SKLearn Pipeline [closed]

Goal: Represent nested models with SKLearn's Pipeline / ColumnTransformer / FeatureUnion setup. Specific issue: I cannot figure out how to use the prediction from one model as a factor of a secondary ...
chris's user avatar
  • 31
2 votes
1 answer
71 views

Why does the mean AURPC go down the more examples one uses?

In the discussion of this question, the following new one arose: Why is the mean AURPRC higher the fewer examples are used? Here is a minimal (Python) code example showing the effect: ...
Tobias Hermann's user avatar
2 votes
0 answers
46 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
0 votes
0 answers
71 views

Differences in R2 score when using MLPRegressor alone vs. with MultiOutputRegressor in Scikit-learn

I am attempting to create a surrogate model for a chemical process simulation that includes flash separators and a heat exchanger (please refer to the photo). Based on my research into similar ...
Nur's user avatar
  • 11
1 vote
1 answer
110 views

Scikit-learn : MultiOutputRegressor

I am currently working on a machine learning model using scikit-learn. In my case, I have 12 input features and 21 output targets, and I am using MLPRegressor to fit my data. However, I noticed a ...
Nur's user avatar
  • 11
1 vote
1 answer
67 views

Multi-label stratified split

I am working on a multilabel text classification problem. The text data is called 'cleaned_text' and has shape (92259, 1) and the one-hot encoded label data is called 'labels' and has shape (92259, 32)...
Steven Gubkin's user avatar
2 votes
1 answer
36 views

Is it appropriate to compare SVM coefficients with random forest feature importances?

I am using scikit-learn to build two binary classification models--one is a random forest, and the other is a linear SVM. I want to compare the relative importances of the input features to the ...
Dominic Martinelli's user avatar
2 votes
0 answers
147 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
4 votes
1 answer
230 views

sklearn PoissonRegressor giving all coefficients zero

I'm doing a random exercise of comparing statsmodels and sklearn regression tools, specifically Poisson Regression (unregularised GLM). I am trying different libraries on the Insurance dataset from ...
A. Patel's user avatar
1 vote
1 answer
238 views

Why use average_precision_score from sklearn? [duplicate]

I have precision and recall values and want to measure an estimator performance: ...
Ars ML's user avatar
  • 31
0 votes
0 answers
93 views

How to deal with the high dimensionality when using EM algorithm to solve Gaussian mixture models?

When I use the EM algorithm to solve a Gaussian mixture model, we may encounter the computation of Gaussian densities in the E step. Specifically, we should have the posterior probability as $$ \pi_{...
Lei's user avatar
  • 11
0 votes
0 answers
13 views

Will adding variables which have little to no significance, affect the effect of more significant variables on the machine learning prediction?

For example: Suppose I am trying to predict the "HEIGHT" of a giraffe. If I have one highly correlated X variable, "AGE", and another X variable, "NUMBEROFSPOTS", which ...
joshAU's user avatar
  • 11

1
2 3 4 5
36