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.
1,814
questions
0
votes
0
answers
30
views
As an intermediate R programmer looking to dive into machine learning, should I choose Python or stick with R? [closed]
I am an intermediate R programmer with some experience in machine learning concepts and simple modeling in R. I have an opportunity to collaborate with a professional machine learning team that is ...
1
vote
1
answer
26
views
Sample weights in Xgboost regression
I am trying to fit a regression model using xgboost's XGBRegressor where I overweight more recent data vs the past during training. I am wondering how the sample_weight works for xgboost.
I know that ...
0
votes
0
answers
7
views
Sklearn PLS attributes X_scores, X_weights, X_Loadings meaning
tried reading the sci-kit documentation but the docs are short and not very helpful. Anyone can give a layman's term of the X and Y scores, weights, and loadings for a partial least squares regression ...
0
votes
0
answers
9
views
PCA with Time Series and Leakage
I have the following code for a simple statistical factor model with PCA and moving window for time series data:
...
3
votes
1
answer
50
views
Solving logistic regression using CVXPY
I am trying to code a logistic regression model using the CVXPY library. The code I have written so far "works" in the sense that it can be executed, it does not yield any error message and ...
0
votes
1
answer
32
views
How does SKLearn derive LASSO coefficients?
I am trying to derive SKLearn's LASSO coefficients using SciPy optimize, just to get an idea of how SKLearn is working under the hood. However, I cannot get the parameters to match.
...
0
votes
0
answers
16
views
Can non-negative matrix factorization be used for binary/boolean data?
I'm circling back to non-negative matrix factorization, in particular the sklearn implementation: https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.NMF.html
The dataset that I'm ...
2
votes
1
answer
47
views
I have a dataset with 18 biomarker features and a target variable. I want to find the features which are having the biggest impact on the target
I Have some disease biomarker datasets that contain 18 biomarker readings from different samples and a target variable which shows presence or absence of disease (features are both categorical and ...
0
votes
0
answers
23
views
How Random Forest handle missing value in sk-learn? [duplicate]
What is the technic used in Random Forest Regressor from scikit-learn to handle missing value ?
First I thought that a Random Forest regressor was able to natively handle missing value during training ...
0
votes
0
answers
12
views
Why the different default parameters for scikit-learn gradient boosting classifiers? (GradientBoostingClassifier and HistGradientBoostingClassifier)
Why do gradient boosting classifiers (GradientBoostingClassifier) and histogram-based gradient boosting classifiers (HistGradientBoostingClassifier) have significantly different default hyperparameter ...
0
votes
0
answers
27
views
scikit-learn CCA: x_loadings_x attribute
I'm doing a canonical correlation analysis using scikit-learn's CCA. After doing the usual steps and calling ca.x_loadings_, I see that I get values bigger than 1. ...
2
votes
1
answer
50
views
Meaning/interpretation of intercept_ in partial least squares
After using sklearn library for Partial Least Squares, I have doubts about the interpretation of the "intercept" of the model.
As you can see in the code that follows, and its corresponding ...
0
votes
0
answers
34
views
How to handle Data Normalization in case that a Logarithmic scale is required?
Let's say we wished to build a Regressor (e.g. a Support Vector Regressor) to predict the price of an asset, within a given time span from now on.
However, what if the historical data we have ...
1
vote
0
answers
26
views
What are the best options for imputing time series that is missing lots of days [closed]
I have many months of temperature data recorded roughly every ten minutes. Except it has gaps. If the gap is an hour or so, I can linearly interpolate, but if the gap is a few days this obviously ...
0
votes
1
answer
22
views
How does KNNImputer stores fitted values of the train set?
If someone here is familiar with the KNNImputer implementation of Scikit-learn, I would be eager to learn this from him.
When you fit an Imputer transformer on your ...
0
votes
0
answers
20
views
GridSearchCV performs worse than baseline
I'm working on a binary classification problem using scikit-learn. One of the models I've tested is KNeighborsClassifier, for ...
4
votes
2
answers
95
views
Finding the corners of noisy polygons
I have some polygons that look for example like this:
If I zoom in very close on one side, you can see the noise.
The data is a list of x coordinates and a corresponding list of y coordinates.
I ...
2
votes
1
answer
77
views
Is my understanding/approach to nested cross-validation, final model tuning correct?
I am training a SVM on limited training data with unbalanced classes.
Here are the things that I want to do:
1.) I want to make a statement of the generalizability ...
1
vote
1
answer
41
views
Reason for high MSE and negative R square value
I am getting really high MSE and negative R square value.
Dataset: https://docs.google.com/spreadsheets/d/1moTZS_LgOn6d74NC44i9lVcWchj-abVx/edit?usp=sharing&ouid=100514649347129021200&rtpof=...
2
votes
1
answer
37
views
How to interpret the results of a classifier when train/test method gives much better results than cross validated one?
I need your help to understand a situation where using train and test set produces perfect results (in terms of accuracy, precision, and recall) but when cross validation is used, the accuracy on ...
1
vote
0
answers
117
views
An error occurred when using the xgboost as a classifier for hiclass [closed]
Bellow it's my example when using the xgboost classifier for hiclass. My question is specifically directed to the hiClass Python package for hierarchical classification. I would like to model the ...
6
votes
1
answer
80
views
What is happening behind the scenes when we use CalibratedClassifierCV without prefit?
From what I understood by reading sklearn Probability Calibration, when we run CalibratedClassifierCV we will fit "a regressor (called a calibrator) that maps the output of the classifier (as ...
0
votes
0
answers
21
views
Weighted KNN imputation
Consider the following piece of python code.
...
1
vote
1
answer
26
views
How does average_precision_score metric in scikit-learn work for non-probability prediction scores
Scikit-learn has an AP metric function Here
The description of y_score (predictions) says :- ...
1
vote
1
answer
51
views
Hierarchical clustering of a distance matrix with element weights
I am computing a hierarchical clustering of some geospatial data. I need to add in an element weighting to the approach.
My current approach is:
I compute temporal cross-correlations between my N ...
0
votes
0
answers
12
views
Can exponentiated coefficients in multinominal logistic regression (with softmax normalization) be interpreted as odds ratios?
Exponentiated logistic regression coefficients are interpreted as odds ratios. Does this still hold in multinominal logistic regression, where softmax is typically used to normalize probabilities to ...
0
votes
0
answers
21
views
"How can I address the lack of correlation and a low R-squared value in my univariate linear regression when the data is scattered?"
**
"I'm trying to find a correlation between the confirmed cases and deaths rates against HUMIDEX values. As you can see, the data is very scattered, so I understand that polynomial and ...
0
votes
0
answers
49
views
Permutation Feature Importance in the Context of Cross Validation
I am considering two apporaches to calculate the mean, std and standard error (se) for ...
1
vote
1
answer
28
views
Standard function to quantify consistency of a sequence of predictions
Let's say I let a deep learning model classify a single object multiple times but under varying circumstances. Ideally it should predict the same class again and again. But in reality its class ...
0
votes
0
answers
20
views
How should uncertainties be treated when scaling data for optimisation
I have a large dataset for which I am using Bayesian statistics for parameter estimation and model selection (using MultiNest for more detail).
This involves setting a prior over which the nested ...
0
votes
0
answers
40
views
Changing OOB scoring metric for RandomForestRegressor from r2 to MSE
In sklearn's documentation https://scikit-learn.org/1.4/modules/generated/sklearn.ensemble.RandomForestRegressor.html it states that the default scoring for OOB samples are r2. It also states that you ...
2
votes
0
answers
38
views
K-nearest neighbors to estimate mutual information
I would like to use the mutual_info_regression object from scikit-learn to get a rough idea of how well any individual feature ...
0
votes
0
answers
45
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$ ...
3
votes
2
answers
80
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 &...
0
votes
1
answer
82
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 ...
1
vote
0
answers
101
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 ...
4
votes
1
answer
124
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...
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 ...
0
votes
0
answers
49
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 ...
2
votes
2
answers
70
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 ...
0
votes
0
answers
15
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)...
1
vote
1
answer
68
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?
0
votes
0
answers
29
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))
...
1
vote
1
answer
199
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 ...
3
votes
1
answer
48
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.
...
0
votes
1
answer
45
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 ...
1
vote
1
answer
40
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 ...
1
vote
1
answer
1k
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
...
2
votes
1
answer
97
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 ...
11
votes
7
answers
3k
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 ...