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

Compare Coefficients of Different Regression Models

in my project, I am using asuite of shallow and deep learning models in order to see which has the best performance on my data. However, in the pool of shallow machine learning models, I want to be ...
0
votes
0answers
21 views

How to predict using the pickle model?

I am new to data science and trying to learn something. I was able to complete the prediction with 98% accuracy and i saved it as pickle model. Now while trying to predict using this model I am ...
2
votes
1answer
32 views

Bagging or Random Subspace Method for Random Forest?

I am reading a lot about the random forest regressor. I reading about bagging (bootstrap and aggregation) and random subspace. But I am not sure if the random forest regressor just using bagging or ...
1
vote
0answers
37 views
1
vote
0answers
15 views

Built strong base for Unsupervised Learning [closed]

I’m am new into machine learning, recently I have put a task upon my shoulders to Detect Outliers in Dataset. The anomaly detection should be done using Unsupervised learning and preferably use ...
1
vote
0answers
20 views

setting class weights for imbalanced dataset, how using EarlyStopping?

I want to train a CNN with Early Stopping (Keras). The data set is imbalanced, so I have set class_weights to 'balanced' like follows: ...
4
votes
1answer
95 views

Calculate confidence score of a neural network prediction

I am using a deep neural network model to make predictions. My problem is a classification(binary) problem. I wish to calculate the confidence score of each prediction. As of now, I use ...
5
votes
2answers
317 views

RandomForest and tree feature importance in scikit-learn

What is the difference between model.feature_importances_ and tree.feature_importances_ in the following code: ...
1
vote
1answer
44 views

Decision tree regression: Polynomials unnecessary?

I am testing out different models for a regression task. When using OLS, Ridge and Lasso, I use different polynomial degrees of the explanatory variables. Example: For two variables x and y, degree 2 ...
0
votes
1answer
25 views

How to choose the best parameter values for TfidfVectorizer in sklearn library?

Recently, I used TfidfVectorizer in scikit-learn library to calculate a matrix of TF-IDF features. However, I do not know how to set some parameters such as ...
1
vote
1answer
28 views

Using TSNE to Visualize Clusters in Python

I'm using TSNE to visualize my clusters but the output seems a bit strange. There are supposed to be 3 clusters but instead, there are 4 lines. Is there something wrong with how I'm visualizing them ...
2
votes
1answer
25 views

Trying to return more than just the top result from sklearn NearestNeighbors

I'm trying to compare a list of names (duplicated into a clean file and a messy file). I then compare the files against each other. My problem is that it returns only the top 1 result for each, ...
1
vote
0answers
26 views

Need help regarding my thesis project related to Data Analysis [closed]

I am working on a project with a company that manufactures Injection molding machines. I am to perform data analysis on some selected parameters as a part of my thesis to tell the company if from ...
1
vote
2answers
35 views

data splitting into 3 sets based on years

let's suppose we have a customer data from the year 2015 to 2019, I want to train_test_split() my data such that my data gets divided into three sets, set-1 is from 2015 to 2017 (3 years) on which i ...
1
vote
1answer
50 views

Random Forest prediction fails due to unseen Features

I have trained a Random Forest Model on some dataset and like to predict outcomes on other data which were not seen in training. When doing this, I get ...
1
vote
2answers
38 views

Predict the average temperature for next 30 years

Objective: I want to predict the average temperature for next 30 years. Q1: What type of dataset is suitable for this (what columns should it contain) Q2: What are the independent variables for ...
0
votes
0answers
34 views

Feature importance and deriving rules using tree based classification models

I have a dataset where I have categorical and continuous values with targets 0/1 (binary classification task). Since I need to find patterns and relationships in the occurrence of the event or target, ...
2
votes
0answers
42 views

Multi-output regression python

I am new to machine learning and cannot figure a way to solve this problem: I have X which is always one row/record while the y can be a row or more. Here is a simple sample from my data-set, 'i ...
1
vote
0answers
27 views

What is the formula to calculate the precision, recall, f-measure with macro, micro, none for multi-label classification in sklearn metrics?

I am working in the problem of multi-label classification tasks. But I would not able to understand the formula for calculating the precision, recall, and f-measure with macro, micro, and none. ...
1
vote
1answer
47 views

How is the 'feature_importance_' value calculated (in sklearn modules) for each variable in a random forest regressor?

I have 9000 sample, with five features, and one output variable (all are numerical, continuous values). I used random forest regression method using scikit modules. ...
3
votes
1answer
34 views

How to balance class weights correct for a CNN in Keras, given an unbalanced data set?

I want to use class weights for training a CNN with a imbalanced data set. The question arise if the sum of the weights of all examples have to stays the same? My previous plan was to use the ...
3
votes
5answers
298 views

GridSearch without CV

I create a Random Forest and Gradient Boosting Regressor by using GridSearchCV. For the Gradient Boosting Regressor it takes too long for me. But i need to know which are the best Parameter for the ...
1
vote
1answer
34 views

How to convert Scikit Learn logistic regression model to TensorFlow

I would like to use existing Scikit Learn LogisticRegression model in the BigQuery ML. However, BQ ML currently has a hard limit of 50 unique labels and my model needs to handle more than that. BQ ...
2
votes
3answers
61 views

How to approach TF-IDf based analysis?

Problem statement : We have documents with list of words in them. Overall these documents are classified into 2 group (say, good quality vs bad) docs - ...
0
votes
1answer
84 views

What is the difference between Freidman mse and mse?

The original question was posted on StackOverflow. However, taking into account the recommendations of Sergey Bushmanov, I'm providing an answer through this medium.
3
votes
1answer
76 views

