Questions tagged [scikit-learn]

Scikit-learn is a Python module comprising of simple and efficient tool for machine learning, data mining and data analysis. It is built on NumPy, SciPy, and matplotlib. It is distributed under the 3-Clause BSD license.

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

Forecasting as a supervised regression task, with uneven length timeseries - how to split?

Consider a number of timeseries. Here we have 3, just to make it dead simple. Note that they're all different lengths. The very first thing I do is splitting by the original sample dimension: Then, ...
2
votes
3answers
35 views

Comparing ML models to baselines

When comparing ML models with baseline or "dummy" models, are there best practices for building and comparing baselines? I'm doing a binary classification task where 40% of the samples are ...
0
votes
1answer
641 views

sklearn predict: IndexingError: ('Too many indexers', 'occurred at index <name>')

The goal of what I'm trying to accomplish here is to have the output contain all of the use_cols but the model only be built to calculate on categorical_features. The output will then be used to ...
0
votes
0answers
21 views

Loss increasing and accuracy decreasing

I've implemented a shallow FC feedforward neural net with 2 input nodes, 1 hidden layer with 4 nodes (tanh activation) and 1 outputnode with sigmoid activation function and binary cross-entropy loss. ...
0
votes
2answers
78 views

Error when trying .transform for OrdinalEncoder from Scikit Learn

I'm having a lot of issues using scikit learn recently and was hoping someone could help me with my problem. I can use other methods to ordinal encode but i want to figure this one out. ...
0
votes
0answers
8 views

Why is CoxTimeVaryingFitter().predict_log_partial_hazard creating NaN for hazard values?

I am using Nasa Turbofan Engine Degradation Simulation Data Set Dataset in case if you need to see the dataset. I have preprocessed it and sure that there is no null value in the dataset yet when I ...
1
vote
1answer
29 views

Two questions on hyper-parameter tuning

Question 1: In the example of logistic regression, I often see the regularization constant and penalty methods being tuned by a grid search. However, it seems like there are a lot more options for ...
1
vote
0answers
20 views
+100

How can the labels of AgglomerativeClustering be re-computed?

I'm using scikit learn's AgglomerativeClustering on a large data set. I want to modify the distance_threshold after the model has already been computed. Computing ...
0
votes
3answers
3k views

How to apply ensemble clustering method?

I need to use ensemble clustering method by using python in my data set. I already applied k-means clustering by using scikit learn library. I also applied different classification method also find ...
1
vote
1answer
22 views

RF regressor for probabilites

I am using sklearn multioutput RF regressor to learn statistics in my data. So my target contains several probabilities for the different features, and the sum of all these probabilities is one as ...
0
votes
0answers
17 views

Why is doing a ShuffleSplit with GridSearchCV decreasing the performance of my model?

I'm using the Boston Housing dataset in Keras, and neural networks for this regression problem. The following is the code I use to prepare the data, build the model, and fit it with GridSearchCV. <...
0
votes
0answers
11 views

Results Random Forest Regression Optimization [duplicate]

I'm going to optimize the hyperparameters of a Random Forest Regressor using scikit-learn and GridSearchCV, with the following code: ...
0
votes
0answers
15 views

Number of samples in cross validation? [closed]

How do I check the number of training sample and number of test samples when I have used cross validation(cv=10)?
0
votes
1answer
17 views

Changing order of LabelEncoder() result

Assume I have a multi-class classification task. The labels are: Class 1 Class 2 Class 3 After LabelEncoder(), the labels are transformed into 0-1-2. My questions are: Do the labels have to start ...
201
votes
10answers
268k views

What's the difference between fit and fit_transform in scikit-learn models?

I'm a newbie to data science, and I do not understand the difference between the fit and fit_transform methods in scikit-learn. ...
1
vote
1answer
26 views

How to combine two logistic regression models trained on different set of data?

