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
1
vote
1answer
17 views

How do I split correctly split my dataset into train, test and validation?

I'm attempting to split my data set into 70% training, 15% testing and 15% validation. ...
0
votes
1answer
24 views

AttributeError: 'numpy.ndarray' object has no attribute 'fit'

I am relatively new to ML and in the process of learning pipelines. I am creating a pipeline of custom transformers and get this error: AttributeError: 'numpy.ndarray' object has no attribute 'fit'. ...
0
votes
0answers
10 views

How does the model trains with a 'Multinomial' parameter in Logistic Regression (Scikit-learn library)

I try to understand how the 'decision boundaries' are drown in a colored plot for a 'multinomial' prameter and then, how the model gives the prediction for a particular class. It can be assumed that ...
0
votes
2answers
18 views
0
votes
2answers
26 views

improve LinearSVC

Dataframe: ...
1
vote
1answer
6 views

Choosing your own initialisation points for kmeans

Kmeans clustering will randomly select the initialisation points and then run the algorithm until convergence is reached. Is there a way I can choose my own initialisation points and pass them into ...
2
votes
1answer
47 views
1
vote
1answer
20 views

Could I directly apply techniques for hyper-parameter tuning, and choose the best model?

I have noticed in some sources the author first trains the model (say a model from scikit-learn) with the default hyper-parameters, and the model naturally gives a ...
2
votes
3answers
44 views

How to get the correct confusion matrix in imbalance class dataset?

I have created two simulated random dataset of 3 classes. Only difference between the dataset is that frequency of the classes. ...
1
vote
2answers
40 views

Dealing with Extra Categories in Test Set

Suppose I have a data set which consists a dependent variable y and independent variables X. Suppose that there is a specific ...
0
votes
0answers
26 views

Trying to understand a PCA output

I recently ran a code to generate PCA for a movie ratings dataset. Actually there were two different datasets, a 'movies' and a 'ratings' one. The movie had about 9700 rows of different movie titles ...
1
vote
3answers
19 views

Work with large number of features for machine learning with pandas and sklearn

I'm relatively new to data science and I'm working with a large dataset. It has lots of rows and around 270 features after removing features with a lot of nan valuew and encoding categorical features. ...
0
votes
1answer
12 views

Where are the predicted results located in this model?

I am new at this and am pretty sure this is a stupid question, but here it goes: Where can I see the results of a model's prediction? I did this course about deep learning, followed the tutorial, ran ...
0
votes
1answer
18 views

For sklearn ML algorithms, is it possible to use boolean data alongside continuous data for the predictive data, and if so how can the data be scaled?

I have a medium size data set (7K) of patient age, sex, and pre-existing conditions. Age of course is from 0-101, sex is 1 for male, 2 for female, and -1 for diverse. All the pre-conditions are ...
1
vote
1answer
33 views

Scikit-learn's implementation of AdaBoost

I am trying to implement the AdaBoost algorithm in pure Python (or using NumPy if necessary)....
0
votes
1answer
18 views

Does hyperparameter tuning of Decision Tree then use it in Adaboost individually vs Simultaneously yield the same results?

So, my predicament here is as follows, I performed hyperparameter tuning on a standalone Decision Tree classifier, and I got the best results, now comes the turn of Standalone Adaboost, but here is ...
1
vote
1answer
32 views

How to fix my CSV files? (ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required)

I have tried to import two csv files into df1 and df2. Concatenated them to make df3. I ...
1
vote
0answers
8 views

Time complexity of scikit-learn implementations of RandomForestClassifier and LogisticRegression

Is there a documented source of the time complexities taken by sklearn implementations of supervised algorithms - specifically of RandomForestClassifier and ...
1
vote
0answers
9 views

Similarity between binary vector with hierarchal structure

I have dataset of binary vectors, where each vector composed from several small vector coming from a different parent category. Each of those categories has a different size e.g. ...
0
votes
0answers
6 views

Invalid value encountered in double_scalars and UndefinedMetricWarning: Precision is ill-defined

This question I asked in stack overflow but didn't receive any comments yet Question Link
2
votes
1answer
25 views

Reading the classification report of evaluation metric?

I am using the "classification_report" from: from sklearn.metrics import classification_report in order to evaluate a classification model. How can I ...
0
votes
0answers
16 views

How to handle both the categorical and ordinal features in a single data sets?

I was practicing Lasso regression with the SPARCS hospital dataset. There are two kinds of features in the dataset: Categorical features like location of the hospital, demographics of patients, etc. ...
0
votes
1answer
78 views

Creating quality data with sklearn.datasets.make_classification

I'm doing some experiments on some svm kernel methods. My methodology for comparing those is having some multi-class and binary classification problems, and also, in each group, having some examples ...
3
votes
1answer
94 views

How to visualize a hierarchical clustering as a tree of labelled nodes in Python?

The chapter "Normalized Information Distance", visualizes a hierarchical clustering as a tree of nodes with labels: Unfortunately I cannot find out how to replicate this visualization, ...
1
vote
1answer
26 views

How are the values for the `sex` feature in sklearn Diabetes dataset obtained?

I'm just starting out with using sklearn for my own Machine Learning project and I'm using sklearn's built-in "Diabetes&...
1
vote
1answer
25 views

