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
1answer
18 views

How does KernelDensity.fit() do the fitting in scikit-learn

How does sklearn.neighbors.KernelDensity.fit() fit the dataset with a probability density distribution? The bandwidth is a parameter that we are already providing; ...
0
votes
0answers
15 views

analyse pattern in confusion matrix using sklearn

I have build a logistic regression model using sklearn and I got the confusion matrix. TNR is 1262(84.13%),tpr is 147(9.80%),fnr is 89(5.93%) and fpr is 2(.13%). I need to find the pattern for fnr and ...
0
votes
0answers
14 views

What does score_samples() do in kernel density estimation? [closed]

In the scikit-learn page page, it's written KernelDensity.fit(X) will "fit the Kernel Density model on the data." I assume this basically means that using ...
1
vote
2answers
285 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 ...
-1
votes
0answers
9 views

Gohen's weighted Kappa canculated by `irr` package in R is wrong [closed]

I found the irr package has 2 big bugs for the calculation of weighted kappa. You can replicate the bugs using the following ...
0
votes
1answer
18 views

Have issues with tuning hyper parameters

I'm a newb, so working with the Iris dataset (with the 2 data errors fixed). Got some pretty standard stuff for a test harness: ...
1
vote
1answer
17 views

Why dual problem coefficients from svm.SVC contain zeros

My question is about the output in sklearn.svm.SVC function in Python. Apologies for a software context question but I believe a good number of those who have ...
0
votes
0answers
5 views

Extracting feature weights after fitting SVC with pre-computed linear kernel

I'm using sklearn's SVC with a linear kernel to train and predict brain states from functional MRI data. Upon completion, I want to extract the feature weights to identify which of these contain the ...
0
votes
0answers
15 views

Summing of Catboost's scikit learn 'permutations importance' values for groups of features

I have built a catboost classifier trained on approximately 600 features, and I want to calculate the permutation importance of groups of features. My question is, can I use the permutation importance ...
1
vote
0answers
253 views

SVM model overfitting?

I have a multi-class (10 classes) classification problem. I am using one-vs-rest SVM modeling with sklearn.svm.SVC. I want to know whether my model is over-fitting. For train set accuracy is 100% ...
3
votes
1answer
289 views

Can LogisticRegressionCV be used with StandardScaler?

If we apply StandardScaler to transform the training data before we fit the LogisticRegressionCV model, I think it is incorrect ...
0
votes
1answer
35 views

Iris data set actual results vs. “expectations”

I'm starting on ML with the Iris dataset (with the errors corrected). I've built a typical test harness in Python. ...
1
vote
0answers
15 views

Gamma GLM vs Linear Regression

I have a problem where the expected regression output should be "loan amount". The expected output should be between 2 values (EX: 100K and 1000K) I was thinking of using a Gamma GLM since ...
4
votes
3answers
478 views

Why is polynomial regression used to demonstrate overfitting and underfitting?

WhenI try to research overfitting and underfitting, the most common algorithm and explanation I see revolves around polynomial regression. Why is this so? Is it just because it can be easily ...
2
votes
1answer
82 views

Scikit learn - GMM log-likelihood. Why use Cholesky's precision matrix instead of covariance matrix?

This is my first post, please let me know if I am not being clear. I am trying to understand the sklearn.mixture.GaussianMixture.score(X). As I understand that the ...
1
vote
1answer
968 views

Why would a tuned SVM model have a lower F1 score than an untuned SVM model?

I have a binary classification problem, with about 500 rows of data and 50 features. Due to the nature of the data, it seems SVM is the best solution to it. But the problem is that for some reason, ...
0
votes
1answer
375 views

how does class 0 scores in the classification report are calculated ( sklearn python )?

Here how these class-0 probability are calculated?? print(classification_report(y_true, y_pred, target_names=target_names)) precision recall f1-score support ...
2
votes
2answers
13k views

How do I increase accuracy with Keras using LSTM

I will start with saying I am a complete beginner and doing this assignment for a class, and having some issues on how to get this to be accurate and (somewhat) show it's working! Can someone that ...
0
votes
1answer
64 views

Question regarding log marginal likelihood in SKLearn

