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

How to choose the best ICA function

I am using the fastICA library from scikit-learn on a project and noticed that there was a fun parameter, referencing the ...
0
votes
0answers
8 views

Choose an appropriate N values for TimeSeriesSplit()

I try to apply code from this link to my local dataset which have dimension of 58 rows and 236 columns: ...
2
votes
0answers
33 views

Help interpreting image prediction

Could someone tell me why my predicted result ("Predicted Heatmap") has "ghost layers" and gray background? What can I do to improve my model? **What I've done to the images ** ...
0
votes
0answers
14 views

Negative KL divergence for train_test_split in sklearn for y_train and y_val

So, I am trying to understand if I have fair split of my train and val sets using train_test_split of sklearn, so I decided to run the KL divergence and JS div tests and I get the following results. ...
0
votes
0answers
19 views

(Stratified) 5-fold cross validation for 2D tensor and real-valued target regression using sklean train_test_split method

In classification problem, when we want to do stratified 5-fold cross validation, we pick the target and use train_test_split using something like below: ...
0
votes
0answers
17 views

Use custom test data with GridSearchCV

When searching for parameters with GridSearchCV, I encountered the problem of getting decent scores with my training data, but bad results with my test data. The design of experiments were conducted ...
0
votes
0answers
8 views

Display inverted ROC plot

my anomaly detection algorithm gave me an array of predictions where all the values greater than 0 should be of the positive class (= 0) and all the other should be classified as anomalies (= 1). I ...
0
votes
0answers
8 views

Predicting end-of-month sales based on year, month, day of month. day of week

The task is to determine total sales at the end of the month based on: date in month, on 25th it will be more accurate than on 5th day in week (1-7), since Mondays are by far the strongest, and ...
0
votes
1answer
62 views

Silhouette was not returning a valid number on scikit-learn on iris data. Is this wrong?

