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

Does it make sense to use Gaussian Naive Bayes for a single feature?

I understand that 'Naive' Bayes refers to the approach where all the features are assumed to be independent. But I want to evaluate the performance of each feature individually before I combine all of ...
0
votes
0answers
9 views

What can cause gradient boosting in scikit learn to run faster than xgboost? [closed]

I am running positive unlabeled learning comparing gradient boosting and xgboost, but I am having a problem where somehow gradient boosting runs faster than xgboost, and sometimes running ...
0
votes
0answers
10 views

Does sklearn pipeline() feed both X and y to the following steps? [closed]

So I'm trying to do outlier removal and supervised feature selection in the pipeline before classifier training. For this I had to create custom tranformers to feed into the pipeline. All the examples ...
0
votes
0answers
25 views

How to measure relationship between one independent variable and multiple dependent variables when DVs are both continuous and categorical? [closed]

How can I measure the relationship between one independent variable and multiple dependent variables, but the dependent variables are a mixture of both continuous and categorical variables? The ...
0
votes
1answer
34 views

Multiclassification: precision-recall from scratch vs sklearn

I would like to know if there´s any issue behind using sklearn's precision/recall metric functions and coding up from scratch in ...
0
votes
1answer
16 views

When do we require to calculate the confidence Interval?

I am using various machine learning algorithms for last 7 years. To validate the model in classification algorithm we use precision, recall, f1 score. For regression methods we use R^2,RMSE kind of ...
0
votes
0answers
10 views

Feature selection before hyperparameter selection & cross-validation

I'm trying to train a model to predict water solubility and the dataset has 200 features, with just a few of them being informative and interpretable. My plan is to validate the estimator using 5-fold ...
1
vote
0answers
14 views

Inuition for Aggregators in Adjusted Mutual Information for Clustering

A post comparing Adjusted Rand Index (ARI) and Adjusted Mutual Information (AMI) cites the rule of thumb that we should use ARI when the ground truth clustering has large equal sized clusters use AMI ...
1
vote
0answers
16 views

Which library implements AdaBoost.NC? [closed]

The sklearn implementation of AdaBoost uses the AdaBoost.SAMME variant of the algorithm. Is there a known python-based library the uses the ...
0
votes
0answers
18 views

How to train a linear regression if the number of sample features is variable (time series) (in sklearn)

Let's assume for the samples $\{(x_i,y_i)\},$ the $dim\ x_i$ is variable, e.g. a time series $x_i = (x_{i1},\cdot,x_{iT_i}).$ Then how do we train a linear regression for such samples? Especially how ...
1
vote
0answers
11 views

Efficient way to perform grid search for reduced set of cross-validated data using sklearn [closed]

