Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
Make your voice heard. Take the 2019 Developer Survey now

Questions tagged [scikit-learn]

scikit-learn is a machine-learning library for Python that provides simple and efficient tools for data analysis and data mining, with a focus on machine learning. It is accessible to everybody and reusable in various contexts. It is built on NumPy and SciPy. The project is open source and commercially usable (BSD license).

1
vote
0answers
7 views

How to compute/plot the contribution of each original descriptor in a final PLA regression model?

New to scikit-learn. I am using v 20.2. I am developing PLS regression models.I would like to know how important each of the original predictors/descriptors are in predicting the response. The ...
0
votes
0answers
10 views

How to apply PCA using statsmodels library [on hold]

I am using statsmodel for developing linear regression model. I want to use PCA using the same statsmodels library. How to do it ? Is it advisable to do PCA using SKlearn and then doing regression in ...
1
vote
0answers
45 views

How to interpret feature importance in a decision tree after applying Factor Analysis

I'm using SKlearn to apply Factor Analysis (FA) to my data before training a Decision Tree. I then want to do an importance analysis. If I had not applied FA to my data, I could just call clf....
0
votes
0answers
8 views

SKlearn GBM feature importance or contributor after predictions [on hold]

I am using SKlearn GBM predictions for one of my exercises, and for understanding feature importance after fitting on train data, I can easily do it like this in python, since 'fit' method has those ...
7
votes
1answer
204 views

Linear regression minimising MAD in sklearn

The standard sklearn linear regression class finds an approximated linear relationship between variate and covariates that minimises the mean squared error (MSE). Specifically, let $N$ be the number ...
0
votes
1answer
25 views

Training data has more variables than test data

Given a train and test data that looks like the below: Im wondering if it is necessary to drip the id field in the training data if the id field is present in the test data. Also, if the test data ...
0
votes
0answers
9 views

sklearn gaussian process kernel optimization [on hold]

Is it possible to freeze a part of the kernel during optimization. Suppose I know that there is two simultaneous trend in the data - one major and one minor. I use linear kernel to model the linear ...
0
votes
2answers
40 views

How to use last predicted value as feature? NLP NER mission

I'm performing NER (Named entity recognition) For example: Seq: When Donald Trump announced... Tags: O B-Person L-Person O When I'm predicting ...
0
votes
0answers
13 views

RFE-RF for non-ordinal multi-class problem using integer target variable

For a classification problem with numerical predictors and a categorical multi-class response I am trying to use Recursive Feature Elimination with Random Forests to identfy relevant features out of a ...
0
votes
0answers
16 views

Applying boundary conditions and constraints to Gaussian process regression

When using Gaussian process regression (GPR) to predict $y$ over a domain, $x$, are there method(s) to impose particular conditions on the predictions? For example, if I know the prediction $y$ must ...
0
votes
0answers
20 views

Strange error in fitting classifier [migrated]

I'm working through O'Reilly's Hands-On Machine Learning with Scikit-Learn & Tensorflow. I'm working on training a classifier on the MNIST dataset and I'm getting the error ...
0
votes
2answers
31 views

Unsupervised Learning: Train Test division

I have one conceptual question. In Unsupervised Learning, when I have no labels. The anomaly detection model (Isolation forests, Autoencoders, Distance-based methods etc.), it should fit on a ...
0
votes
1answer
14 views

apply CountVectorized to whole data before applying train_test_split

Is there any difference between the two different snips of codes. ...
0
votes
0answers
13 views

R Equivalent to sklearn/TfidfVectorizer? [closed]

I want to create a document-term-matrix with tf-idf weighting in R. So far, I use the cast_dtm() function for this. In Python / sklearn, I can use the TfidfVectorizer from sklearn the following way: ...
0
votes
0answers
27 views

ML - Text input data

I'm trying to explore an use-case in ML but stuck at a point. May i please request your advise please. Have a service desk web application for logging tickets, which is essentially a form having ...
0
votes
1answer
12 views

