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).

Filter by
Sorted by
Tagged with
0 votes
0 answers
22 views

Train sklearn model with different data types. (Float and list of Ints)

I need to train a Decision Tree model using sklearn fit function. The data is similar to the following one: min_out min_in max_out max_in mean_out mean_in \ 0 86 -76 1085 ...
polespinasa's user avatar
0 votes
0 answers
5 views

Issues with waterfall and bar plots in SHAP - Python

I'm trying to display waterfall plots for a binary classification problem. My code is the following: mod_choice = XGBClassifier(alpha=0.5, gamma=0.5, learning_rate=0.2, max_depth=5, n_estimators=50, ...
Giant Steps's user avatar
-2 votes
0 answers
16 views

Why sklearn Random Forest achieve higher accuracy with smaller max_features?

Fig 1 I can't understand why accuray peak when max_features = 1 I read the documentations on sklearn and found "Note: the search for a split does not stop until at least one valid partition of ...
Hải Long Nguyễn's user avatar
0 votes
0 answers
11 views

What methods of its last estimator does a scikit-learn pipeline have?

I'm trying to understand scikit-learn Pipelines. According to a Note in the scikit user guide a Pipeline "has all the methods that the last estimator in the pipeline has". So I wrote my own ...
Evan Aad's user avatar
  • 5,709
0 votes
2 answers
53 views

Error in grouping by month and calculating the average temperature of each month

I am preparing data in a python project using jupyter, pandas, and scikit-learn. I am trying to add monthly averages of the maximum temperature in the form of a new column. But whenever I use this ...
ShadowKnight's user avatar
-1 votes
0 answers
21 views

train_test_split alter the amount of row in scikit-learn [closed]

This is my code: #importing necessary modules import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression, LogisticRegression from sklearn.model_selection import ...
Amin Khormaei's user avatar
1 vote
1 answer
29 views

Issue with GMM predict_proba() sklearn function

I'm applying Gaussian Mixture Models (GMM) to a dataset of features with a size of [80, 1024], where 80 represents the batch size and 1024 is the dimensionality of the data. My goal is to cluster ...
External_Happy_77's user avatar
1 vote
0 answers
27 views

Autoencoder for dimension reduction did not produce expected results as PCA

I am trying use autoencoder for dimension reduction to reduce a tablulated data into 2 dimensions only. I simulated a data that should have five clusters. PCA analysis detected the clusters but ...
user498036's user avatar
0 votes
1 answer
48 views

ImportError: cannot import name 'plot_partial_dependence' from 'sklearn.inspection'

I am running sckitlearn 1.3 with the following code and get the following error: print(__doc__) import pandas as pd import matplotlib.pyplot as plt from sklearn.datasets import load_diabetes from ...
Wayne Thompson's user avatar
0 votes
0 answers
33 views

Expected 2D array, got 1D array instead using SciKit for image classification

I am trying to train a Gaussian Naive Bayes model using scikit-learn. My database contains 656 images along with labels from a csv file. Below is the code I used to both import the images + labels as ...
Ginger's user avatar
  • 1
0 votes
0 answers
18 views

Is there a way to transform both the data matrix and labels in a single pipeline before fitting a model in sklearn?

Suppose I have a data matrix X (numpy ndarray, all features are numeric) labels y (numpy array of string). I want to apply SimpleImputer(strategy='mean') and StandardScaler() to X, and ...
HARSHIL PANDEY's user avatar
-5 votes
3 answers
60 views

Unable to import python modules, despite having them properly installed [closed]

I cannot seem to figure out this issue. I have all modules properly installed, but they are not being recognized in VSCode. I have setup an environment. Error Messages Showing that packages were ...
Richard D's user avatar
0 votes
0 answers
27 views

Specifying to sklearn mplclassifier which category is the most important

I'm trying to make that estimate if the team will win or lose based on: ['team_id', 'nb_games', 'team_gamesPlayed', 'team_pergame_wins', 'team_pergame_losses', 'team_pergame_goals', 'win_game'] The ...
Vincent Coulombe's user avatar
0 votes
0 answers
18 views

How to Fix the Dimension Issues of features and classes from a Multilabel Classification dataset in getting the Out-of-Bag Error of a Random Forest?

