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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
7 views

How sklearn logistic regression computes accuracy, recall etc if we don't provide threshold?

It might be a stupid question, but I just realized that calling score function on logistic regression model shouldn't make any sense - as far as I know in sklearn ...
0 votes
0 answers
3 views

Multi output regression model with non categorical text data

I am doing a multioutput regression model where 1 input and 6 output. My dataset contain all non categorical text data. I used countvectorization in the preprocessing but got an error while fitting ...
0 votes
1 answer
9 views

StandardScaler and MinMaxScaler vs RobustScaler

I've recently read that Standard Scaler functions best in situations where the distribution of the features are approximately normal. MinMaxScaler works in a way that it preserves the features' ...
0 votes
0 answers
5 views

Combine several pyod model into one scikit learn pipeline

I recently discovered pyod for outlier detection in python. Many outlier detection algorithms are implemented in pyod, and the package also comes with several combination function to combine the ...
0 votes
0 answers
16 views

ValueError: Found input variables with inconsistent numbers of samples: [283, 943]

I am trying yo split the data using train_test_split(), but I got this error: ...
  • 1
0 votes
0 answers
14 views

How to split a LGBM.DataSet into trainning/validating/testing sets?

It looks like that LightGBM.train() can accept two arguments i.e. train_set and valid_sets, then it can do validating operations ...
  • 101
0 votes
1 answer
14 views

how to chose between these models?