Shrink decision tree by shuffling order of attributes

I made a decision tree that classifies mushrooms in the UCI Mushroom dataset as either poisonous or edible based on their features. The model has a 100% accuracy on both the training and test set. ...
0
votes
1answer
34 views

math behind polynomial regression

I am creating a polynomial regression model with Python sci kit learn package, and I was wondering how I can use the predict features in machine learning ...
0
votes
0answers
36 views

Feature Importance in Isolation Forest

In an unsupervised setting for higher-dimensional data (e.g. 10 variables (numerical and categorical), 5000 samples, ratio of anomalies likely 1% or below but unknown) I am able to fit the isolation ...
0
votes
1answer
28 views

Hyperparameter tuning using grid search/randomised search

I am conducting hyperparameter tuning for my XGBClassifier model for a multi-class classification problem using scikit-learn ...
1
vote
1answer
27 views

feature importance using forward selection

In the following article the author has correctly mentioned that the "petal" is more important than "sepal" in case of iris data: https://towardsdatascience.com/feature-importance-and-forward-...
0
votes
0answers
10 views

Why are there differences in recall values when I use GridSearchCV vs classification_report (scikit-learn)?

I'm currently working on a clasification problem through random forest. When I use GridSearchCV, using the parameter scoring="recall", the best_estimator_ is: ...
0
votes
0answers
10 views

Does it make sense to apply recursive feature elimination on one-hot encoded features?

Does it make sense to apply recursive feature elimination on a feature set pre-processed with One-Hot Encoding? This is my code for feature selection: ...
2
votes
1answer
36 views

Normalizing vs Scaling before PCA

I know there's a lot of content about PCA pre-processing, but I am still somewhat confused. I have a dataset that contains some clear patterns: 1 variable is whether a person has financial resources (...
0
votes
0answers
11 views

How to correctly plot the outputs of a recursive feature elimination algorithm?

I am a bit confused with understanding the parameter step of RFE and RFECV algorithms. This is how I run RFECV for multi-class classification problem (3 classes): <...
0
votes
0answers
6 views

Ensemble Scalability Challenges

Are there special challenges in scalability related to having an ensemble model rather than using a single classifier?
0
votes
1answer
11 views

alpha and cv_alpha parameters in sklearn.linear_model.LarsCV

Can someone explain alpha and cv_alpha parameters in sklearn.linear_model.LarsCV? I am guessing that alphas refer to maximum correlation at any given step between one of the remaining explanatory ...
0
votes
1answer
10 views

How splits are calculated in Decision tree regression in python

I'm using scikit-learn to build a decision tree (or a random forrest) for a regression problem. I have continuous variables as my regressors. I wonder to know how the splits in a regression decision ...
0
votes
0answers
12 views

LocalOutlierFactor scikit-learn

My goal is to use the LocalOutlierFactor class from scikit-learn to do real-time Novelty Detection. This can be achieved by setting novelty=True in the constructor, ...
0
votes
0answers
14 views

big difference between r squared in training and test data

I'm building a random forrest regression tree and use cross_validate function from scikit-learn with cv=3 I'm getting a huge ...
0
votes
0answers
29 views

Trouble understanding L1 and L2 cost function [duplicate]

When reading the Sklearn User Guide, one might see the following statement about Logistic Regression As an optimization problem, binary class L2 penalized logistic regression minimizes the ...
1
vote
0answers
42 views
+50

Accounting for errors in independent variable through Gaussian process regression

In Gaussian process regression (GPR), one applies a kernel (i.e. covariance function) to describe the similarity between observed and predicted data in the domain. The diagonal of the covariance ...
1
vote
0answers
44 views

Logistic Regression Just Predicts 1

I am a 10th grade student working on a science fair project that involves making predictions about adherence given patient data. I have separated the week into 21 time slots, three for each time of ...
0
votes
1answer
33 views

Adjusting probability threshold for sklearn's logistic regression model

