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
12 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 ...
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
6 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-...
0
votes
0answers
7 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
0answers
19 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) ...
0
votes
1answer
24 views

PCA and eigendecomposition: Calculating loading vector in Python

For an assignment the Matlab code has to be rewritten into Python code. ...
0
votes
0answers
7 views

How can I generate a plot of the partitions in Isolation Forests

I have seen this plot is used to indicated how anomalies are isolated via partitioning in Isolation Forests. Is there a library to automatically plot this from a dataset? The plot I want to generate ...
1
vote
1answer
20 views

One hot coding in Train Validation and Test set (Production data) [closed]

For example I have below train set. name values 0 Tony 100 1 Smith 110 2 Sam 120 3 Shane 130 4 Sam 140 5 Ram 160 After ...
1
vote
1answer
17 views

How to evaluate the loss on a Gaussian Mixture Model?

I successfully modeled my data using a Gaussian Mixture Model in scikit-learn but I can't figure out how I should say "how good" the model is by calculating the loss. My first thought was to ...
0
votes
0answers
27 views

Is upsampling a tiny class before cross-validation valid?

I'm working with a dataset containing several classes. The largest class has over 500 samples, and the smallest classes have fewer than 10 samples. I know that you should perform upsampling inside the ...
0
votes
0answers
12 views

Micro average for AUC/ROC

The yellowbrick documentation has an example of AUC/ROC here. It seems odd to me the micro average would have an AUC much bigger than the individual classes or macro average. Is there some reason the ...
0
votes
0answers
9 views

Are the statsmodels and sklearn implementation of multinomial logistic regression equivalent?

I'm trying to wrap my head around multinomial logistic regression for k classes. It looks like one formulation of the problem is to do k-1 binary logistic regressions with one class as a "pivot ...
0
votes
1answer
19 views

Question about using formula to compute PCA transform in Python

I try to understand how the Python function sklearn.decomposition.PCA working. I read the documentation of the code package in Github about transform function. And ...
0
votes
2answers
36 views

Why is the optimal C chosen by GridSearchCV so small?

I'm trying to use GridSearchCV to select the optimal C value in this simple SVM problem. The issue I'm having is that when I run the code the optimal C is chosen to be ridiculously small (~e-18) so ...
1
vote
0answers
24 views

Fitting a linear regression model to a chained function

Assuming I have a dependant Variable X (Target) which I fitted a linear regression to: X = a + b1(A) + b2(B) + E What is the best practice to fit a linear regression for another Variable Y which ...
2
votes
1answer
56 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 ...
0
votes
0answers
11 views

How do I efficiently project a data point on a linear SVM?

I already asked the question on stackoverflow but I think this might be rather the forum where I should've asked the question, so please refer to: https://stackoverflow.com/q/66797637/7732820
0
votes
0answers
28 views

Forecasting with lagged data

I'm trying to forecast some values with information about many variables from the past, there's a description of the data: It contains information over the time from 5 sensors for different variables ...
1
vote
0answers
18 views

How to parametrize a Decisiontree Classifier for NLP tasks?

I want to use sklearns DecisionTreeClassifier for sentiment analysis. I am fully aware that a decision tree is probably not a good model for this kind of task, but I want to try it anyways for the ...
1
vote
1answer
30 views

Initial guess for linear regression