i have a regression problem so i tried some regression models in order to pick the best one (based on RMSLE) here are the results: here are all the models = [ ('LR', LinearRegression()), ('Ridge', ...
  • 1
0 votes
1 answer
23 views

How Naive Bayes makes prediction based on scikit-learn?

I need to understand, how multinomial-naive-bayes can make prediction based on scikit-learn implementation. I saw the source code but I want to understand the math behind it. Could you please explain ...
1 vote
1 answer
25 views

Do you have to use clustering with SciKit-Learn's Mutual Information metric?

I'd like to calculate the mutual information between two datasets, but I'd prefer not to cluster them first. I'm thinking of using SciKit-Learn's mutual_info_score ...
  • 523
1 vote
2 answers
44 views

How to boost the performance of a single decision tree by adding additional trees?

I have a binary classification task and the data has imbalance issue (99% is negative and 1% is positive). I am able to build a decision tree that is carefully tuned, weighted, and post-pruned. Take ...
  • 11
0 votes
0 answers
9 views

Difference between Validation Error on Learning Curve and Validation Error Calculation in Machine Learning Model

I am encountering a problem where the validation error I see on the learning curve of my machine learning model is different from the validation error I calculate using the mean squared error function....
0 votes
0 answers
8 views

How to add query filter to the Nearest Neighbors algorithm?

I have Nearest Neighbors model, built with sklearn sklearn.neighbors.NearestNeighbors, which I use to make content based recommendations. Sometimes I need to ...
  • 101
0 votes
0 answers
24 views

SequentialFeatureSelector and scoring for clustering

I want to use SequentialFeatureSelector from scikit-learn to do feature selection for clustering (K-Means). [Here][1] is a list of available evaluation scores for clustering. What I do not understand ...
0 votes
1 answer
23 views

using a feature that is only available during training

I'm working on a project that aims to classify JIRA issues into their relevant owner group. An issue has the following text features: Summary Description Comments all of which are text based. During ...
  • 167
1 vote
3 answers
66 views

What's the fastest clustering package in Python?

I'd like to perform clustering analysis on a dataset with 1,300 columns and 500,000 rows. I've seen that clustering algorithms are available in SciKit-Learn. But I'm worried that the algorithms will ...
  • 523
0 votes
0 answers
44 views

Sklearn predicts different results depending on the input length

Here is the problem: I fitted a Random Forest Classifier and saved it to a pickle file. However, when I predict with the entire dataset I get one result, and when run predict line by line (loop) I get ...
  • 1
0 votes
0 answers
18 views

passing pandas dataframe to function, but it appears as numpy array

In the function I call sklearn train_test_split In Pycharm debugger everything looks ok until it gets to that call. Then it backtracks and tells me ...
0 votes
0 answers
16 views

Teaching the model on more than one dataframe/dataset

I am trying to write a thesis on oil pipe leakage detection. The aim is to predict the size and location of the leak. My problem is that I can only run single simulations using a software called OLGA ...
0 votes
0 answers
27 views

Can BM25 be used as an embedding algorithm?

I'v studied about BM25 algorithm. Untill now, I couldn't find an implementation of BM25 to give me an embedding of a text like TfidfTransformer and ...
0 votes
1 answer
18 views

What else can I do to help my model my classification task?

I have a classification task that I'm currently getting really low accuracy metrics on (my highest accuracy score is about 20%). So far I've run 5 models: quadratic disc analysis, logistic regression, ...
0 votes
1 answer
40 views

Tuned model has higher CV accuracy, but a lower test accuracy. Should I use the tuned or untuned model?

I am working on a classification problem using Sci Kit Learn and am confused on how to properly tune hyper parameters to get the "best" model. Before any tuning, my logistic regression ...
0 votes
2 answers
39 views

I am getting all scores as 100% on my machine learning models. Is it okay to have this kind of result?

I am getting all scores for my ML model as 100% for the Extra Trees Algorithm. I am applying the necessary pre-processing steps (duplication removal, correlations validating, cardinality validation, ...
0 votes
0 answers
46 views

Do we need to check the training score when we use randomizedsearchcv

given a model and a set of parameters, randomizedsearchCV(or gridsearchCV) gives the mean of the best scores from a list of different folds of the datasets. Does the model control for overfitting? I ...
0 votes
1 answer
38 views

how do I test if overfitting exists when I use cross_val_score method?

I got the following code form a book on xgboost. I wonder whether this is a correct way of analyzing cross validation score for overfitting purposes. mean accuracy is 81 which can be okay. but what if ...
0 votes
1 answer
26 views

How can I be more certain that I have not accidentally made my ML model predict on training data?

I have this random forest model setup as shown below in python. It's performing unexpectedly well with a ~70% classification success rate (to the extent where I really doubt it is genuine) and I am ...
0 votes
1 answer
31 views

Ugly AUC curves. Sklearn. How to make AUC Curves less square

I dislike the square look of this AUC curve (SKLearn). The purpose of this question is "visual". Please post code snippets. This question is not requesting the theory behind the AUC. My goal ...
1 vote
1 answer
21 views

How to determine which combinations of parameters to include in GridSearchCV

I am using MLPClassifier from sklearn and I would like to tune it with GridSearchCV. But I don't know which set of values to include for hidden_layer_sizes, max_iter, activation, solver, etc. How can ...
  • 11
0 votes
1 answer
14 views

Maximum categories for categorical variables in K-Means clustering

I am trying to perform K-means clustering on a dataset, and one of my categorical features has 96 possible options. Would this be too many features for one variable to have? The alternative would be ...
  • 101
4 votes
3 answers
90 views

Imputation of missing values based on target variable

I want to impute missing values in German Credit Risk dataset. ...
  • 61
2 votes
1 answer
30 views

Surrogate splits in Python

I want to use RandomForestClassifier from Sklearn to predict categorical variable (credit risk). But one of the predictors seems to have missing values: ...
  • 61
1 vote
1 answer
35 views

Can I use a fitted polynomial regression to make reverse predictions?

I want to start off by acknowledging that this may be a dumb-sounding question to someone with more machine learning experience to me, so please go easy. Here is the background. I am currently an ...
3 votes
1 answer
137 views

Does OpenAI and ChatGPT use Scikit Learn?

Scikit Learn is Python's go-to open source package for running common AI and machine learning algorithms. Does OpenAI and its product ChatGPT use or rely on Scikit Learn on its back-end at all? If not,...
1 vote
0 answers
69 views

ValueError: Found input variables with inconsistent numbers of samples: [120, 30]

I practice XGBClassifier() to predict the target in iris dataset. here is the code: ...
0 votes
0 answers
13 views

Ordinal Encoding for Differing Categories

As an example, I have a dataset of available games. ...
  • 1
0 votes
0 answers
13 views

How to make a predictive model using a timeseries data consisted of binary information?

I have a set of data that is showing the state of an object as a function of time. I would like to know what and how I should be utilizing machine learning to predict the state of the object at some ...
  • 101
0 votes
1 answer
47 views

high degree polynomial model with sklearn does not fit

The idea was to gradually raise the degree of the polynomial. Here is the code that implements creating a random dataset, fitting the polynomial of the CHANGE_ME ...
0 votes
0 answers
21 views

Classifier calibration leading to worse outcome

I am trying to calibrate some classifiers to output more accurate probabilities. For this, I am using a sigmoid regression as implemented in ...
  • 23
0 votes
1 answer
21 views

Get multiple predictions from a knn model

I want to my code to return multiple(5) predictions from my trained knn model. I've tried using predict_proba() but it just returns the probabilities and not the names Here is my code: ...
0 votes
0 answers
18 views

sklearn.model_selection cross_validate accuracy parameter of score set to NAN

Problem On sklearn.model_selection import cross_validate the accuracy parameter of score set to NAN. working with score_metrics to collect all accuracy and error measures from cross_validate, sklearn. ...
0 votes
0 answers
22 views

How to structure dataframe combinations for regression, without corruption/loss?

I have a data set, redacted sample below. My goal is linear regression. My question is: Have I created unintended results, due to how I structured the df, using concat and/or div? For example, ...
0 votes
0 answers
13 views

Sklearn pipelines, applying transformations to feature engineered columns in previous steps

I am working on a sklearn pipeline for my binary classification problem. The pipeline should perform typical things like downcasting data types, scaling numerical values, one-hot and ordinal encoding ...
0 votes
1 answer
17 views

problem with imputing in sklearn

I have used SimpleImputer() to fill the missing values my_imputer = SimpleImputer() data_with_imputed_values = my_imputer.fit_transform(train_data) what I expect ...
0 votes
1 answer
17 views

What is Auto-Sklearn Dummy Model?

When I apply AutoSklearn for some datasets I get this error No models better than random - using Dummy Score What does it mean? what is this Dummy Model? How does ...
  • 517
1 vote
2 answers
54 views

problem with standardScaler

problem with standardScaler hi I'd like to scale one column in the titanic data set. I am using the following code segment. for some reason df_scaled results an empty set. how can I solve it? what is ...
0 votes
0 answers
26 views

Multi-label predictive modeling using Naive Bayes

I'm working on a predictive model that currently uses scikit-learn's Naive Bayes (testing with both Bernoulli and Gaussian) but I'm running into some trouble. First I have a large dataset of records (...
1 vote
0 answers
48 views

scikit learn logistic regression to annotate single cell RNA seq data

I want to use scikit learn logistic regression to train a model on a labelled single cell RNA sample and subsequently apply this model on new unlabelled single cell RNA seq samples to annotate the ...
0 votes
0 answers
44 views

Building recursive forecasting from scratch?

I am currently testing time-series modelling with tree-based (xgb, lgbm, cat) algorithms using, recursive lags of a y (sales) along with with numerous exogenous regressors i.e. date-time, price, ...
  • 101
1 vote
0 answers
10 views

Boosting the effect of some of the features in SVM

I'm doing text classification with SVM. I'm using Tfidf vectorization. In addition to the text vectors, I have a context data denoting the possible outcomes of the prediction. For example, I have a ...
0 votes
1 answer
29 views

DecisionTreeClassifier cannot take one-hot encoded classes?

I got ValueError: Found array with dim 3. None expected <= 2. I dont know which array has dim 3? DecisionTreeClassifier cannot take one-hot encoded classes? But ...
0 votes
0 answers
25 views

What is the difference between nmf.fit() nmf.fit_transform() in a easy way?

I am reading several questions on this topic. It seems quite clear to me for TFIDF why we have .fit_transform() and .transform() ...

1
2 3 4 5
46