Encoding "histogram bins"

I am currently working on a regression problem where I have one variable (x) of the data in the form of "histogram bins". I.e. I could have value ranges ...
0
votes
0answers
18 views

Is is possible to make a text generator with sklearn?

So recently I made a Tensorflow model using RNN (Recurrent neural networks) and I was wondering if it was possible with sklearn too, through the usage of SVMs or Naive bayes. I searched up many ...
0
votes
1answer
25 views

Why is there no R `formula` parameter in Scikit-learn models?

I was comparing both R and Python implementations of various models, such as Generalized Boosted Regression and Generalized Linear Models, and I was wondering why in R it is usual to see the ...
0
votes
0answers
19 views

StandardScaler on data which increase over time

I am trying to apply standard scaler on my data for classification prediction. But one of the feature will increase over time e.g. lifetime count, days since join Should I apply the standard scaler ...
0
votes
1answer
23 views

Scikit-learn make_scorer custom metric problem for multiclass clasification

I was doing a churn analysis using: ...
0
votes
2answers
21 views

Why is a MinMax Scaler scaling every coloumn independently?

Why is a MinMax Scaler scaling each column independently? Isn't it losing information if the values are somehow connected? If the value in column B is always an upper limit for the value in column C, ...
0
votes
1answer
21 views

how to choose between data normalization or standadization?

I have been studying about data scaling. Two common methods for it are the StandardScaler and MinMaxScaler. As I understood, StandardScaler expects the data to be normally distributed, but I have seem ...
3
votes
2answers
100 views

Constraining linear regressor parameters in scikit-learn?

I'm using sklearn.linear_model.Ridge to use ridge regression to extract the coefficients of a polynomial. However, some of the coefficients have physical ...
0
votes
1answer
16 views

What are the different estimators used by different loss functions in sklearn's SGDClassifier?

I am new to Data Science and was curious to learn about sklearn package. While digging up details on SGDClassifier I found in the documentation that SGDClassifier uses different estimators for ...
0
votes
1answer
26 views

Machine Learning in Tensorflow

I am doing a work that is based on analyzing different Python libraries for Machine Learning. I chose to analyze Scikit-Learn, Keras, Tensorflow and Pytorch for being the most known ones. The idea was ...
0
votes
0answers
9 views

How to calculate diameter of clusters for DBSCAN?

I've created several clusters for my task. Now I'd like to know the distance among the far points in each cluster. ...
-1
votes
1answer
26 views
0
votes
2answers
15 views

why i got error when using SimpleImputer for impute Nan values?

I have the following code, where sp_col is a sliced column of my dataframe df_1: ...
0
votes
0answers
19 views

Possible fixes for an overfitting random forest regressor?

I'm fitting a random forest regressor on my dataset (do note its not a classifer but a regressor since the target is a continuous variable) through a grid search cross-validation in sklearn. The ...
0
votes
0answers
45 views

Preserve column order after ColumTransformer

I'm using Pipeline and ColumnTransformer modules from sklearn library to perform feature ...
0
votes
0answers
12 views

How to perform nonlinear regression on data with error?

Most of of physical measurements are associated with error, I am wondering how to perform nonlinear regression in this situation. In the linear case, there are few methods like Deming Regression, ...
0
votes
0answers
35 views

Why is Testing Accuracy consistently higher than Validation Accuracy (even with multiple datasets and splits)?

I am having a problem where even after 1000 train/test splits, I am still getting a better accuracy in my testing set than my training set. I am stratifying my train/test sets and my sample size is ...
0
votes
0answers
13 views

GridSearch where input X consists of two DataFrames

For a project where a classifier and a regressor are combined in an scikit-learn pipeline, the input variable has to be a list (or sth equivalent) of two pandas DataFrames. When it comes to ...
0
votes
0answers
10 views

Fit StandardScaler API with training data and only transform the test set with the same parameters (losing model generalization)

If the standard scaler is better than the min max normalizer in terms of model generalization, since the standard deviation and mean are not the same for every attribute and can vary for different ...
0
votes
1answer
26 views

Tensorflow for Deeplearning and Machine learrning

We can use TensorFlow for both machine learning and deep learning. So why do we use scikit-learn more in machine learning and not TensorFlow? Are they both alternatives of each other?
0
votes
1answer
23 views

Randomforest code taking longer time every iteration

I have a prediction code that runs RandomForestRegressor and RandomForestClassifier. I call the functions 9 times each ...
0
votes
0answers
22 views

What should be the ratio between training time and accuracy?

What should be the ratio between time and accuracy? I mean when should you drop the accuracy a little bit but it will take less time for the Classifier/Regressor to run? Edit: As part of my studies I ...
1
vote
0answers
30 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: ...
1
vote
1answer
14 views

Shouldn't a test be repeated X times and average the results to determine the best machine learning model?

I have searched in several web pages how to choose the best machine learning model for a dataset and they all seem to agree that they should be compared using the same seed. However, they only run the ...
0
votes
1answer
48 views

Anomaly (Outlier) Detection with Isolation Forest too sensitive even with low contamination

I'm trying to use the sklearn implementation of the Isolation Forest algorithm to detect anomalies in my time series data. However, even with a very low contamination parameter (0.0001), it is ...

1
2 3 4 5
40