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
0 answers
7 views

Is it possible to extract precise decision boundaries from a random forest for a multiclass classification?

I have a random forest (argmax post-processor) with 3 trees and 10 input features. The final outcome of the random forest is either true or false depending on the combination of the feature values. Is ...
user avatar
0 votes
1 answer
16 views

What's more important - accuracy on training or accuracy on cross validation?

I optimized a knn algorithm in sklearn with a grid search. However, my accuracy on the training data decreased 1% while my cross validation accuracy increased 0.7%. Is the model better after the grid ...
user avatar
0 votes
0 answers
11 views

LightGBM Price Prediction always INF but RMSE 0.19

I have a real state dataset from Belgium: https://raw.githubusercontent.com/Joffreybvn/real-estate-data-analysis/master/data/clean/belgium_real_estate.csv And I want to use LightGBM for price ...
user avatar
0 votes
1 answer
17 views

Using 'Mlxtend' with 'TensorFlow' or 'Pytorch'

Is it possible to create a simple stacking implementation for regression with 'Mlxtend' using models created by 'TensorFlow' or 'Pytorch' however the documentation only supports examples that contain '...
user avatar
1 vote
2 answers
15 views

What is the role of epoch in this Geron's code?

I am reading Hands-On ML 2nd Edition. In page 142 there is the following code as an example of Early Stopping: ...
user avatar
0 votes
1 answer
25 views

Denoising in ML Pipeline

Say I split my raw data into train and test sets. Should I clean them first and denoise the datasets before I start creating new features or, should I create new features for both the train and test ...
user avatar
0 votes
1 answer
48 views

Optimize a non-linear function in Python

I am trying to optimize a function using scipy.optimize, but it does not converge. I have a trading strategy with a default stop-loss based on the lowest price over 20 days. I want to optimize this ...
user avatar
0 votes
0 answers
12 views

What is this method of feature selection called, is it a good idea, and if so how might I implement it?

I hope you don't mind me asking a few questions in one - they're all related somewhat. I'm working on a simple classification problem (Titanic, you guessed it) and I'm trying to grind out the last ...
user avatar
0 votes
1 answer
15 views

Time Series Data Imputation

