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
0answers
17 views

The most important matrices for evaluating a predictive model for customer churn

My questions is as above. What are the most important matrices (f1, precision, recall...etc) that I need to prioritize my work to improve for evaluating how good a model predict customer churn and the ...
0
votes
0answers
18 views

Adaboost - Is it (really) necessary to plug sample weights into cost function?

I implemented Adaboost using the SAMME algorithm (for multiclass) with Multilayer Perceptron networks as weak learners. For the MLP, i am using ...
1
vote
2answers
35 views

Why does plotting a LinearRegression from sklearn make a crazy graph?

I've seen a couple of posts on how to make a simple graph that looks something like this: The code for this would be as follows: ...
1
vote
0answers
64 views

Unstable cross validation results, which one do I select?

I'm running StratifiedKFold(n_splits=5, shuffle = True) on a binary classification problem. I take the accuracy and recall from each testing fold and report their average. I noticed that the averaged ...
0
votes
0answers
41 views

nature certainty in predict_proba in GaussianNB() from sklearn, python

If using predict_proba in a GaussianNB() model I generate the following two sets of probabilities: Probabilities of '0' and '1' outcomes: ...
0
votes
1answer
63 views

Is it correct to decrease the alpha parameter in sklearn SVM pipeline to improve performance?

I'm trying to find the best parameters for a Fine-grained Sentiment Analysis of a dataset of movie reviews. This is the current code: ...
0
votes
1answer
44 views

Using my models with NGBoost?

I've come across this new tool of NGBoost from the Machine Learning group of Stanford, I was curious if peopel have started using it yet. They say that one can have a Base learner such as a regression ...
0
votes
0answers
21 views

Is it an overfitting problem for SVM classification?

I am new in Machine learning, and I want to detect emotions from the face. Preprocessing: I used equalizeHist to equalizes the histogram of grayscale images (JAFFE database with 213 images), in the ...
4
votes
2answers
100 views

Should we center original data if we want to get principal component?

Suppose we have data matrix $X$ with shape $n*p$, each row $x_i^T$ is a sample. By definition first principal component is $y_1 = e_1^T * x$, where $e_1$ is unit eigenvector corresponding to largest ...
2
votes
1answer
35 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
46 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
28 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
53 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
34 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
17 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
213 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
149 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
42 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
251 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
102 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
25 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
28 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
260 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
34 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
29 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
34 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
15 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
265 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
86 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
26 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
33 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
261 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
13 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
21 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
22 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
50 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
138 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
87 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
19 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
31 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
3 4
5
6 7
31