Questions tagged [scikit-learn]

scikit-learn is a popular machine learning package for Python that has simple and efficient tools for predictive data analysis. Topics include classification, regression, clustering, dimensionality reduction, model selection, and preprocessing.

583 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
7 votes
4 answers
4k views

How to perform feature selection on dataset with categorical and numerical features?

I am working on a dataset with 30 columns (29 numerical, 1 non-ordinal categorical). I hot-encoded the categorical feature and reached at 35 columns. To improve training efficiency, I want to perform ...
Songyu Yan's user avatar
6 votes
2 answers
95 views

How sklearn SVM find the initial hyperplane before Optimisation?

The optimization goal of the SVM is to maximize the distance between the positive and negative hyperplanes. But before optimizing, how does sklearn first find the positive and negative support vectors ...
user3363813's user avatar
6 votes
2 answers
3k views

How to deal with missing data for Bernoulli Naive Bayes?

I am dealing with a dataset of categorical data that looks like this: ...
Chuck's user avatar
  • 161
6 votes
2 answers
187 views

Gridsearch XGBoost for ensemble. Do I include first-level prediction matrix of base learners in train set?

I'm not quite sure how I should go about tuning xgboost before I use it as a meta-learner in ensemble learning. Should I include the prediction matrix (ie. df containing columns of prediction results ...
doyz's user avatar
  • 161
6 votes
0 answers
3k views

How to tune weights in Voting Classifier (Sklearn)

I am trying to do the following: ...
Abhinav Gupta's user avatar
6 votes
0 answers
12k views

Tuning Gradient Boosted Classifier's hyperparametrs and balancing it

I am not sure if it is a correct stack. Maybe I should have put my question into crossvalidated. Nevertheless, I perform following steps to tune the hyperparameters for a gradient boosting model: ...
user1877600's user avatar
6 votes
3 answers
314 views

Anomaly detection using clustering of highly correlated Categorical data

My data has two columns and both are highly correlated e.g. if column1 has value ABC, column2 should be XYZ i.e. ABC-->XYZ. If column2 has anything else it's Anomaly. Likewise, there are thousands ...
viral kapadia's user avatar
6 votes
1 answer
3k views

How does XGBoost compute the probabilities in predict_proba()?

I'm using the sklearn wrapper for XGBoost. I didn't manage to find a clear explanation for the way the probabilities given as output by predict_proba() are computed....
keren42's user avatar
  • 61
5 votes
0 answers
753 views

sklearn FutureWarning message when running a CNN model

When I run my model, I am receiving the following error message: ...
Jack's user avatar
  • 145
4 votes
0 answers
56 views

Does ROC AUC different between crossval and test set indicate overfitting or other problem?

I am training a composite model (XGBoost, Linear Regression, and RandomForest) to predict injured people probability. Well, the results of cross-validation with 5 folds. Well, I can see any problem ...
GregOliveira's user avatar
4 votes
1 answer
58 views

Spatially constrained geospatial similarity

What's the current methodology for clustering geospatial data by features? Example: I have some demographic dataset. Let's say this contains average home price and population density. So, an example ...
Overflow2341313's user avatar
4 votes
1 answer
857 views

Scikit-learn average_precision_score() vs. auc score of precision_recall_curve()

I've been searching around for an explanation to this, and haven't come across one yet- in scikit-learn, when I compute the auc() of the ...
sarahwie's user avatar
4 votes
1 answer
2k views

Which algorithm is used in sklearn SGDClassifier when modified huber loss is used?

The documentation says: The loss function to be used. Defaults to ‘hinge’, which gives a linear SVM. The ‘log’ loss gives logistic regression, a probabilistic classifier. ‘modified_huber’ is ...
Vikk's user avatar
  • 141
4 votes
2 answers
1k views

Can I do incremental learning with the sklearn implementation of Linear Discriminant Analysis

I have a large number of pictures that I would like to use LDA on. However, it requires too much memory, so I was wondering if it would be possible to make the learning incremental, using a sklearn ...
Afou Lazyboy's user avatar
4 votes
1 answer
946 views

What preprocessing steps to be followed before image comparison?

1 down vote favorite For example I am trying to find the similarity between two images using skimage - SSIM. The code block will be as follows ...
Vivek Srinivasan's user avatar
3 votes
1 answer
129 views

Issues with self-implemented logistic regression

I am trying to self-implement a logistic regression algorithm to do some self-learning but I am having a bit of trouble with achieving similar accuracy to the logistic regression of sklearn. Here is ...
Steve Ahlswede's user avatar
3 votes
0 answers
130 views

