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
34 views

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

I have tried to import two csv files into df1 and df2. Concatenated them to make df3. I ...
1
vote
0answers
14 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
10 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
53 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
94 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
194 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
27 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
26 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
24 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
26 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
21 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
26 views

Scikit-learn make_scorer custom metric problem for multiclass clasification

I was doing a churn analysis using: ...
0
votes
2answers
23 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
22 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
120 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
22 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
10 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
34 views
0
votes
2answers
31 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
68 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
14 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
27 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
32 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
17 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
73 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 ...
0
votes
2answers
28 views

Predict a continuous data without a linear shape on data points

I have a dataset like that I want to predict the financial loss given the incident type. This is a brief visualisation As the financial loss is a continuous data, I know that I cant do a linear ...
0
votes
1answer
22 views

need an explanation of the For Loop in the DBSCAN algorithm Demo

In the following code of the DBSCAN algorithm, as a beginner I need an explanation for what happens to the data in the bottom for loop and why ? Generate sample data ...
0
votes
0answers
8 views

Proper scaling method for time series classification transformer models?

I've asked a similar question about Gradient Boosting Machines already some time ago. This time, I would like to perform time series classifications with a transformer model. I found this Keras ...
0
votes
0answers
15 views

OLS Regression: Predicting to the certain total

I have a simple dataset: Rooms Price(in March) Single 20 Balcony 50 Triple 100 Couple 75 Family 150 Now, I can predict the values and set the ...
0
votes
0answers
25 views

SVM Hyperparamter tunning using GridSearchCV

I am trying to hyper tune the Support Vector Machine classier to accurately predict classes which have higher degree of overlapping.The objective is to get the precise value of C which would be ...
0
votes
0answers
23 views

Is it possible to cluster unseen data using transductive algorithms like DBSCAN, OPTICS, Spectral Clustering, Agglomerative clustering

I am trying to solve a clustering problem. In general for K-Means clustering we fit the data and whenever we have a new data/sample we use ...
1
vote
0answers
24 views

Logistic Regression : shouldn't weighting by the number of instances give the same result ? What could explain the discrepency?

I am performing a logistic regression in a standard supervised framework (Data Set X, target y). The dataset X is composed of a handfull of categorical variables (that I one-hot encode), thus it ...
0
votes
0answers
14 views

How does regularization work?

Could any explain how regularization works with the noise point. Like in this image, the $2^{nd}$ graph is where the decision surface is good, where the noise points are close to the actual points.
0
votes
1answer
36 views

When should I use 'rbf' and 'polynomial' kernel trick in machine learning algo?

I have a problem about hate-speech classification using support-vector machine algorithm. The task is to identify the sentence that contains 'positive' or 'negative' sentiment. Which is the best ...
1
vote
0answers
81 views

Plotting SVM hyperplane margin

I'm trying to understand how to plot SVM hyperplane and its margins by this example: https://scikit-learn.org/stable/auto_examples/svm/plot_svm_margin.html And I got stuck at the plotting the ...
1
vote
1answer
26 views

When should you use Ensemble?

I have been working on a project as a part of my studies(computer/data science). I tried to make the best classifier I can with what I learned, and recently I have tried to upgrade this classifier ...
0
votes
0answers
17 views

Change in matrix of features format after one hot encoding

I have a dataset with 10 independent variables (2 categorical and 8 numerical) and one dependent variable. I used one hot encoding on the categorical dataset and the multiple linear regression ...
0
votes
0answers
16 views

Oversampling on Sequence(Text) data

Has anyone been able to perform synthetic oversampling on Sequential data? From what I've read and understand, the oversampling/undersampling techniques that are currently used are only applicable on ...
0
votes
1answer
53 views

How do I split a data set into train and test sets using

I have the following matrices for training a model: INPUT FEATURES MATRIX $$ X = \begin{bmatrix} | & | & & |\\ X_1 & X_2 & ... & X_m\\ | & | & & | \end{bmatrix}; ~ ...
0
votes
1answer
19 views

Stop words list to use for CountVectorization

The sci-kit learn library by defaults provides two options either no stop words or one can specify stop_words=english to include a list of predefined English words I am using Naive Bayes for SMS spam ...
2
votes
1answer
81 views

Why does classifier (XGBoost) “after PCA” runtime increase compared to “before PCA”

The short version: I am trying to compare different classifiers for a certain dataset from kaggle, and am trying to also compare these classifiers between before using PCA (form sklearn) to after ...

1
2
3 4 5
40