I am studying time series analysis to apply on a new project. Well, I am confronting a dilemma that I need some help. When I read an old version of ggplot2 book (https://ggplot2-book.org/), I guess ...
user avatar
2 votes
1 answer
26 views

How to build single pipeline with multiple estimators supporting fit and predict?

I have a ML problem where I want to divide the prediction task into subproblems (where I believe specialized models will do better). All these predictions tasks operate independently and will use the ...
user avatar
1 vote
1 answer
23 views

Getting equal distributions of data from different input sets

I am new to ML. I am trying to create a training dataset that is equally distributed between multiple lists, each of which have a different kind of data. How can I do this? I looked into ...
user avatar
0 votes
0 answers
14 views

Improving f1 score in an image dataset

I'm having troubles trying to improve the f1 score of my model. Here is the code: ...
user avatar
0 votes
0 answers
12 views

Feature selection with GridsearchCV [migrated]

I am trying to use GridSearchCV to optimize a pipeline that does feature selection in the beginning and classification using KNN at the end. I have fitted the model using my data set but when I see ...
user avatar
0 votes
0 answers
15 views

Can calibrated probabilities in binary classification problem be used to reliably calculate metrics such as sensitivity, specificity, f1-score?

After using Beta Calibration on the probability predictions output by a Random Forest, I get a list of calibrated probabilities like: ...
user avatar
  • 1
0 votes
0 answers
25 views

How to improve validation score

I am working on time series classification. My data has 4 classes. I used this paper's architecture on my data (1611.06455). However, my results look like this : . Here is a link to my notebook I ...
user avatar
1 vote
1 answer
29 views

How do I specify encoding in scikit-learn OrdinalEncoder?

Scikit-learn object OrdinalEncoder() allows the user to create a lineary based encoding principle for ordinal data, however the the codes are encoded randomly. Is there any way I can specify how the ...
user avatar
  • 11
1 vote
1 answer
22 views

Found input variables with inconsistent numbers of samples: [908, 9080]

I have a dataset, I have reconfigured my tensors as a single 3072 sized line array. I have reconfigured the valid dataset and training dataset. You can find all of the information about my train, ...
user avatar
  • 11
0 votes
0 answers
15 views

Understanding Isolation Forest predictions

I'm running sklearn's IsolationForest on a dataset containing 2 classes of data, one that I know is the anomaly (~1.5% of the entire dataset), the other is the normal dataset. I'm using this (shuffled)...
user avatar
  • 111
0 votes
1 answer
20 views

LinearSVC training time with CountVectorizer and HashingVectorizer

I am currently trying to build a text classifier and I am experimenting with different settings. Specifically, I am extracting my features with a CountVectorizer ...
user avatar
1 vote
1 answer
21 views

Feature Engineer each class separately in Binary Classification

I have an imbalanced tabular dataset, my problem is a binary classification. The dataset is strongly imbalanced so I have performed oversampling, but it did not solve the issue, you can find the ...
user avatar
0 votes
0 answers
17 views

Prediction intervals is the correct way for upper bound prediction?

I was tasked with a relatively straightforward problem at work: Given an already preprocessed training dataframe X and its corresponding target vector y, find the estimated upper bound in performance ...
user avatar
0 votes
0 answers
8 views

Most common transformations in an sklearn pipeline?

I'm wondering if there is a list anywhere of the most commonly used transformations that people use in a machine learning pipeline - particularly in Python and scikit-learn. Additionally, are there ...
user avatar
0 votes
0 answers
28 views

Low F1-Score due to Imbalanced Dataset even after resampling

I am performing a Binary Classification over an imbalanced dataset: 0: 16,263 1: 214 I have used multiple oversampling, undersampling, and combination techniques, below are the results that I have ...
user avatar
0 votes
0 answers
11 views

Time required for training the random forest classifier with RandomizedSearchCV

I added the below param_grid to the model for RandomizedSearchCV for RandomForestClassifier ...
user avatar
2 votes
2 answers
86 views

Binary Classification with Very Small Dataset (<40 samples)

I'm trying to perform binary classification on a very small dataset, consisting of 3 negative samples and 36 positive samples. I've been testing different models from scikit-learn (logistic regression,...
user avatar
  • 23
2 votes
1 answer
132 views

Why XGboost does not work on small dataset

Here I am using Xgboost for classification for a simple small dataset, when x = 0 then y = 1 elif x = 1 then y = 0. Then I use the xgb.XGBClassifier() but the resulting probability is just 0.5. I ...
user avatar
0 votes
0 answers
11 views

Question about PCA application in Random Forest

I have a dataset with more than 100 columns(features) and I am using RandomForest classifier to train it. I am applying PCA to reduce dimension. Result seems pretty good with ...
user avatar
0 votes
1 answer
18 views

SkLearn DecisionTree doesn't include numerical variables after one hot encoding pipeline

I'm trying to fit a dataframe with SkLearn DecisionTree with the following code. But I get a error Length of feature_names, 9 does not match number of features, 8. ...
user avatar
2 votes
1 answer
45 views

Some classes are not present in test set after train-test split

I have a dataset with 3075 unique classes (they represent rubric IDs that can be assigned to an order to categorize it into this or that rubric). Some rubrics were only assigned once meaning that ...
user avatar
  • 121
0 votes
1 answer
21 views

Voting Regression models, other approaches than averaging the results from each estimators

In a regression problem that I'm currently working on, it seems that my model is doing well on higher values but significantly worse on lower values (e.g. values from 100,000,000 to 105,000,000 are ...
user avatar
  • 3
0 votes
0 answers
8 views

Trying to bootstrap code from another script i build using one-hot-encodeing, this time i don't need to encode

I have a code bit that i'm trying to duplicate except for my matches being encoded I just have a binary 0 or 1 for my data in the field that is to be indexed. If i substitute 1 or 0 for the "...
user avatar
0 votes
0 answers
6 views

Can label encoder be used to deal with unordered category variables?

Many people say that one hot should be used to deal with unordered category variables, but I see that there is a high praise project on kaggle, which directly uses label encoder to deal with unordered ...
user avatar
0 votes
0 answers
5 views

SciKitLearn - Powerlifting Placing Predictor Recommended Models?

I am new to data science and working on a project utilizing the openpowerlifting database to create a machine learning model to predict what someone would place in a local powerlifting competition, ...
user avatar
0 votes
0 answers
8 views

Using variable bandwidths in a KDE estimate

I'm working with geospatial data that is pretty irregularly spaced, but I have a length scale estimate for the spacing in the samples so in principle I have a "bandwidth" for every data ...
user avatar
  • 111
0 votes
1 answer
9 views

How to Scale target feature

How should I scale target feature? Should I use scaler as fit_transform on y_train, and just fit on y_test to avoid leaking data?
user avatar
1 vote
0 answers
19 views

Random Forest Generating Bad Predictions: What might the issue be?

I'm using sklearn's RandomForestRegressor to try and model a relationship that involves three Feature variables (x1,x2,x3) and ...
user avatar
1 vote
0 answers
16 views

What's the difference between micro-averaged precision and accuracy score?

I'm using sklearn's metrics module to try and evaluate a k-NN model's performance on the provided iris dataset from the ...
user avatar
0 votes
0 answers
18 views

Using scipy.optimize.curve_fit for Non-Linear, Multi-Variate Models

Warning: ML Noob. I have a 3D dataset (data at the bottom) with 2 feature variables and 1 target variable. Polynomial Regression produced unsatisfactory results and it seems that the relationship of ...
user avatar
0 votes
0 answers
15 views

What are the differences between uniform and normal QuantileTransformer Normalizer?

In sklearn.preprocessing package there are QuantileTransformer(output_distribution="uniform") and ...
user avatar
  • 33
1 vote
0 answers
36 views

Best Strategy for predicting a Calendar with daily routines

I have a data-sheet with calendar entries of a single person which consists out of every-day routines such as sleeping, eating, working, body care, ... In total, there are about 40 different ...
user avatar
  • 111
0 votes
1 answer
20 views

OCR with grouped text based on solid rectangles

I can read text from an image using OCR. However, it works line by line. I want to now group text based on solid lines surrounding the text. For example, consider I have below rectangle banners. I can ...
user avatar
  • 101
0 votes
2 answers
35 views

What mean a column in zero in confusion matrix?

When training my model and reviewing the confusion matrix, there are completely zero columns for each specific category, what does this mean, is there an error or how do I interpret it? I use the ...
user avatar
0 votes
0 answers
23 views

Is it a right way to score the importance of categorical features against categorical targets using ANOVA?

I know that f_classif method is mostly used for scoring numerical features and categorical targets. But I'm wondering if it's possible to score features coded by integers or binary codes against ...
user avatar
  • 101
0 votes
0 answers
125 views

Evaluate multiple Isolation Forest estimators during GridSearchCV with custom scorer function

I have a sample of values that don't have a y target value. Actually, the X features (predictors) are all used to fit the Isolation Forest estimator. The goal is to identify which of those X-features ...
user avatar
  • 101
0 votes
0 answers
45 views

When I use imblearn pipeline instead of sklearn pipeline all textual features disappear. Any solution?

This is my code below, I need to use SMOTENC to balance the dataset, which means I have to use the pipeline from the imblearn library. However, it does not recognize the CountVectorizer features ...
user avatar
1 vote
0 answers
27 views

How to return selected features with different feature selection models?

I use the below function to detect the effect of those feature selection models on my data, it works perfectly. what I want is to return the name of selected features for each model, is there any ...
user avatar
  • 33
2 votes
1 answer
101 views

What are the differences between the below feature selection methods?

Do the below codes do the same? If not, what are the differences? ...
user avatar
  • 33
0 votes
0 answers
16 views

Can a custom Transformer be used to transform X and y?

I am working with time series in sklearn, my goal is to have a Pipeline step that replaces each row with a window centered on that row (think convolution). My ...
user avatar
  • 101
0 votes
0 answers
5 views

Does it make sense to scale input data with random forest regressor taking two different arrays as input?

I am exploring Random Forests regressors using sklearn by trying to predict the returns of a stock based on the past hour data. I have two inputs: the return (% of change) and the volume of the stock ...
user avatar
0 votes
0 answers
14 views

Retrive image from from features represented by histograms of oriented gradients

I am using histogram of oriented gradients for image classification using clustering in scikit learn. I am using hog from scikit-image to generate hog from 512x512 grayscale image. Here is an example: ...
user avatar

1
2 3 4 5
43