I have created a multilabel classification dataset using make_multilabel_classification from scikit learn: from sklearn.datasets import make_multilabel_classification as mmc X, Y, p_c, p_w_c = mmc( ...
Ralph Henry's user avatar
0 votes
0 answers
17 views

Scikit-learn. Only positive Linear Regression with zero koeff

I'm trying to fit a linear regression model to find coefficients that must be strictly positive. Some of the coefficients turn to zero. How can this be avoided? I thought about normalizing values, but ...
KGB's user avatar
  • 1
0 votes
1 answer
24 views

Specify columns to be selected in parameter grid for GridSearchCV

I want to train models with certain sets of features as hyperparameters, using sklearn's GridSearchCV. An example parameter grid would be: [ { 'clf': [LogisticRegression()], '...
Amok's user avatar
  • 13
0 votes
0 answers
19 views

Error "Cannot use mean strategy with non-numeric data" in making column transformer

I'm doing Housing Price Prediction competition on Kaggle. When I'm dealing with data, there're missing values and categorical data. So I do preprocessing to everything but it doesn't work well. Let me ...
Neki's user avatar
  • 3
0 votes
1 answer
12 views

Label Encoding of Categorical values for Future df

I am building a model where LabelEncoding of 2 categorical columns is a better approach. So I had implemented the same on the train_df and finalized the model. And for predicting the test_df, I used ...
SM079's user avatar
  • 410
-2 votes
1 answer
35 views

find linear ascending pattern in set of data [closed]

I want to find a linear pattern in set of data, which are stored in list of tuples, for example: data = [ (1, 726), (2, 709), (3, 706), (4, 715), (5, 730), (6, 662), (7, 631), (8, 664), (9, 635), (...
mik.ro's user avatar
  • 4,409
1 vote
1 answer
33 views

Feature Selection using RFE Not Returning Correct Number of Features

I am creating a logistic regression model using python in jupyter notebook. I have reached the stage of doing Feature Selection using RFE. I specify 15 features, however, the code is outputting most/...
JacksonM's user avatar
0 votes
1 answer
32 views

Calculating Dice coefficient for image segmentatiom

I have created a function which calculates the Dice coefficient for the binary mask, however, I am not sure if I am doing it correctly: def dice_metrics(inputs, targets, smooth=1e-8): #inpts is the ...
KWKIM128's user avatar
-1 votes
1 answer
50 views

Why is my double underscore notation not working with nested pipelines in scikit-learn? [closed]

I'm trying to build a pipeline that contains a pre-processing transformer (it simply removes columns from the data) and an LDA classifier. I wanted to tweak hyperparameters for each, and from looking ...
Ted's user avatar
  • 1
3 votes
1 answer
47 views

"Warm Start" in combination with new data leads to broadcasting error when predicting with Random Forest

I am trying to train a random forest model with sklearn. I have some original data (x, y) that I use to train the RF initially with. from sklearn.ensemble import RandomForestClassifier import numpy as ...
Janosch's user avatar
  • 388
1 vote
1 answer
23 views

RFECV is starting over w/ original number of features

I'm trying to use RFECV to suggest the optimal number of features I should keep in X to predict y. My X is a dataframe with 121 variables (mix of dtypes, some continuous, some categorical) and my y is ...
Watson Gray's user avatar
0 votes
1 answer
24 views

How to calculate the sum of multiple confusion matrix in Python?

I have stored the results of 5 confusion matrix in an array. Now I have to calculate the sum of confusion matrix and then I want to use to calculate for True positive, False positive, False negative ...
Haseeb Tariq's user avatar
0 votes
0 answers
18 views

RuntimeWarning: invalid value warning sklearn GraphicalLassoCV

I keep encountering this RuntimeWarning: invalid value encountered in (subtract or multiple, or divide etc) when trying to run the sklearn GraphicalLassoCV model. I checked my dataframe to make sure ...
mlauber1999's user avatar
0 votes
0 answers
19 views

sklearn - kNN - KNeighborsClassifier - FutureWarning

I have a simple code for kNN model. It works well but I can't figure out how to solve the FutureWarning df = pd.read_csv('https://cf-courses-data.s3.us.cloud-object-storage.appdomain.cloud/...
user_n_8093's user avatar
0 votes
0 answers
39 views

Different sklearn Output: Teacher's vs. Mine - What Am I Missing? [closed]

In my ML class we've been taught about non linear reductions of data dimensionality. During the lecture we were using Jupyter notebook and the teacher and also I were executing this piece of code: ...
Infinity's user avatar
-2 votes
0 answers
12 views

Getting error as key error=5 on applying ReliefF

I am running this code for uci heart disease prediction using ReliefF technique along with Decision tree classifier. import pandas as pd from sklearn.model_selection import train_test_split from ...
sheldon cooper's user avatar
0 votes
0 answers
26 views

Combining minmaxscaler.partial_fit and joblib Parallel, n_samples_seen_ is not cumulate samples

I use multiprocessing to train a sklearn minmax scaler. I have a huge quantity of csv to take in consideration so I use .partial_fit. all seem to run well but at the end when I do some inspection of ...
Jonathan Roy's user avatar
0 votes
1 answer
25 views

KNN algorithm throws ValueError: Unknown label type: 'continuous'

import pandas as pd from sklearn.preprocessing import LabelEncoder import sklearn from sklearn.model_selection import train_test_split from sklearn.neighbors import KNeighborsClassifier from sklearn....
Akshay Basutkar's user avatar
-1 votes
0 answers
27 views

Issues with Random Forest Regression: Predictions Not Accurate [closed]

I am working on creating a machine learning model for a regression task. I have a dataset with three features, and I'm encountering some issues with my Random Forest Regression model. Here's what I've ...
kalai's user avatar
  • 1
0 votes
1 answer
36 views

Dockerfile to install scikit-learn on rasp pi hardware

How to make a Dockerfile for Raspbian hardware that can install scikit-learn? I haven't had any luck with debian-slim or Alpine Linux images. # Use a base image for Raspberry Pi with Alpine Linux FROM ...
bbartling's user avatar
  • 3,310
2 votes
0 answers
72 views

Why are linear discriminant analysis in SPSS and Python not giving me the same results for coefficients?

Although the data I'm feeding into both SPSS and Python is identical, I'm getting different scores for eigenvalues and canonical discriminant function coefficients while tests of equality of group ...
mdiramali's user avatar
0 votes
0 answers
32 views

Pipeline for Machine Learning Model has 'Feature shape mismatch' when trying to predict the target for a single observation

Here is the outline of my Machine Learning / Python project: Build a ColumnTransformer called preprocessor containing multiple transformers (e.g. One Hot Encoding, Ordinal Encoding etc) Build a ...
Zoe's user avatar
  • 35
0 votes
0 answers
32 views

Can Kernel Density Estimation be used to smooth 3D data?

I'm aware that KDE can be used to estimate the density of points in any number of dimensions. For example, if I use the sklearn implementation in python, I can simply feed in 3D data, fit the KDE ...
ThisRandomEngineer's user avatar
0 votes
0 answers
20 views

BinningProcess: error in binning_transform_params parameter with metric = bins

I would like to use BinningProcess to transform columns in a sklearn pipeline. However, I would like BinningProcess to return bins instead of the mean of the target variable to have meaningful bins ...
hexolitemax's user avatar
-2 votes
0 answers
48 views

Is this code correct for cross-validation with feature selection using SelectFromModel?

I am trying to perform cross-validation with feature selection using SelectFromModel in scikit-learn. I am using the following code: scaler = StandardScaler() X = scaler.fit_transform(X) specificity = ...
Aman 007's user avatar
-3 votes
0 answers
70 views

Faster algorithm to find if there are points within 1.5 km from house

I have a dataset contains about ten thousand latitude and longitude of house, and a dataset about one hundred thousand latitude and longitude of convenient stores. Firstly, I use brute force to find, ...
蔡承諺's user avatar
1 vote
3 answers
40 views

Why do my tf-idf values not appear consistent?

I have a series of tweets that I've converted to tokens. Among them are the following: geraldkutney happen realize happen conveniently rename catch yet emergency post fact come government ...
Daniel V's user avatar
  • 1,315
0 votes
1 answer
76 views

How to use SelectFromModel with cross_validate in scikit-learn?

I am trying to use SelectFromModel to select features from my dataset before training a DecisionTreeClassifier model. I am also using cross_validate to evaluate the model performance. However, I am ...
Aman 007's user avatar
-1 votes
0 answers
53 views

Why does Python scikitlearn OneHotEncoder say array dimensions are incorrect, but returns value error when I reshape it?

I am trying to use scikitlearn OneHotEncoder for an assignment. I define y as a column from a dataframe, in which each cell has the value either A B or C. Then I fit the encoder using X as below. y = ...
tfren99's user avatar
3 votes
2 answers
160 views

Average precision implementation for object detection - low confidence detections do not impact the score

I have the following code that calculates precision-recall curve for object detection task, where detections are matched to ground-truth first by creating 1-to-1 pairs starting from detection with the ...
Kuba_'s user avatar
  • 815
1 vote
1 answer
35 views

How to manually select features for Scikit-Learn model regression?

There are various methods for doing automated feature selection in Scikit-learn. E.g. my_feature_selector = SelectKBest(score_func=f_regression, k=3) my_feature_selector.fit_transform(X, y) The ...
Bill's user avatar
  • 10.4k
0 votes
1 answer
24 views

Stacking regression not initializing the estimator properly

A simple description of my machine learning pipeline: Dataframe has field that identifies which city the row belongs to Factory function initiates a random forest pipeline Custom stacking regressor ...
Jeffrey Ober's user avatar
0 votes
1 answer
27 views

Understanding BinningProcess output

I want to integrate optbinning.BinningProcess in my Pipeline but before, I need to understand the output. I was expecting bins after fit_transform but I obtained values close to my target variable. ...
hexolitemax's user avatar
0 votes
0 answers
18 views

Invalid parameter 'max_depth' for estimator GaussianProcessRegressor()

I am trying to develop an automated model which runs 5 algorithms, hyper tunes them and chooses the best based on mse ((Please note that this is to automate the estimation process such that whatever ...
Cpt_Spog's user avatar
0 votes
1 answer
56 views

Plotting ROC curve for different threshold values python

I am using MLP for audio classification. The following code is used to plot the ROC curve and obtain the optimal threshold values: # Compute ROC curve and ROC area for each class fpr = dict() tpr = ...
A. Gehani's user avatar
-1 votes
1 answer
32 views

How to use both string and float DataType in sklearn KNN .fit() method

I have a dataset which contains both string and float DataType and I want to train my KNN model with the dataset but it gives a ValueError saying could not covert string to float inputs=data.drop(['...
Akshay Basutkar's user avatar
0 votes
0 answers
10 views

ML Flow experiement remaining time?

I am fitting a imblearn pipeline using Random undersampler, Feature selector and MLPClassifier on my data in databricks. Is there a way to know how much time will it take for fit to complete? data ...
rushikesh maheshwari's user avatar

1
2 3 4 5
561