I was testing some clustering validity indexes with Iris Dataset and I got something odd with scikit learn. The silhouette index is giving a better index for 2 clusters instead of 3 clusters (the real ...
0
votes
0answers
13 views

Very low score in binary classification score

I was wondering how to interpret and tweak a model with 10% accuracy, in binary classification. With common feature engineering, I get something around 65% accuracy. When I do some transformation on ...
1
vote
0answers
24 views

Scikit-learn permutation importance is higher than 1 with R-squared scoring

I'm using Scikit-learn permutation_importance to compute the feature importance for a regression problem according to multiple models. I use $R^2$ as the scoring. ...
0
votes
0answers
16 views

Different results when i define my own score and when using model.score in linear regression (out of sample accuracy)

I am dealing with time feries data. I have a custom function created with sklearn.metrics.make_scorer to compute out-of-sample model accuracy: ...
0
votes
0answers
38 views

How to interpret result of kMeans scores if I have encoded the data with OneHotEncoder?

I am working on the AdventureWorks database and I have extracted some demographic data from the person scheme as follow. My aim ...
0
votes
0answers
10 views

Do we need to normalize all the variables before calculating mutual information for variables using sklearn?

In calculating the mutual information on sklearn using either mutual_info_classif or mutual_info_regression, the underlying algorithm seems to use KNN to derive the mutual information for the variable....
1
vote
2answers
28 views

Cannot manually reproduce CCA loadings

For my current project I am using sklearn.cross_decomposition.CCA. On several wepages (e.g. https://stats.idre.ucla.edu/r/dae/canonical-correlation-analysis/ or ...
0
votes
0answers
12 views

Combining multiple 1-sample t-tests (using decision trees)

I'm working on a concept to convert the RandomForestRegressor model from sklearn to a classification model with a measure of ...
0
votes
0answers
10 views

Why one of the features is dominating all rest of the features in my trained SVM?

I have been given a task to train the SVM model on conll2003 dataset for Named Entity "Identification" (That is I have to tag all tokens in "Statue of Liberty" as named entities ...
2
votes
1answer
25 views

Is it important to convert numeric features to object if they have no ordinal or mathematical meaning?

For example a column containing numeric values for phone area code or a postal code. In case it matters, I am preprocessing data for use in a tree-based ensemble classifier.
2
votes
2answers
81 views

What is the role of 'shuffle' in train_test_split()?

Wondering what shuffle does if I set it to True when splitting a dataset into train and test splits. Can I use shuffle on a dataset which is ordered by dates? ...
0
votes
0answers
23 views

Two models trained on the same data, with very similar performance statistics, give very different results on unseen data

I am trying to develop a natural language processing model. My goal is to be simple, and basically say if something is good or bad for a topic. I have a training set made up of around 15000 sentences. ...
1
vote
1answer
62 views

Obtain a between-class similarity. And is the way to do it through PCA valid?

Context: I have a dataset containing instances labeled into different classes, and for all the classes, I have the same set of features. My research question is to identify classes that are more ...
0
votes
0answers
17 views

PCA on transpose matrix: why are explained variances different?

I have noticed that for non-centered data, applying PCA on a data matrix X of shape (n, m) for n samples and m features gives different results than applying it to its transpose. For example the ...
0
votes
0answers
14 views

In Stacking Classifer, what will be the output of Level-1 classifier if each Level-0 classifier predicts different classes for an input?

I am trying to understand Stacking Classifier. My specific question is as follows. Let's assume in level-0 we have three classifiers namely NaiveBayes, KNN and RandomForest and in level-1 we have a ...
0
votes
0answers
25 views

Finding the maximum point in a linear regression model

I have a set of data points that I used to train a linear model (with polynomial interpolation as described here. In my understanding, the linear model can be described as a response function ...
0
votes
1answer
15 views

Why do the roc_auc scores for train_test_split and for cross-validation differ so much? [closed]

When I used scikit-learn pipeline and cross-validation, I got an average cv roc_auc score of about 0.78. But when I used train_test_split, I got a test roc_auc score of only 0.54. The difference is so ...
1
vote
0answers
28 views

Tuning parameters for multiple regression models [closed]

I am trying to compare multiple regression algorithms to estimate biomass (dependant variable) : KNeighborsRegressor, GaussianProcessRegressor, LinearRegression, BayesianRidge, Ridge, SGDRegressor, ...
0
votes
2answers
62 views

Does Chi-square test for independence (sklearn.feature_selection.SelectKBest) produce incorect results?

When looking for correlation between features (for feature selection), I found that sklearn implementation of Chi2 test of independence produce significantly different results from scipy.stats ...
0
votes
0answers
15 views

Pearson chi2 tests of independence: differences between Scipy and Scikit-learn

Scipy and Scikit-learn both implement Pearson's $\chi^2$ test of independence, but they give different results. The former matches what you might expect when computing this test "by hand", ...
0
votes
0answers
14 views

why is using a small vocabulary for topic modelling bad?

i am trying to classify texts into topics. for example, let's say one of the topics is cooperation. so in the vocab param of the sklearn api. so some of the prevalent words (or "tokens" are ...
1
vote
2answers
69 views

Why are my elastic net and lasso r-squared measures negative?

I'm using sklearn.linear_model.Lasso and sklearn.linear_model.ElasticNet on a model that includes a constant. I don't expect a model with a constant to perform worse than the average of the data, ie ...
1
vote
1answer
84 views

How to compute a 'pair confusion matrix'?

I don't really understand how the pair confusion matrix (used for example in comparing of clusterings) is calculated... ...
1
vote
1answer
30 views

Tuning the regression hyperparameters

I am trying to find the hyperparameters of a gaussian process regression algorithm using sklearn. The book (Rasmussen), says I should to maximize the log marginal likelihood given by $$\log(\mathbf{y}|...
0
votes
0answers
30 views

How to implement kfold and cv into Hybrid feature selection and evaluate the classification model performance?

I have been working on a Hybrid feature selection combined with hyperopt package for hyperparameter tuning and I am thinking about evaluating the performance of several model classifiers. I looked ...
0
votes
0answers
12 views

PCA whitening and centering in inference/test samples

[cross-posted from SO] I'm working on speaker identification. I need to take the speaker embeddings from a neural network and apply a few transformations to finally generate the score for verification....
0
votes
0answers
16 views

Is this problem a multi-label or multi-class multi-output classification?

I have a dataset whose input data include some numbers like x1, x2, ..., xn. I have n target columns each of which represents a binary vector including m elements. For example, a simple instance of a ...
0
votes
0answers
26 views

How can the scores of CV done with training data better then the score of all training data

I have the following issue, when I use the adam solver (MLPRegressor from sklaern) my cross validation (10 repeats a 5 splits) metrics (r2, maxError, RMSE, MAE) are all better (r2 ~ 0.94) as the ...
0
votes
0answers
11 views

Precision-Recall curves with multiclass classifier

I would like to plot the PR curves for a multiclass classifier (e.g. 3 classes). In the documentation it states that multiclass is not supported, and instead a series of one vs all classifiers are ...
0
votes
0answers
10 views

Stacking/Blending for Convolutional Neural Networks using original training data

I have a dataset consisting of multiple classes of images. I trained several CNN's to predict the probability for those classes. Afterwards, I combined the predictions of the CNN's using a weighted ...
0
votes
0answers
16 views

What is the use of the learning_rate parameter in sklearn AdaBoostClassifier/Regressor?

There is a similar question here. But I have doubts regarding the answer. Hence am asking a new question clarifying my doubt. The general pattern for boosting is that the predictions of the weak ...
1
vote
0answers
18 views

How does cost_complexity_pruning_path in sklearn calculate effective alphas when pruning a decision tree?

I know when pruing DecisionTreeRegressor, we can leverage cost_complexity_pruning_path method to get a list of effective alphas. ...
0
votes
1answer
33 views

Positive train score and negative test score in sklearn [duplicate]

I am doing a regression model using kfold cross validation using a dataset with ~200 data and noticed my r2 score on train data is positive(average 0.7) and my r2 test score is negative. What does it ...
0
votes
1answer
34 views

AUC measure for Local outlier detection in python?

I'm using Local outlier factor algorithm provided by Scikit-learn for outlier detection. For the evaluation i want to use auc measure. ...
1
vote
0answers
17 views

Why Does using a OneVsRest Model for multiclass problem result in overall low accuracy but high accuracy for each individual class?

I have a multiclass problem i.e. 4 labels 0,1,2,3. I used a OneVsRest model wrapped around an xgboost model. What happens therefore is that i train a model 4x for each class. e.g.: ...
0
votes
1answer
17 views

Random Forest Parameter Settings for Big Data

I have a big data set (with more than 9,000,000 rows) with 7 features and 1 label. The label is ordinal data. I would like to run a random forest regression. I'm fairly new to random forests so I have ...
0
votes
0answers
41 views

How to use SVR in sklearn python

im new in python, I want to do SVR time series prediction with sklearn. Below is my data exmple with "P" is the time plot, "T" is the data target that i want to predict with X1-X4 ...
0
votes
1answer
26 views

Prediction of Adaboost Classifier between 0 and 1

I have to use an Adaboost classifier to predict if the data is a signal (1) or a background (0) event. But since the output is expected to be 1 or 0 the ...
0
votes
1answer
35 views

Transform target/label variable into classes but classes are data-dependent: How to approach this correctly?

I was redirected from StackOverflow because my question is more about theory. I have a usual set-up with a pandas dataframe with some features and a numeric target variable (financial returns for ...
0
votes
0answers
26 views

LDA Feature Importantance Extraction - sklearn Python

I have run LDA from sklearn on a dataset and I have gotten pretty good separation between classes. Typically I can extract feature importance to determine which contributing factor is most important. ...
0
votes
1answer
41 views

How best to deal with missing event data

I have a data set which contains values like "last_foo" containing the number of days since the last time foo occurred. Naturally this feature contains NaNs for examples that have never foo'...
0
votes
1answer
94 views

max_depth vs. max_leaf_nodes in scikit-learn's RandomForestClassifier

What's the difference, if any at all, between max_depth and max_leaf_nodes in sklearn's RandomForestClassifier for a simple ...

1
2 3 4 5
33