I'm trying to understand the hyperparameter optimization implemented in SKLearn. I'm using the basic example presented here with an alternative data set of 100 observations of Rastrigin test function (...
0
votes
0answers
14 views

Preprocessing deterministic data with sklearn

I am trying to create a set of ML models that will serve as a replacement for a complex deterministic simulation. The simulation requires 4 inputs (x1, x2, x3 and x4) to determine 4 different outputs (...
1
vote
0answers
14 views

Can the value obtained from GridSearchCV be used to find the best model after hyperparameter tuning? - sklearn

I have two model: k-nearest neighbours and a ridge classifier. In order to find the best hyperparameters, the code below is run. For ridge classifier ...
5
votes
1answer
2k views

Improve precision/recall for class imbalance?

Trying to get better precision/recall for both classes ... any tips? I have heterogeneous features [a few num vars, a few cat vars, and 2 text vars] Target is a binary classification w/ class ...
0
votes
0answers
11 views

How logistic regression class weight works in scikit?

I guess the math behind logistic regression computation of the three classes (c1,c2,c3) and 4 features (x1,x2,x3,x4) follow something like this. I have two question. (1) When I give input ...
3
votes
1answer
635 views

Calculation of nu and gamma in one-class SVM with rbf kernel

I am using python sklearn's one-class svm classifier for anomaly detection. I would like to know can I accurately calculate the required value for nu and gamma for rbf kernel. Is there any equation or ...
0
votes
1answer
1k views

DBSCAN considers all data points noise for reduced time series data [closed]

I had a data matrix 609 rows × 264 columns, time-series data. Data was reduced using t-SNE algorithm to 3 dimensions. When being clustered I get zero clusters, where all data points are considered ...
0
votes
1answer
332 views

How is BayesianRidge different from Ridge?

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.BayesianRidge.html https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html For me, the different is <...
0
votes
1answer
22 views

Relationship n_components and Y array dimension - Canonical Correlation Analysis (CCA)

Background My system tries to classify among three classes. At first, my labeling for CCA had a single dimension {1, 2, 4}, but then I found out that to get more ...
0
votes
0answers
10 views

Why does my cross_val_score give different values when I run it again? [duplicate]

I'm practicing testing multiple models on the iris dataset with python and I have the following code: ...
0
votes
0answers
23 views

RFECV (Recursive Feature Elimination with Cross Validation) grid scores discrepancies

I would like to know why the grid scores obtained by RFECV (Recursive Feature Elimination with Cross Validation) for nth features do not match the scores when I run RFE and train a model with same ...
0
votes
1answer
202 views
0
votes
0answers
19 views

sklearn pipeline: standardize features for feature selection, but not for model

I use a sklearn pipeline that contains a SelectFromModel with LinearRegression and a DecisionTreeRegressor step. The SelectFromModel with LinearRegression requires standardization of the input ...
0
votes
0answers
24 views

Why isn't my gaussian process regression failing?

If I understand well, a homogeneous linear kernel imposes only one degre of freedom on the parametrized function. I tried to make sklearn fail but it doesn't: ...
0
votes
1answer
1k views

Constructing a model with SMOTE and sklearn pipeline

I have a very imbalanced dataset on which I'm trying to construct a LinearSVC model with SMOTE and standardization, using a Pipeline. I had already applied SMOTE and sklearn's StandardScaler with ...
0
votes
1answer
31 views

Why does Multinomial Naive Bayes work well on discrete features?

I understand Multinomial Naive Bayes is a specific instance of Naive Bayes when the data distribution is assumed to be multinomial. In the sklearn documentation for Multinomial Naive Bayes, it is ...
1
vote
3answers
635 views

Samples in decision trees

I am trying to do some binary decision trees with Python (scikit-learn), but my sample has a bad repartition : I have something like 100 000 data points with label 0 and 800 000 with the label 1. So ...
1
vote
1answer
266 views

What is the difference of 'max_iter' definition for “LBFGS” and “SGD,Adam” optimizers in sklearn MLPClassifier?

I am trying to use scikit-learn's MLPClassifier with the LBFGS optimizer to solve a classification problem. In the documentation of the module, there is a statement that ...
0
votes
1answer
20 views

The resulting image file is even larger than original when using K-means to do image compression

I am trying to compress jpeg file [Original Picture] [Compressed Picture with K-means using K=10] However, the original one is 85K while the compressed one is 101K? Here is the code I use: ...
2
votes
1answer
32 views

Random forest final stage: Consider the training dataset or the entire dataset?

I trained and tuned a random forest classifier using cross validation and train-test split, as in 70% training dataset (which is then cross validated 5 splits, 6 times) and 30% test dataset. With the ...
0
votes
1answer
33 views

Matrix Factorization and Linear Regression

Which matrix factorization algorithm is used in LinearRegression() function of scikit-learn?
8
votes
4answers
17k views

TfidfVectorizer: should it be used on train only or train+test

When training a model it is possible to train the Tfidf on the corpus of only the training set or also on the test set. It seems not to make sense to include the test corpus when training the model, ...
0
votes
0answers
30 views

convert R2 score from sklearn (variance score) to the R squared coefficient?

I am trying to run RANSAC robust fit method on my data and predict correlation between my X and Y data. I have decided to use this method because in my small dataset I have identified one outlier. I ...
6
votes
2answers
451 views

Using StandardScaler function of scikit-learn library

I have been using the StandardScaler function from the sklearn library. Could you tell me how it normalizes the distribution in ...
0
votes
0answers
5 views

Partial_dependence_plot with gbt estimator has a mean response shift between curves computed by different methods ( 'brute' or 'recursion')

The new version of scikit-learn's partial_dependence function has the 'kind' additional option. With kind='average' one can compute the values for the partial dependence plot (PDP), with kind='...
1
vote
0answers
24 views

How to find the optimal threshold for the Weighted f1 score in a binary classification problem

I know how to find the optimal threshold for the standard f1 score but do not know how to do so for the weighted f1 score with the sklearn library. Sklearn provides a way to compute the weighted f1-...
2
votes
1answer
216 views

Why does the 'weighted' f1-score result in a score not between precision and recall?

On the F1 score sklearn page there's a section that explains each of the options for the average parameter. Under the weighted option, it says: "it can result in an F-score that is not between ...
1
vote
2answers
436 views

Estimating parameters of mixture of 2 exponential random variables (ideally in Python)

Imagine a simulation experiment in which the output is n total numbers, where k of them are sampled from an exponential random variable with rate a and n-k are sampled from an exponential random ...
0
votes
0answers
8 views

How can I force sklearn decision tree to select predefined feature as the root?

I would like to create a single decision tree from my data, but I want the decision tree to make the first split using a feature that I selected, not necessarily the feature that creates the best ...
0
votes
1answer
224 views

Inititialize alpha in LassoLarsCV and LassoCV in sklearn

Is there a way to initialize (warm start) the value of alpha used in LassoLarsCV and LassoCV?...
0
votes
0answers
21 views

Cross-validation / Threshold moving when training is balanced but test is imbalanced?

I have a binary text classification problem where texts of class 0 account for ~95% of cases and class 1 for ~5%. I put some effort until having a decently sized, balanced manually labeled subset (7k) ...

1
2 3 4 5
32