This is a very basic question but I was reading the notes by Andrew NG (https://see.stanford.edu/materials/aimlcs229/cs229-notes1.pdf) about linear regression and am wondering how the initial guess ...
1
vote
0answers
36 views

How to choose the value of nu parameter in one class SVM data without outliers

The nu parameter is an upper bound on the fraction of training errors and a lower bound of the fraction of support vectors. I quote from scikit-learn : This estimator is best suited for novelty ...
0
votes
0answers
7 views

How to use Product Matching to create Product Bundles

I am working on a product matching model. GOAL A store has many products like creams, perfumes, other beauty products. Based on product properties I have to cerate bundles of it so we can sell more ...
0
votes
0answers
12 views

Scikit-Learn - model gives certain feature too much weights

I have run a random forest model with scikit-learn. And my dataset got 10 same types of features which I named them as feature1, feature2 ... feature10. These features come from the same data source ...
0
votes
0answers
16 views

Huge AUC difference between using predictions from xgboost.train and XGBClassifier

I'm using two different versions of XGBoost modeling, and seeing that the two versions are producing vastly different AUC results. As far as I know, the XGBClassifier.fit() method should be using the ...
0
votes
0answers
16 views

How to interpret the output of cross-validation for SVR

I wrote this code to run a SVR with cross validation: ...
0
votes
0answers
9 views

I do PCA manually with numpy in the same method as Scikit Learn and getting same values but different signs [duplicate]

It is asked me to do PCA manually. I wrote a code that does PCA in the same way as Scikit Learn PCA function, but even if I got the same values, some of the values had different signs. My code is <...
0
votes
1answer
33 views

incorrect results of IsolationForest

I inspired by this notebook, and I'm experimenting IsolationForest algorithm for anomaly detection context on the SF version of KDDCUP99 dataset, including 4 ...
1
vote
0answers
24 views

How can i find best metric

I have many confusion matrices and I need to select best matrix according to precision(TP/TP+FP) and total predictions(TP+TF+FP+FN)..I mean I prefer 8 true in 10 guesses over 2 true in 2 guesses. I ...
0
votes
0answers
11 views

Why does using probabilities result in higher ROC_AUC scores?

in the most recent playground competition on kaggle (https://www.kaggle.com/c/tabular-playground-series-mar-2021/overview/evaluation) we once again have an evaluation via the area under the roc curve. ...
0
votes
0answers
8 views

How to forecast same number of inputs

I would like to forecast two non-correlated attributes (non-stationary). The input is X1 and X2, and I need the same attributes as output X1 and X2. I've followed some examples in here https://...
0
votes
0answers
12 views

Forecast two variables in MLP scikit-learn

I have two non-correlated variables which I would like to forecast. I mean, the output should be those two variables. How can I do it? I just found examples where output is one variable. https://...
0
votes
0answers
27 views

Reproducible sklearn SelectKBest + GridSearchCV results

I would like to be able to reproduce sklearn SelectKBest results when using GridSearchCV by ...
2
votes
1answer
37 views

Training, saving and distributing the model – what about data the transformations?

I have a question about process, and I’m a relative noob when it comes to Machine Learning. Let’s say I have dataset with X features to train a model. During development of my model I drop a few ...
0
votes
0answers
27 views

When does MAPE (Mean Absolute Percentage Error) fail?

I have a multioutput regression model that predicts float values. When using MAPE to evaluate regression model performance (using either built in libraries or implementing a function for it) I am ...
0
votes
0answers
23 views

Is there any way of limiting the matchable classes for data in SVMs?

Let's say I'm working on the "Recognizing hand-written digits" where we are using an SVM to analyze handwritten digits. Now imagine we have some additional information, for each image we are ...
0
votes
0answers
15 views

Sentiment Analysis using an SVM - How to comprehend the models decision based on weights and input?

I am doing sentiment analysis using sklearns linear SVM and I want to try to figure out why certain texts get incorrectly classified by looking at the models weights and the vector for that text. For ...
0
votes
0answers
12 views

Machine learning training with regard of hidden features

Having an effect that my data has a hidden feature, leads to falsely high accuracy, when training my data without regarding this effect. This kind of data looks like: index n features label Then the ...
0
votes
2answers
26 views

Large Negative r-Squared Scores using Cross-Validation

I am working working with the World Happiness Report dataset from Kaggle. When using either cross_val_score or GridSearchCV from ...
0
votes
1answer
26 views

XGBoost, Imbalanced Data and CalibratedClassifierCV

I am currently working with a slightly imbalanced dataset (9% positive outcome) and am using XGBoost to train a predictive model. ...
0
votes
1answer
20 views

Does GridSearchCV actually fit the best model to the training data, or do you have to refit after hyperparameter optimisation?

I have this code, with the aim being to develop a neural network with cross validation and hyperparameter optimisation for a regression problem (continuous features, continuous label). ...
2
votes
0answers
16 views

Does Sklean have a Gaussian Discriminant Analysis (GDA)

I was trying to look for the Gaussian Discriminant Analysis in sklearn however I was unsuccessful and I was wondering what it the name of it. I was about to find the LinearDiscriminantAnalysis and ...
1
vote
0answers
22 views

Least median square in python

I couldn't find least median square technique on python, any one knows any library? Or how to adapt it from the common linear regression.
1
vote
1answer
16 views

Control group in ML model? [closed]

I have on my Data Frame column with name "group" with values: control_group / campaing_group. And my question is should I use observations from "control" in Machine Learning model ...
0
votes
0answers
16 views
0
votes
0answers
32 views

How do I handle separate standardization for test and training when doing Cross-Validation

I understand that if I am going to standardize numeric columns in preparation for a machine learning algorithm, I should do this scaling separately for training and testing data, which is fine and ...
0
votes
0answers
6 views

F1 Score of RFE Top 20 features Greater than RFE CV F1 Score

I've been running some simulations using RFE on random forests and I got some puzzling results. Let's say I run RFE with CV and the highest F1 score is sometimes lower than the F1 Score I get from ...
0
votes
0answers
6 views

“GP Kernel” between parameters in skopt

I am trying to run skopt's gp_minimize optimization algorithm over a set of parameters, and I'm having trouble understanding how ...
3
votes
2answers
93 views

How to understand and interpret multicollinearity in regression models

I am using python to implement different regression models on a fantasy sports dataset. I am using a multivariable dataset which contains 5 independent variables to 2 regression models, which is Lasso ...
3
votes
0answers
32 views

KFold CV and Monte-Carlo CV performance for a regression problem

I've ran the following code on google colaboratory. Succintly, I've used some housing prices for a typical regression problem, and then trained the same simple neural network, but with different Cross-...
2
votes
0answers
27 views

Why Ridge and Lasso regression is returning almost identical results to Linear Regression [closed]

I was trying to compare Ridge, Lasso and Linear Regression models to each other. I am using a subset of the Ames housing dataset. Here is a link to an already preprocessed dataset that I am using. The ...

1
2 3 4 5
31