sklearn SimpleImputer too slow for categorical data represented as string values

I have a data set with categorical features represented as string values and I want to fill-in missing values in it. I’ve tried to use sklearn’s SimpleImputer but ...
2
votes
1answer
23 views

Maximize one data point

I am completely new to data science and looking to narrow down the search and reduce the learning curve required to solve problems like the one given below I have a data set with 7 columns , Column ...
1
vote
0answers
22 views

Retrieve dropped column names from `sklearn.impute.SimpleImputer`

The SimpleImputer class takes pandas dataframes and returns unlabeled numpy arrays. Which means that the SimpleImputer drops ...
2
votes
1answer
33 views

How can I perform categorical encoding when the dataset is too large for memory?

I generally do preprocessing before fitting estimators using Scikit-Learn. My latest project is using significantly more data than I have used in the past, and whilst I know I can use online learning ...
0
votes
0answers
27 views

Different extraction pipeline for train and test

I'm trying to create a production-ready ML model. The problem is as follows: Training data: Database A + Plus python aggregations. Testing data: Database B + Plus python aggregations. Both ...
0
votes
1answer
22 views

splitting into train test by train_test_split of float values?

How to split into train test by train_test_split of float values ? I used LabelEncoder but I have about 300K lines and when I used the cross_val I saw ...
1
vote
0answers
13 views

Equivalent procedure to Scikit-Learns class_weight=balanced in Keras?

I want to train a SVM and a CNN with the same unbalanced multiclass-dataset and want to compare the results. I use Scikit-Learn for the SVM and Keras for the CNN. My goal is that no class is ...
0
votes
0answers
16 views

undersampling problem in imblanced dataset ValueError: Unknown label type: 'continuous'

I would like to undersampling the data but I encounter the following error? ...
1
vote
0answers
29 views

Sklearn Decision Tree as weak learner in Adaboost not working properly

I'm trying to implement Adaboost algorithm with sklearn decision tree as the Weak Learner - at each step I want to choose one feature with one threshold to classify all samples. I have 1400 long ...
1
vote
0answers
14 views

regression model assumption [migrated]

I try to check whether my regression model is follow regression assumption or not? for that I did below python code but response is error. can someone explain how it wrong ...
0
votes
1answer
19 views

String labels for classification

I've recently started playing SciKit ML. I just got my hands on classification algorithms (SGDClassifier, LinearSVC) and I'm not sure how to properly represent feature labels. Suppose I'm trying to ...
1
vote
0answers
19 views

pipeline stragety when removing outliers

We are implementing an sklearn pipeline as follows (pseudo code): ...
1
vote
1answer
23 views
2
votes
1answer
45 views

KNN custom transformer shows same accuracy for every k i set

I built custom trasformer for KNN and i can't figure why my k-number, when i set it, always shows same accuracy... ...
0
votes
0answers
25 views

TypeError: 'KFold' object is not callable

I am trying to perform K-Fold Cross Validation with Scikit Learn: from sklearn.model_selection import KFold KFold but I am getting ...
6
votes
5answers
632 views

Decision tree with final decision being a linear regression

Question: I want to implement a decision tree with each leaf being a linear regression, does such a model exist (preferable in sklearn)? Example case 1: Mockup data is generated using the formula: <...
2
votes
1answer
27 views

weightage attributes

If I have a dataset with binary classification and has many attributes with value of (0 or 1) means the occurrence of attribute is represented by 1 and absence is represented by 0, can I add weight ...
3
votes
1answer
132 views

Is GridSearchCV in combination with ImageDataGenerator possible and recommendable?

I want to optimize some hyperparameters for a CNN architecture by using GridSearchCV (Scikit-Learn) in combination with Data Augmentation (ImageDataGenerator from Keras). However, GridSearchCV only ...
1
vote
3answers
41 views

why to use Scaler.fit only on x_train and not on x_test for normalizing value using MinMaxScaler?

while normalising the data everone is saying that we need to fit only on x_train and not on x_test ? why is that we should not fit x_test ? if we should not fit the scaler on x_test then why we need ...
2
votes
1answer
53 views

For a square matrix of data, I achieve $R^2=1$ for Linear Regression and $R^2=0$ for Lasso. What's the intuition behind?

For a square matrix of random data, N columns and N rows. I am fitting two models, linear regression and Lasso. For the linear regression, I achieve a perfect score in train set, while in the Lasso I ...
2
votes
1answer
25 views

Calculating error from accuracy score in Sklearn

I have one question thats maybe simple, but my brain overfited :) I wrote a code for simple linear regression in Python and ...
1
vote
1answer
22 views

Is it possible to change pandas column data type within a sklearn pipeline?

Sklearn pipeline I am using has multiple transformers but one of the initial transformers returns numerical type and the consecutive one takes object type variables. Basically I need squeeze in a: <...
4
votes
2answers
43 views

(Newbie) Decision Tree Classifier Splitting precedure

I have a dataset with 4 categorical features (Cholesterol, Systolic Blood pressure, diastolic blood pressure, and smoking rate). I use a decision tree classifier to find the probability of stroke. I ...
3
votes
2answers
27 views

What is meaning of zip(kfold.split(X, Y) in sklearn

What is meaning of zip(kfold.split(X, Y) in sklearn? for (train, test)in zip(kfold.split(X, Y)):
0
votes
1answer
17 views

Does Sklean's SGDClassifier automatically standardize the training data when regularization is turned on?

Generally speaking--it is best to apply standarizaton (z-scoring the training data) prior to regularization. Does sklearn.linear_model.SGDClassifier automatically standardize the training data or not ...