I am using grid search to find the optimal parameters for 2 models. I have to build one model with entire dataset and another model with reduced dataset (required to keep the folds same for both the ...
1
vote
1answer
18 views

Getting different results when running SMOTE

I have this code which runs SMOTE and then getting roc_auc_score. The issue is that every I run the code on the same dataset, I get different results. How can I fix this? I need the same sample when ...
0
votes
1answer
11 views

How to optimise RandomForestClassifier for one of two outcome options?

I am using a RandomForestClassifier to classify two outcomes, let's say circles and squares. In my data set, there are many more squares (93%) than circles (7%). The percentages are the same in the ...
0
votes
0answers
5 views

What is the default mechanism for determining the best model in sktime's ForecastingGridSearchCV

The documentation doesn't really explicitly mention which is the actual metric that will be optimized across all the hyper-plane parameters. But still it says it returns the best_score_ in the object ...
0
votes
1answer
17 views

How is the threshold parameter practically selected for Scikit learn's decision tree algorithm and how to determine depth of tree?

I am referring to the so-called optimized CART algorithm that is explained on Scikit learn's website: https://scikit-learn.org/stable/modules/tree.html#mathematical-formulation I would appreciate if ...
0
votes
1answer
17 views

Scikit learn justification for the usage of a validation set: why would tuning on training set leak to test set?

it says in the Scikit learn documentation for cross validation: https://scikit-learn.org/stable/modules/cross_validation.html When evaluating different settings (“hyperparameters”) for estimators, ...
0
votes
1answer
42 views

Classification / learning with one class [duplicate]

My dataset contains a single class, which has noisy examples. Up to now I have been converting this to a binary classification problem and using logistic regression, however this does not feel correct,...
0
votes
0answers
10 views

How does KernelDensity.score_samples() evaluate log density model in scikit-learn?

Prior to KernelDensity.score_samples(), we use KernelDensity.fit(). Does the fit() memorizes the datapoints $x_i$ and ...
2
votes
1answer
50 views

Random forest that aggregates by taking the maximum over the trees instead of taking the average

I want to make a Random forest that aggregates by taking the maximum over the decision trees instead of taking the average. By default Sklearn is taking the average, and I couldn't find how to change ...
0
votes
0answers
14 views

Normalization on datasets with different distribution

I am having two datasets one is used for training a model and another one for testing it. The training dataset is large scale corpus of general context (parallel text) while the testing dataset ...
0
votes
1answer
15 views

How do decision trees decide the value to be split upon for continous variables? [duplicate]

I know that decision trees make the split based on some metric such as entropy, information gain, gini index etc. But for continous variables how does it figure the value at which to make a split. For ...
2
votes
2answers
41 views

Naive Bayes - having trouble coming up with a case where Laplace smoothing changes the prediction

I'm thinking through the logic of Naive Bayes and encountered a brain teaser. I know that adding smoothing (alpha) to Naive Bayes can help to increase the accuracy of the model, which implies that it ...
1
vote
0answers
15 views

Interpretation of a tightly paired learning curve with increasing loss

I am assessing models for a binary classification task and have created a model with a very strange learning curve. This is the learning curve of an sklearn AdaBoostClassifier fitted with default ...
1
vote
0answers
21 views

Is it reasonable to do Feature Engineering before Data Preprocessing? [closed]

I want to do data preprocessing with scikit learn and create a pipeline, among other things to avoid data leakage and streamline the process. The problem though is that after fitting the data to the ...
0
votes
0answers
10 views

What are y_weights, y_loadings and y_rotations in sklearn PLS

The partial least squares is an algorithm that seeks to decompose two data matrices $X$ and $Y$ based on a latent structure of the form: $$X=TP+E$$ $$Y=UQ+F$$ where $T$ and $U$ are score matrices, and ...
0
votes
1answer
18 views

What does the prefit parameter in sklearn's SelectFromModel do?

I'd like to use sklearn's SelectFromModel to do feature selection. However, I'm not quite sure I understand the difference between prefit=True and ...
0
votes
0answers
15 views

How to use Dummy Classifier “constant” to obtain baseline prediction

I have a sample data frame that looks like below that I would like to build a baseline model of prediction. I obtained centroid by using ...
0
votes
0answers
7 views

Does scikit-learn implement the SLINK algorithm for single-linkage, hierarchical, agglomerative clustering?

Does scikit-learn implement SLINK for single-linkage, hierarchical, agglomerative clustering? I wasn't able to find that info in scikit-learn's documentation.
0
votes
1answer
39 views

sklearn cross validation wildly different results from manual cross validation

The following code, which uses the function sklearn.model_selection.cross_validate and the scikit learn compatible XGBClassifier:...
1
vote
0answers
23 views

How to get Kappa and MCC from nested cross-validation?

Let's take this well known example. How could I get the Kappa score and the Matthews correlation coefficient from nested cross-validation? I've tried to make it with ...
0
votes
1answer
32 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
16 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
1answer
20 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
32 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
8 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
19 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 ...
0
votes
1answer
36 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
19 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
501 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 ...
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 ...
0
votes
1answer
79 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
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 ...
0
votes
0answers
11 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
63 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
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
27 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
25 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
50 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
2 3 4 5
32