My data has a hierarchy structure - meaning that there is an N class at level 1 and an M class at level M. After training both models separately with a different set of data (both are Logistic ...
1
vote
0answers
31 views

Reduce multiclass classification targets to binary classification targets in scikit-learn

I would like to reduce multiclass classification targets to binary classification targets. Ideally, this mapping would happen within scikit-learn so the same transformation applies during both ...
0
votes
0answers
5 views

SelectKBest for regression `f_regression` behaves weird when changing the random_state parameter when splitting

I am working on a regression project using the Audi dataset from Kaggle. I have looked at other notebooks and i saw that people use SelectKbest. I tried using the same thing, but when I was splitting ...
0
votes
1answer
31 views

Machine Learning algorithm for predicting number of cases in pandemic

I’m giving my first steps with AI and Machine Learning so I have the following issue. I’m trying to predict an outcome from COVID-19 number of day vs confirmed cases using scikit-learn library. I mean,...
2
votes
1answer
97 views

SelectFromModel vs RFE - huge difference in model performance

Note: I have already looked at Difference between RFE and SelectFromModel in Scikit-Learn post and my query is differnt from that post Expectation: SelectFromModel ...
0
votes
1answer
14 views

LinearRegression with fixed slope parameter

I have some data $(x_{1},y_{1}), (x_{2},y_{2}), ..., (x_{n},y_{n})$, where both $x$ and $y$ represent real numbers (float). I want use Scikit-learns LinearRegression model to fit a model of the form: $...
28
votes
3answers
14k views

Difference between OrdinalEncoder and LabelEncoder

I was going through the official documentation of scikit-learn learn after going through a book on ML and came across the following thing: In the Documentation it is given about ...
1
vote
0answers
21 views

How to evaluate KDE against histogram?

I am currently testing some approaches for density estimation, and I think the basic approach of histograms may not be the best option to me and KDE is certainly a good alternative to go. While ago I ...
1
vote
1answer
440 views

How to impute using simple imputer (custom function)

I am imputing my data using simple imputer from sklearn. i want to test many different ways of applying transformations to the data. i.e for logisitcic regression i would like to remove nans and ...
1
vote
1answer
30 views

upload model to S3

I'm using AWS Sage Maker to build my model. I want to store the model in S3 for later use. How do you save your model in S3 with Amazon Sage Maker? I know this seems trivial but I didn't understand ...
0
votes
1answer
21 views

Classification Threshold Tuning with GridSearchCV

In Scikit-learn, GridSearchCV can be used to validate a model against a grid of parameters. A short example for grid-search cv against some of DecisionTreeClassifier parameters is given as follows: <...
0
votes
2answers
109 views

Cross-Validation in Anomaly Detection with Labelled Data

I am working on a project where I train anomaly detection algorithms Isolation Forest and Auto-Encoder. My data is labelled so I have the ground truth but the nature of the problem requires ...
4
votes
2answers
181 views

Scikit-learn pipeline with scaling, dimensionality reduction, average prediction of multiple regression models, and grid search cross validation

I would like to use a sklearn pipeline doing this : ( - ) scale the data ( StandardScaler ) ( - ) reduce dimensionality ( PCA ) ( - ) make a prediction with GradientBoostingRegressor() and ...
4
votes
2answers
101 views

Sklearn: applying cost complexity pruning along with pipeline

I have a data set with categorical variables. I have defined a decision tree algorithm and transformed these columns to numerical equivalent using one hot encoding functionality in sklearn: Create ...
0
votes
1answer
1k views

What is difference between leave one subject out and leave one out cross validation

What is the difference between leave one subject out cv and leave one out cross validation (loocv)? are they same or different?. I have images of 24 subject and according to literature, leave one ...
0
votes
2answers
26 views

How match output (pred value) to input value

I'm working with data(with 4 columns which are p(product), M(name of the store)), I want predict the demand of store for that I sued SVR on the data by theses formulation: ...
0
votes
0answers
16 views

Results of quadratic SVM in Matlab are different from the results obtained in Python

I am trying to replicate a quadratic SVM classifier from Matlab to Python, however I am having different results regarding the accuracy. In Matlab the accuracy is 0.8955 meanwhile in Python the ...
1
vote
1answer
18 views

cost-complexity-pruning-path with pipeline

I'm using Kaggle's titanic set. I'm using pieplines and I'm trying to prune my decision tree and for that I want the cost_complexity_pruning_path. The last line of code produces the error: ...
0
votes
1answer
8 views

Statsmodel logit with sample weights

Using sklearn I can consider sample weights in my model, like this: ...
0
votes
1answer
30 views

Feature relevance in PCA + kmeans algorythm

Working on the World Happiness Report dataset, i have N countries with M features and a happiness score. This is the parameter I built 3 classes from: happy, medium, unhappy (numerical intervals of ...
4
votes
1answer
36 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 ...
0
votes
1answer
977 views

How to fix “Expected sequence or array-like”

I am trying to get the accuracy of the model and I am getting this error TypeError: Expected sequence or array-like, got Here's my code sample. ...
0
votes
0answers
13 views

Using GridSearchCV in a regression with Keras [closed]

I'm trying to use GridSearchCV in a regression with a Keras neural network. The data I'm using is the Boston Housing Price dataset, which was loaded directly from keras ...
1
vote
1answer
49 views

Accuracy over different sample sizes from dataset

What I'm trying to do is predict how much more data would help in a classification task. So, what I'm doing is bootstrapping entries in my dataset to get a sample, with a specified size. Then, I fine-...
1
vote
1answer
21 views

What is different between R2 and mean of R2 in multiclassification probelm? Which one is correct?

I have a question. I have a big dataset (unfortunately confidential). What I did? I have trained my model with Naive-Bayes. ...
0
votes
1answer
41 views

How to interpret my logistic regression result with statsmodels

so I'am doing a logistic regression with statsmodels and sklearn. My result confuses me a bit. I used a ...
1
vote
0answers
21 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 ...
4
votes
2answers
1k views

Validation Curve Interpretations for Decision Tree

I'm working on a machine learning class, and we're using supervised learning right now, starting with decision trees. I'm using the UCI Credit Card dataset (whether or not certain people will default ...
2
votes
1answer
27 views

Large dataset - ANN

I am trying to classify around 400K data with 13 attributes. I have used python sklearn's SVM package, but it didn't work, and then I learned that SVM's are not suitable for large dataset ...
0
votes
1answer
50 views

Multiclass classification dataset with many features producing bad accuracy of predictions

I have been trying to fix this for 2 months now with no luck. I am doing some medical research for my study. I have a dataset that has patients diagnosis based on medical reports (Features.csv) and ...
0
votes
1answer
21 views

IterativeImputer Evaluation

I am having a hard time evaluating my model of imputation. I used an iterative imputer model to fill in the missing values in all four columns. For the model on the iterative imputer, I am using a ...
1
vote
0answers
19 views

Multiclass Classifier comparison decision regions

How can I get the very same effect of this tutorial in Scikit Documentation with more than 2 classes? Let's say we'll keep only the first dataset (the linear separable one) and substitute it with <...
2
votes
0answers
14 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 ...
1
vote
1answer
22 views

Geolocation Based Anomaly Detection in IPs Using Isolation Forest

I'm trying to detect anomalies based on geolocation from IP addresses on a server access log file. I have created two features country and geo_velocity, using the IP address and the timestamp of each ...

1
2 3 4 5
36