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
2
votes
1answer
46 views

K Fold Cross Validation in Python

I am trying to compare 2 classifying methods (SVC vs Random Forest) in order to do that I am using the cross_val_score function. It is posible to use the same folds in both methods? In order to ...
0
votes
1answer
52 views

Scoring rules (log-loss vs. F1-weighted) and RandomizedSearchCV

I read multiple posts about scoring rules during cross-validation and the fact that the log-loss score is a proper scoring rule and, correct me if I am wrong, any threshold based approach is a ...
1
vote
0answers
16 views

Hausdorff Distance with Manhattan Distance

I'm applying Hausdorff Distance to understand if two datasets are representing the same subset of the space of a particular problem. The point is that I've read the Hausdorff distance computes the ...
1
vote
1answer
68 views

CalibratedClassifier and RandomSearchCV

I was wondering what the right steps would be to perform both hyperparameter optimisation and obtain a calibrated model. I thought the following could be the right way (70% train split, 10% validation ...
2
votes
1answer
47 views

Get OOB samples of random forest in sklearn [closed]

In sklearn I oob_score_ gives me the OOB score of a random forest model. This score is calculated by the samples which were left out during RF training. Is there a way to get the individual OOB ...
0
votes
0answers
31 views

MLPRegressor with 'lbfgs' algorithm incredibly bad performance [duplicate]

I can't manage to train the MLPRegressor with 'lbfgs' algorithm to better R2 score than around -14. How comes? First I tried randomly guess the hidden layers shape, then I even tried to use Grid ...
1
vote
1answer
13 views

How to see the learning of a classifier over time? [closed]

I am a beginner, I try to find out if it is possible to know "where the classifier stands" in its learning. Indeed I have a lot of data and after doing ...
0
votes
1answer
34 views

Does radial basis function kernel has a coefficient?

I found there are two forms of RBF function. these is a coefficient before $\exp$ $$ k_{f}\left(x_{i}, x_{j}\right)=\sigma^{2} \exp \left(-\frac{1}{2 \ell^{2}} \...
0
votes
0answers
11 views

Label Space Partition Classifier

I am trying to understand this paragraph in Szymanski & Kajdanowicz 2018 regarding the label space partition classifier in scikit-multilearn: Scikit-multilearn provides a partitioning and a ...
1
vote
1answer
28 views

Does Random Forest Regression or Lasso Regression benefit (in terms of accuracy) from predicting multiple outputs at once?

I'm using Random Forest regression and Lasso regression for the task of predicting multiple outputs. I'm using sklearn.ensemble.RandomForestRegressor and ...
0
votes
0answers
69 views

Implementing Cross-Validation for Gaussian Process Regression

Although Gaussian Process Module in sklearn package offers an "automatic" optimization based on the posterior likelihood function, I'd like to use cross-validation to pick the best ...
1
vote
0answers
29 views

What metrics can be used to evaluate each cluster in clustering

I am clustering a dataset, where the binary ground truth (positive/negative samples) is known. I am looking for specific clusters that show high homogeneity/purity. I know that there are many metrics ...
0
votes
1answer
21 views

Ridge Regression - Advice on Modeling Sales Data

I am looking to use ridge regression to predict end of quarter sales revenue. My features are sales pipeline and revenue booked quarter to date. As the quarter progresses sales pipeline will ...
0
votes
1answer
48 views

Why is One Class SVM predicting that half my dataset consists of outliers?

I am currently working on a dataset with 14 continuous features, a categorical target over five classes, and 90,000 samples. My current goal is to explore outliers in the dataset, and to that end I ...
1
vote
2answers
286 views

Why Feature Selection with sklearn.feature_selection.SequentialFeatureSelector is a preprocessing task?

I am facing a feature selection problem. Because I am building an Explanatory Regression Model I decided to follow a Forward Sequential Feature Selection. Moreover I wanted to implement ...
0
votes
0answers
10 views

Comparing Multiple ML Models: Do CV for each model independently, or use same splits for each model?

I was trying to figure out the most efficient way to compare multiple models using sklearn. Let's say I have three models to compare: Naive Bayes Logistic Regression SVM I want to train and obtain ...
2
votes
1answer
62 views

PCA in Sklearn: Uncorrelated Outputs

Admittedly I am now questioning my understanding of the output from PCA in sklearn. At a high level, many tutorials discuss the benefits of PCA as having uncorrelated components for use in downstream ...
3
votes
1answer
69 views

accuracy decreases with number of folds in x-validation

I am running a Sequential model in Tensorflow for binary classification. I cross-validate it using sklearn's KFold with 50 folds. The strange thing is that the binary accuracy has a trend of ...
6
votes
1answer
372 views

When a classifier predicting probability should be calibrated?

At scikit-learn website they have a very nice picture showing the need to calibrate [some] classifiers to correct bias in predicted probabilities: And they have a very nice explanation of why one ...
0
votes
1answer
30 views

What is the purpose of the first (1s) element in sklearn.preprocessing.PolynomialFeatures?

I got confused when I used 10 degrees and got 11 outputs. I checked the https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.PolynomialFeatures.html and there seems to be (1) column ...
0
votes
0answers
75 views

Dummy Classifier - No Skill Line on a Binary Classification Precision Recall Curve Using a Stratified Approach - How Calculated?

I am doing binary classification on a highly imbalanced data set where the positive value is about 1.6% of the dataset. I am training and running models but I want to compare against a dummy ...
0
votes
0answers
19 views

NLP: vectorizer/metric to upweight absence of frequent terms

I'm doing hierarchical clustering of documents in a corpus; there are words that occur in almost all the documents. To define document similarity, I've used ...
0
votes
0answers
35 views

Low precision after smote

I am working on a classification problem with class imbalance. I implemented every kind of balance technique and I always get high accuracy, recall and roc (0.85) and low precision( around 0.50). Also ...
0
votes
0answers
17 views

DNA sequence classification of reads treated with justConcatenate in DADA2

I have a general questions regarding DNA sequence classification using scikit-learn. I have non-overlapping reads and joined them using the justConcatenate-command ...
1
vote
0answers
15 views

increase precision without hurting recall

I have a classification problem with class imbalance and after the oversampling, I get high recall ,accuracy and roc (around 0.85) while my precision and f1 is fairly low(0.50). I have used every kind ...
2
votes
2answers
91 views

Why does chi2-test show me a dependence between randomly generated columns?

I generate two columns of length 343180 with random integer values between 0 and 290 and run sklearn's chi2-test of dependence. One would expect that the null hypothesis (independence) is accepted ...
0
votes
0answers
24 views

Machine Learning algorithms and Panel data

I have a large panel dataset composed of $N$ stocks, $T$ quarterly dates and $K$ features for each stock. The dataset looks like the following: ...
3
votes
1answer
46 views

Significant Difference in prediction when using library and coding from scratch in Multiple Linear Regression [duplicate]

I have been trying to implement multiple linear regression from scratch after implementing it using sklearn. The values predicted using sklearn is very accurate whereas the values predicted by the ...
0
votes
0answers
6 views

raw_id vs inner_id in Surprise Lib?

What is the difference between raw_id vs inner_id in Surprise Lib. The documentation is not clear enough (at least for me). Why ...
0
votes
0answers
22 views

How can i calculate density of every centroid in python

i have kmeans clustered data, and cluster centroids of the kmeans. I want to calculate density of each cluster centroid and remove the cluster of the highest cluster centroid density. I did my ...
1
vote
0answers
75 views

How does the python port of libsvm's predict_proba work?

I've followed through the original libsvm code on it's [github][1]. I'm not concerned about the theoretical backfground of how the probability estimates are derived. All that I care about is how to ...
0
votes
1answer
23 views

Different tools for calculating PCA [duplicate]

I have a test csv file and I have written a code via Scikit to show the PCA for that. I also use another tool in Excel (XLSTAT) to compare the results. The XLSTAT automatically calculates the number ...
0
votes
0answers
35 views

What is anti test set?

What is the exact meaning of the term Anti Test set? Why and where is it used? I recently came across the link build_anti_testset(fill=None) and it is a bit ...
1
vote
1answer
84 views

Why should we use cross_val_predict instead of just normally predicting our instances using all the training set?

Aren't we using less data to train our model when we are using cross_val_predict? Say I have the following code; sgd_clf = SGDClassifier(random_state=42) sgd_clf.fit(X_train, y_train) ...
1
vote
0answers
37 views

Should I use classification or regression model to predict discrete/ordinal movie ratings?

I’m making a ML model that predicts movie ratings from 1-10 (discrete). With scikit, is it better to use a classification model with 10 classes or a regression model that predicts a continuous ...
0
votes
0answers
31 views

What is the best way to deal with missing values in numeric columns for a decision tree?

I have a dataset that has consists of both categorical and numeric columns. It contains a target variable that is a binary 1 or 0. I want to use a decision tree to come up with branches that would ...
1
vote
1answer
37 views

What would cause spurious relationship when using logistic regression?

I generated random values from a normal distribution(using numpy.random.normal) and threw them into a logistic regression model as X variables(~300 of them). Y is binary( around 51% is 1 ) and is from ...
2
votes
0answers
26 views

What is the difference between pairwise kernels and pairwise distances?

What is the difference between pairwise kernels and pairwise distances? I frequently came across terms like pairwise kernels and pairwise distances while learning about Pairwise metrics, Affinities, ...
0
votes
0answers
148 views

How does sklearn.model_selection.cross_val_predict work?

What exactly does sklearn.model_selection.cross_val_predict do and how does it work? Documentation says: "Generate cross-validated estimates for each input ...
0
votes
1answer
118 views

f_regression in sklearn - how is a correlation converted into an F score?

From the following link: https://scikit-learn.org/stable/modules/generated/sklearn.feature_selection.f_regression.html#sklearn.feature_selection.f_regression There's: This is done in 2 steps: The ...
0
votes
1answer
57 views

Score function for GridSearchCV with GaussianMixture [closed]

I want to train a GaussianMixture model. I want to select the number of components based on a cross-validation score. I want the score function to be the log ...
0
votes
1answer
118 views

Calculating TF-IDF on a test set, having already built on training set

I have a need to engineer features from TF-IDF values for a downstream classification task. I (think) I have a reasonable grasp of TF-IDF as described in Sci-kit Learn documentation, but am unable to ...
0
votes
0answers
112 views

Using KL divergence to select topic from LDA

I have used sklearn's sklearn.decomposition.LatentDirichletAllocation module to model 10 topics in a set of documents. I have also used the same on a reference text (1 document) and obtained a 1 topic ...
0
votes
0answers
13 views

fastICA (Python) does not give white components

Following the example from the sklearn documentation: ...
0
votes
0answers
16 views

Gaussian mixture model for image labelling task

I'm trying to solve an image labelling task by using Gaussian Mixture Models. The total number of classes in my dataset is 9, each representing a different variety of vegetable (Class1, Class2, Class3)...
0
votes
0answers
16 views

Different behavior of MinMaxScaler() on similar range of series

I am trying to understand Sklearn's MinMaxScaler's different behavior for the similar series. I've 2 sets of series with 2 of each in it call it Normal and New. In each of the set, I want to reduce ...
2
votes
0answers
360 views

Why SVM with gamma='scale' for RBF kernel works so well?

The intuitive explanation for the gamma parameter of the RBF kernel in SVMs is the following: Intuitively, the gamma parameter ...
1
vote
1answer
34 views

Work around restrictions of Scikit-Learns PCA implementation [duplicate]

Scikit-Learns implementation of Principal Component Analysis has some restrictions, that are based on the svd_solver (link to docs). This means, that if i have a ...
0
votes
0answers
116 views

Learning curve for kNN train set doesn't change with training size. Why?

I am training several models for a binary classification task (balanced dataset). After hyperparameter tuning, the learning curves for Logistic Regression converge to a value (no overfitting). This is ...
0
votes
0answers
4 views

Data leakage when setting class_weight to tackle imbalanced time series data?

I'm using a random forest classifier from sklearn to predict whether a stock's return for the next period is greater than a certain threshold (say -2%), so negative is 0 and positive is 1, a binary ...

1 2
3
4 5
32