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
0answers
10 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 ...
0
votes
0answers
6 views

PCA of self generated data using orthogonal components itself, gives back inconsistent components

I was trying to study python API in sklearn for PCA to test if it can recover back the orthogonal vectors to generate data. Steps Used: Generate 3-D random orthogonal vectors. I take first two ...
3
votes
1answer
47 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
77 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
14 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
11 views

Python Libraries for different regression methods [closed]

What is the best library/functions to perform regressions like standard least squre regression (SR), Inverted standard least squre regression (ISR) , orthogonal regression (OR), general orthogonal ...
1
vote
0answers
13 views

I need a concrete example of collinearity and multicollinearity in linear regression [duplicate]

Consider a set of examples $x_1, x_2, x_3, \ldots, x_N$ where each $x_n \in \mathbb{R}^D$ I form a design matrix $X$, defined as $X = \begin{bmatrix} x_1^T \\ x_2^T \\ \vdots \\ x_N^T \end{bmatrix} \...
0
votes
0answers
11 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
6 views

sklearn implementation of nDCG seems not suitable for recsys that generate a ranked list of items. Any library recommended?

Most recommenders do one of two tasks. They either ... attempt to predict a rating of an item by a user, or generate a ranked list of recommended items per user. What I want I'm currently interested ...
0
votes
0answers
17 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 ...
1
vote
0answers
14 views

Bayesian Gaussian Mixture Models | Model selection & Selecting the number of active components [closed]

I have generated 2 groups of 1-D data points which are visually clearly separable and I want to use a Bayesian Gaussian Mixture Model (BGMM) to ideally recover 2 clusters. Since BGMMs maximize a lower ...
0
votes
0answers
22 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 ...
1
vote
0answers
12 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
12 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 ...
1
vote
1answer
14 views

Is there a way to add timer to Random Forest Classifier and return parameters even if not done tuning [closed]

I'm trying to find a way to add a timer to SKLearn Random Forest, so if I allocate an hour it'll run for an hour and at 1 hour if it's not done just return and use the parameters found after an hour. ...
2
votes
2answers
83 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
18 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: ...
2
votes
1answer
22 views

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

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
5 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
19 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
27 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
20 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
18 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
25 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
19 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
19 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
19 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
18 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
33 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
17 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
16 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
26 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
9 views

fastICA (Python) does not give white components

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

Custom boosted pipeline in sklearn [closed]

I am interested in assembling a pipeline that has a series of models $[M_1, M_2, ..M_n]$ assembled in a boosted configuration. By that I mean: Fit $X$ on $Y$ with model $M_1$, get the residuals (call ...
0
votes
0answers
13 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
14 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
47 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
26 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
69 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
3 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 ...
0
votes
0answers
18 views

Stacking of Machine Learning models using different data splits

I have one single dataset with 2 classes. I want to make a model for binary classification, and I am experimenting a bit. My intention is to use stacking on some models by using subsets of the 1 ...
0
votes
0answers
24 views

Multiclass Logistic Regression: How does sklearn model.coef_ return K well-identified sets of coefficients for K classes?

I am looking to fit a multinomial logistic regression model in Python using sklearn, some pseudo python code below (does not include my data): ...
0
votes
1answer
53 views

Optimize number of hidden layers and neurons with RandomizedSearchCV (scikit-learn) -> No unnecessary trainings?

I want to optimize the number of hidden layers and the number of units in each hidden layer. For this I used RandomizedSearchCV from sklearn in this way: ...
0
votes
0answers
15 views

Getting Negative Values When Trying to Recover Standard Errors from Sparse Matrix with sklearn LinearRegression

I am using the answer given to this SO question to try to recover Standard Errors for a large linear regression from the LinearRegression() method in the python ...
0
votes
0answers
21 views

sklearn.model_selection : sampling issue with TimeSeriesSplit

I am new to sklearn and the TimeseriesSplit, I appologize in advance if that's a dumb question. I cannot find nowhere a way to solve my issue. To my understanding a sample is a row in the timeseries, ...
3
votes
1answer
47 views

What does it tell you when PCA cannot reduce the dimensionality of your dataset

I'm new to PCA and I'm trying to apply it to a dataset I have with 15 different features. I normalized my dataset before applying PCA and used the PCA method in the decomposition function from sklearn....
0
votes
0answers
41 views

how to interpret negative values in permutation importance report?

i am using a permutation report from sklearn. i train my model and optimize on 'mean_squared_error' this is actually negated in sklearn. when i get the perumutation importance report however how do i ...
1
vote
0answers
35 views

Interpretation of unreasonably high R-squared [closed]

High CrossValidated community, I need your "brains" to explain a result related to my model(s). I have some data that contain physical quantities $y$ measured at specific points (e.g. ...
2
votes
3answers
47 views

What's the speed bottleneck in sklearn.svm.SVC.predict?

I'm working with some high resolution images of specimens in test tubes and I found that using an SVC to classify each pixel by HSV value helps me to a great job at segmenting out just the specimen ...

1
2 3 4 5
30