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

Getting feature weights with permutation_test_score()

I am using sklearn to fit a SVM to some data. Since I wanted to use cross-validation and evaluate my classification accuracy using permutations, I am using the permutation_test_score() function (https:...
0
votes
0answers
52 views

Issue in using KNN in out-of-sample estimation

In search of the best possible features of forecasting, I have the idea of finding the KNN(5) of my Y variable to predict future values of Y. This is only possible in real time, using forecasts of X-...
0
votes
1answer
29 views

SVM for fMRI: unbalanced data - leave-one-triplet-out?

I am using SVM (sklearn.svm) to classify fMRI data from two groups of people. One group has n = 25 and the other n = 26. Everyone except for one person has seen 96 trials, so in total I have 2,496 ...
1
vote
0answers
37 views

Scaling revenues - Drawbacks and advantages of average vs. median scaling

Context Currently I am doing some regression-predictions with various machine learning algorithms (still in the experimental phase). Some features I use for the prediction are revenues customers ...
0
votes
0answers
64 views

What's the purpose of using “algorithm = ball_tree” in sklearn.neighbors.KernelDensity?

In sklearn.neighbors.KernelDensity,there is a parameter "algorithm = ball_tree". What is its specific role in KDE? ...
1
vote
1answer
38 views

Testing for multi-collinearity after fitting a model with LassoCV from Sklearn in Python?

Is there a way to test for multi-collinearity, like VIF for example, after fitting a model with LassoCV from Sklearn in Python? https://scikit-learn.org/stable/modules/generated/sklearn.linear_model....
0
votes
0answers
19 views

random forest model is making flipped prediction

I have a very strange problem when trying to use random forests. I am trying to use RF for some binary image segmentation where I am using some texture features and I am using the scikit-learn library ...
4
votes
1answer
244 views

Cross Validation in StackingClassifier Scikit-Learn

In Scikit-Learn StackingClassifier documentation it's written: Note that estimators_ are fitted on the full ...
1
vote
0answers
190 views

Cross Validation for longitudinal/panel data in scikit-learn

I have some longitudinal/panel data that takes the form below (code for data entry is below the question). Observations of X and y are indexed by time and country (eg USA at time 1, USA at time 2, CAN ...
0
votes
0answers
47 views

partial_fit API in minibatch K-Means Sci-kit Learn

The documentation on the partial_fit API from Sklearn is very sparse. I am trying to understand how it works with Sci-kit learns Minibatch K-means algorithm: https://scikit-learn.org/stable/modules/...
0
votes
0answers
288 views

How to do Data Augmentation and Cross validation at the same time

I have read somewhere that you should not use data augmentation on your validation set, and you should only use it on your training set. My problem is this: I have a dataset with few samples. I split ...
1
vote
0answers
151 views

Polynomial regression multicollinearity assumption?

The difference between Linear regression and Polynomial regression is that in the last we manipulate our original explanatory ...
1
vote
1answer
31 views

Correct way (if any!) to apply preprocessing to hold out dataset

After cross validation and grid search the below are the desired pipeline steps and hyper-params for my model. ...
2
votes
1answer
19 views

Does it make sense to obtain the greatest error when evaluating only dataset with the most important categorical feature?

I'm running a Gradient Boosting Regressor using scikit-learn. Within my features, I have a categorical feature (let's say Res), ...
0
votes
0answers
33 views

Plot SVM boundary *after* training in Python

I want to train SVM on multiple features for high accuracy. Then I want to do the visualization: reduce dimensionality to 2D (with PCA, t-SNE or anything else) and plot the learned decision boundary. ...
1
vote
0answers
305 views

AUC ROC and Varying Thresholds?

I understand that the ROC curve will plot the sensitivity vs FPR for varying thresholds. For my SVM ML model, I desire a good sensitivity score so I have decreased the threshold to make a positive ...
0
votes
0answers
38 views

Does feature selection with mutual information require scaling?

I’m building a machine learning model that has continuous, discrete and one-hot encoded features. I would like to use mutual_info_classif for feature selection (through SelectKBest). Do I need to use ...
0
votes
0answers
1k views

val_accuracy not changing but it is very high

My model's validation accuracy doesn't change and I have been trying to fix it for a while, but now the accuracy is very high. I'm not sure if that means my model is good because it has high accuracy ...
0
votes
0answers
31 views

Do I compute sample_weights on the original dataset or the training data?

I have an imbalanced dataset which looks like this. I will use the a reweighing technique to improve the fairness of my dataset (a good example of this is shown in this article). Computing the weights ...
0
votes
1answer
35 views

GBDT predict() sometimes gives different class value than using apply() and then sum leaf values [closed]

In sklearn GradientBoostingClassifier, when I use predict() to classify: gbdt = GradientBoostingClassifier(n_estimators=7) tree_preds = gbdt.predict(X) gives ...
0
votes
0answers
19 views

Implication of correlated and non-correlated features and target for machine learning/linear regression

I am new to applying linear regression on datasets. I have experience mostly from Coursera courses and MOOCs. There are certain dilemma i am facing when I look at the feature and their correlation to ...
1
vote
1answer
42 views

How can I improve a classification algorithm for dogs and cats?

The following code is a ML algorithm trained to classify between dogs and cats, the database is composed by 25000 images (evenly split) and can be obtained at this Link (if you click it will ...
0
votes
0answers
18 views

Feature importance on one specific prediction

I'm looking to create a machine learning model that could provide, after the prediction, an information about which variable, in this specific case, made the model decide if its prediction was 0 or 1. ...
4
votes
2answers
314 views

Is it better to compute Average Precision using the trapezoidal rule or the rectangle method?

Background Average precision is a popular and important performance metric widely used for, e.g., retrieval and detection tasks. It measures the area under the precision-recall curve, which plots the ...
1
vote
0answers
97 views

How is sklearn's Logistic Regression's Score Calculated?

I used sklearn.linear_model.LogisticRegression to check how the price of a quote affects whether that quote is taken. ...
1
vote
0answers
27 views

How do I use the coefficients from a logistic regression model to recreate the predictons myself

I've been banging my head against a wall on this as I'm pretty sure this should be pretty straightforward. So I have a pipeline which replaces a few nulls as zero, scales each column (I understand it'...
-2
votes
1answer
36 views

Train/Validate/Test in Scikit learn [closed]

I need to x_train, X_validate, and y_test. This is the code I have so far, but I do not think it is right. Could someone please guide me? I typically only see train and test, not all 3 together. ...
1
vote
1answer
300 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
0answers
14 views

Combining PLS components

I am using Partial Least squares to investigate associations between two multidimensional datasets. I have 60 observations, and one of the datasets has 60 features, while the other has around 5,000. ...
0
votes
0answers
23 views

how to set the hyperparameters ranges when hyperparameters optimization?

I am using machine learning algorithms to solve my problem. I do hyperparameters optimization in my training data. I am confused that how to set the hyperparameters ranges or the guide principle. For ...
1
vote
0answers
23 views

LabelBinarizer gives too many features on test

Let's say I have a Dataset with a coulum called countries. Lots of the values are usa and there is a small amount of values wich are either ...
0
votes
0answers
10 views

How can I find the “typical” clustering distance?

Say I have a few hundred positions along a straight line, and am looking for (one-dimensional) clustering along that line. I am aware of several clustering algorithms that are available (e.g. scikit-...
0
votes
0answers
58 views

Why average probability estimates when applying Platt scaling with cross validation?

On the subject of doing probabalistic classification and calibration with cross validation, the sklearn docs for Probability Calibration state: ...
2
votes
1answer
163 views

What's the score employed by Platt scaling to compute SVM posterior probabilities?

I have read about the Platt scaling approach to compute posterior probabilities for the SVM classifier $P(y=1|x)$. In Scikit-learn's SVC (SVM) implementation this is the approach used to produce ...
2
votes
0answers
111 views

Why is bias term not included in Regularization (Regression/Classification)? [duplicate]

I read different articles including this answer. Why is bias term not included in regularization, in general? I see some of the algorithms such as LinearSVC includes bias term in regularization. ...
0
votes
0answers
25 views

How can I put a multilabel decision tree into PMML format?

I am part of a team that is creating an app to accompany stroke patients through the recovery process. One component of this is creating an algorithm to suggest treatments based on certain clinical ...
1
vote
1answer
15 views

Engineering features that depend on more than one data point (classification with gradient boosting in particular)?

So I'm working on the Titanic data set (predicting survival of passengers), and would like to add a feature that indicates whether a given passenger's family survived or not (using the known training ...
1
vote
0answers
33 views

How is ExtraTrees different from Decision Tree for classification of dataset with one feature?

From what I understand ExtraTrees has one source of randomness in building an ensemble - random selection of features. But if there is only one feature, shouldn't ExtraTrees be the same as a ...
0
votes
0answers
20 views

Implementation of the multi-class XGBClassifier with a “one-vs-one” strategy

The Scikit-Learn Wrapper interface for XGBoost provides a direct and easy to use multi-class approach within it's API. However, it implements the one-vs-all ("one vs. the rest") strategy. Is ...
0
votes
1answer
32 views

The objection function of Lasso in sklearn: why the coefficient 1/(2*n_samples) is there?

In sklearn Lasso (link below): https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Lasso.html?highlight=lasso#sklearn.linear_model.Lasso , there is the coefficient 1/(2*n_samples) ...
1
vote
1answer
43 views

How to replace scalars with vectors in simple models, such as classification of sentences where 1-hot encoding is replaced with word vectors

I have a problem, which seems simple enough, but I don't know how it is solved in the industry. This has to do with the machinery of feeding data to a model, rather than trying to figure out the best ...
0
votes
0answers
14 views

Compare ground truth images of classes with clustering output classes images

I have a ground truth input of 24 folders (classes) and each folder has 20 images. Each image has an encoding feature template and consists of 512 dimensions like ...
1
vote
1answer
1k views

How to implement the closed form solution of Ridge Regression in Python when intercept is not 0 (fit_intercept=True) without using sklearn?

The well-known closed-form solution of Ridge regression is: I am trying to implement the closed-form using NumPy and then compare it with sklearn. I can get the same result when there is no ...
0
votes
0answers
11 views

How to find the k value for K-Means clustering using scikit in python? [duplicate]

I have a Pandas DataFrame which looks like this: ...
0
votes
1answer
20 views

Apply logistic regression to binary data - Need guidance

Good morning. I am trying to predict the probability of death of people suffering from a disease, based on their age and gender. Currently from the data (approximately 50,000 people), 43699 survive ...
1
vote
1answer
34 views

Scikit learn models gives weight to random variable? Should I remove features with less importance?

I do some feature selection by removing correlated variables and backwards elimination. However, after all that is done as a test I threw in a random variable, and then trained logistic regression, ...
0
votes
2answers
86 views

Linear Regression with vs. without polynomial features

I have a conceptual question about why (processing power/storage aside) would you ever just use a regular linear regression without adding polynomial features? It seems like adding polynomial features ...
0
votes
0answers
20 views

Best practices for predicting trial to paid conversions for in-progress trials

I have a data frame that has tens of thousands of rows that look like this: ...
0
votes
0answers
149 views

calculation of eta squared using ANOVA, or anyway in general to measure effect size

Is there a way to find the sum of squares for each dependent variable in a dataset, which can then be used to compute the eta squared values in python. ...

1
4 5
6
7 8
32