Initial value space for Random Forest hyperparameter tuning

I'm building a Random Forest Classifier using Scikit Learn. My problem consists in a 4 class classification task, the values are distributed as follows (after splitting my data in training set and ...
Mattia Surricchio's user avatar
3 votes
1 answer
39 views

Text vectorizer that capture feature offset in the text?

I'm using sklearn Tfifdfvectorizer to extract feature from text towards text classification. I believe the information I need tends to be in the beginning of the document, so I would like to somehow ...
R Sorek's user avatar
  • 53
3 votes
0 answers
42 views

Gaussian process regressor returns almost identical std for all datapoints

I am using a Gaussian process regressor as the regressor for active learning and I use its standard deviation to choose the next training inctance (the one with the highest std is chosen). However, ...
Ash's user avatar
  • 51
3 votes
1 answer
522 views

Gaussian Naive Bayes (GaussianNB) classifier not working with large number of features

I'm trying to make a partial fitting with GuassianNB here's small snippet of my code ...
Dia Abujaber's user avatar
3 votes
1 answer
1k views

Expected 2D array, got scalar array instead: array=11

...
user avatar
3 votes
1 answer
2k views

Why does classifier chain ask for at least 2 classes, when I have it

I'm using Classifier Chain with logistic regression and when i try to use fit, i get This solver needs samples of at least 2 classes in the data, but the data contains only one class: 1 but I'm ...
ronald reagan's user avatar
3 votes
0 answers
1k views

How to add control variable in regression using sklearn

I am trying to perform controlled regression using sklearn, I have been using sklearn for fitting dependent variable and independent variable, however, if there is a variable that I want to control ...
Jibin Mathew's user avatar
3 votes
0 answers
392 views

PCA and FastICA in scikit-learn giving near identical results

So after importing my data, transforming it, and splitting into training and test sets I tried running this script for PCA: ...
Jon M's user avatar
  • 31
3 votes
2 answers
1k views

Large sparse dataset in Catboost

I have a large sparse data matrix (bag of words, over large number of entries). I can easily treat it as a sparse matrix in sklearn models such as ...
Mojtaba Komeili's user avatar
3 votes
0 answers
2k views

why the accuracy of LDA model is always changing and also is high

Let’s explain the whole goal firstly, then go through the question. I am using topic modeling like LAtent Dirichlet Allocation and NMF to extract the topic from a collection of documents. My dataset ...
Maria's user avatar
  • 321
3 votes
1 answer
2k views

IsolationForest Decision Function vs. Anomaly Prediction Question

I'm currently working on an unsupervised anomaly detection project, and for it I'm using IsolationForest through scikit-learn. My question is, why/how is it possible for the model to predict something ...
kdavid2's user avatar
  • 41
3 votes
0 answers
1k views

Fuzzy Rules with more than two variable in python

I am trying to build a fuzzy inference system in Python using skfuzzy library. I have 4 variables depending on which output class is decided. ...
maggs's user avatar
  • 345
2 votes
1 answer
382 views

Dummy Variable trap in Linear Regression

The dummy variable trap is a common problem with linear regression when dealing with categorical variables, since one hot encoding introduces redundancy, so if we have m categories in our categorical ...
AAA's user avatar
  • 35
2 votes
0 answers
78 views

Feature selection and model performance

Featuretools provides an automated way to generate features from your data, by providing relationships within your data and applying their so-called deep feature synthesis. It generates features like ...
holzben's user avatar
  • 121
2 votes
0 answers
342 views

random_state on train_test_split() appears to have large effect in performance metrics?

To summarize the problem: I have a data set with ~1450 samples, 19 features and a binary outcome where classes are fairly balanced (0.51 to 0.49). I split the data into a train set and a test set ...
jlnsci's user avatar
  • 31
2 votes
0 answers
76 views

Association between categorical variables with no hierarchy in Python

I have a dataset with over 100 possible variable occurrences across 20 columns. At first glance this problem seemed to fit into hierarchical clustering. I started testing with Agglomerative Clustering,...
jtoepp's user avatar
  • 21
2 votes
1 answer
160 views

Not able to encode multiple categorical columns at once

I have written the following code for encoding categorical features of the dataframe( named 't') - ...
Sumit Jha's user avatar
2 votes
1 answer
44 views

How to build regression model on residuals