I am a 10th grade student working on a binary classification problem and I have decided to use the logistic regression model from Scikit-Learn. I am looking to predict patient adherence given the time ...
1
vote
0answers
26 views

Does mutual information depend on the number of data points?

I am playing with mutual information in scikit-learn. ...
0
votes
1answer
12 views

In-sample evaluation with different classifiers

I've tested in-sample evaluation with different classifiers (Decision trees, Random Forests, Gaussian Naive Bayes) within sklearn and Iris datasets. ...
0
votes
1answer
20 views

Random Forest - Why does the value for doing the split change?

I created a random forest. When observing the trees that compose it in many of them the first variable to make the split is "age". But here my doubt arises. The values to make the split change. For ...
0
votes
1answer
16 views

Should the validation set have the same ratio in the categories as the whole data?

I'm currently working on a classification problem. The variable Y in 70% of cases is 0 and in 30% of cases is 1. Does my validation set have to have this same proportion? I ask because after using ...
0
votes
0answers
16 views

MultiTaskLasso vs. Lasso with dummies

I am trying to do a Lasso regression, where one of the features is a categorical string e.g. suppose we have Price,Year,Make for a car. One option would be to use one-hot encoding for Make, and do ...
2
votes
1answer
97 views

Scikit-Learn Gaussian Mixture: How can log-probabilities be positive? [closed]

I am fitting a Gaussian Mixture model: gm = GaussianMixture(n_components=K) gm.fit(features) When I do: ...
0
votes
1answer
21 views

Odd SVM output - Need explanation

I built a linear SVM model. My data has 105 subjects and 115 features, which I ordered from least important to most important. I iterated through them to find the f1-score with all 115 features, then ...
1
vote
1answer
55 views

linear regression predicts lower than expected

I am trying to predict first term GPA for college students based on a number of incoming factors (high school gpa, placement test, year). This isn't the overall model just a simpler one. The first ...
0
votes
1answer
124 views

Sklearn imputing the mean issue regarding historical api and json rest api

I am trying to make a prediction on a new dataset via LendingClub's rest api. I also have historical data from them which I am using to create the model. I have split the data into train/test sets ...
0
votes
2answers
41 views

Interpret reuslts of PLS regression coefficients

I have performed PLS regression using sklearn library (python 2.7) over three types of soil (PLS model per soil type) and I plotted the regression coefficients, but ...
0
votes
2answers
33 views

Random Forest Classifier with different depth for different features

I am using sklearn random forest to predict the probability of win/lose in a card game. There are 4 features in my data set. Can I set the depth of one feature to be 1 while the depth of other ...
1
vote
1answer
56 views

Spectral Clustering of a skipgram model

I have a model where I'm applying Spectral Clustering to frequencies of words. My pipeline consists in TF-IDF, followed by a <...
-1
votes
1answer
37 views

PCA influence of duplicates

I am using sklearn IPCA decomposition and surprised that if I delete duplicates from my dataset, the result differs from the "unclean" one. What is the reason? As I think, the variance is the same. ...
0
votes
1answer
10 views

Merging a few separately trained skikit-learn MLPRegressor models into one

I am thinking about parallel training a few MLPRegressor models using individual subset of training data (or maybe random selection from same test data) and then somehow "merge" individually trained ...
4
votes
3answers
97 views

Almost reverse feature importances by Extratrees vs RandomForest

I am using scikit-learn to find feature importances using ExtraTreesClassifier and RandomForestClassifier, both of which have feature_importances_ attribute. The data has 4 numeric predictors, 2 ...
0
votes
0answers
23 views

Time series forecasting with decision making

I want to do forecasting for wind power generation but the problem with it is that when the wind speed is below 4 m/s the power output is zero. RNN based models do best when these type of conditions ...
0
votes
1answer
15 views

How is it called when a MLR algorithm predicts a value beyond the range of the training data set and is there a way to avoid this for Neural Networks?

I use two Machine Learning Algorithms to learn how my target variable [0, 8] is affected by four features, each within a scale of [1, 10]. I am using scikit-learn to do this task for me. ...