Let's say you have a good-performing regression model, but the end result is not just yet there. One of the ideas, I came across to improve model performance is to build a second model using the first ...
Simon Adams's user avatar
2 votes
1 answer
178 views

How do I use wavelet transform for feature extraction correctly?

I'm trying to classify words based on EMG signals using a support vector machine as my model. My dataset includes 15 classes (words) with 230 repetitions and 1000 features each. I already merged all ...
Rose's user avatar
  • 21
2 votes
1 answer
2k views

Plotting confusion matrix for multi classification problem

I am using google colab to solve a multi-classification problem. I am trying to plot the confusion matrix for this problem, I have tried doing so using : ...
AAA's user avatar
  • 145
2 votes
0 answers
264 views

Why RandomForestClassifier doesn't have cost_complexity_pruning_path method?

In trying to prevent my Random Forest model from overfitting on the training dataset, I looked at the ccp_alpha parameter. I do notice that it is possible to tune ...
hotuagia's user avatar
2 votes
0 answers
212 views

Understanding an MLP coefficient array

I have implemented a super simple MLP using SKLearn. I have a 2 hidden layer model and 31 features on the input layer. So the lengths of the arays are 31, 20 and 10. ...
kikee122's user avatar
2 votes
1 answer
959 views

How to identify/recognize that a sentence about talks about future?

Brief Introduction: I have a report/paragraph in which there are sentences with reference to future plans/outlooks/expectations for a particular entity. I want to extract all such sentences for now. ...
Krs's user avatar
  • 21
2 votes
0 answers
39 views

Multidimensional scaling (MDS) fails on a simple example

I want to apply multi-dimensional scaling (MDS) on specific objects; using the Euclidean distance does not make sense for such objects; using another distance metric, I can compute their dissimilarity ...
user11634's user avatar
2 votes
0 answers
1k views

How to pick best model based on Accuracy and Recall in a GridSearchCV when you have already set scoring = custom_scorer?

This is a binary classification problem, I am using a GridSearchCV from Sklearn to find the best model, here is the GridSearch line I am using: ...
SpaceSloth's user avatar
2 votes
0 answers
30 views

What would be a good randomization environment for data science?

I would like to know if there are any best practices to optimize random environment. Currently I use this simple structure in my config : ...
Al_P's user avatar
  • 21
2 votes
0 answers
168 views

Apply error analysis on the iris dataset for a specific type of misclassification

Suppose that I have the well-known iris dataset and I want to perform error analysis on the misclassified examples, more specifically for a specific class. I don't ...
thanasissdr's user avatar
2 votes
2 answers
989 views

How can the labels of AgglomerativeClustering be re-computed?

I am using scikit-learn's AgglomerativeClustering on a large data set. I would like to modify the distance_threshold after the model has already been computed. ...
UTF-8's user avatar
  • 21
2 votes
0 answers
31 views

Methods of de-emphasizing some dimensions in a cluster analysis

I'm trying to understand how "weightings" on different dimensions in a cluster analysis might relate to the range of values along a given dimension in the dataset. DATA SET List of 1,000 to ...
deseosuho's user avatar
  • 121
2 votes
0 answers
2k views

How to interpret my logistic regression result?

I'm having a hard time to interpret my result of the logistic regression. I have a few question. Firstly, how can I check if a feature is more important to the others, like that there is a real ...
grumpyp's user avatar
  • 157
2 votes
2 answers
1k views

How to decode encoded labels in Decision tree classifier

I have some dataset with procurements of organization where actually i'm working. The aim is to find most important features that describe why some processes of purchases is succesful, and why not ...
O.Sartaev's user avatar
2 votes
1 answer
232 views

what does the standard deviation plot around my learning curve indicate?

I plotted a learning curve below. There is a thick red band around the top portion of my training score. Why is it so high at the beginning? Below is a snippet of the code used: ...
Maths12's user avatar
  • 496
2 votes
0 answers
123 views

Genetic Programming Python library with a Scikit-Learn inspired API

I've been working with GPlearn for the passed couple of months as part of my research, but it turns out that it provides only a binary symbolic classifier. Do you guys know any other python library ...
JojoHalastra's user avatar
2 votes
0 answers
216 views

How to Ensemble LGBM and XGBoost Machine Learning Models?

I want to Ensemble my predictions for the StratifiedKFold of LGBM and XGBoost into another LGBM Model. I had written the following code which works when the data set has an ID_COL, but in this data ...
Ishan Dutta's user avatar

1
2 3 4 5
12