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
1answer
741 views

neg_mean_squared_error in cross_val_score [closed]

The string "mean_squared_error" appears to be deprecated in cross_val_score now, and it's saying to use ...
2
votes
1answer
35 views

How to fit a KNN and then a linear regression with those neighbors?

How do I fit a KNN to get the $k$ nearest neighbors and then aggregate the those neighbors into a fit using a linear regression (instead of a weighted average) in Scikit-Learn? I've tried creating a ...
0
votes
0answers
14 views

What classifier is best to use for multi-class number outputs?

I have 50 features which are real numeric values, and the outputs are 5 numbers. How can I best construct a classifier for this using sci kit learn? I think Random Forest would be good but what else ...
0
votes
0answers
26 views

Is there an point to using LassoCV with `cross_val_score`

I've seen some jupyter notebooks that seem to combine LassoCV with cross_val_score, and I'm confused what the point is. Usually ...
3
votes
0answers
152 views

sklearn FutureWarning message when running a CNN model

When I run my model, I am receiving the following error message: ...
1
vote
1answer
28 views

Categorical encoded variables in scikit-learn diabetes dataset [closed]

When using sklearn.datasets import load_diabetes, the sex variable which is categorical, is scaled to continuous values. Is it even legal to scale such variables?
0
votes
1answer
125 views

Logistic regression with unbalanced data, scoring based only on rare class

I have a dataset off app. 600.000 data points in which 0.2% (1.200 samples) is labelled as signifying a rare event. I want to use logistic regression to help me predict this rare event, but even when ...
1
vote
1answer
34 views

Why can't I use 2D-arrays as features for CCA (Canonical Correlation Analysis) classifier?

The Problem When using fit of the scikit learn CCA classifier it won't allow me to use arrays as features. The error ...
1
vote
1answer
57 views

How to compute f1_score for multiclass multilabel classification

I have used one hot encoder [1,0,0][0,1,0][0,0,1] for my functional classification model. The predicted probabilities for test data ...
0
votes
1answer
18 views

How to add 'other' as one group to clustering algorithm inference pipeline

I have few clustering algorithms tuned having 5 cluster. I want 6th cluster if new data does not belong initial 5 cluster fall in 6th cluster. 6th cluster [ say other category] consist of all data ...
1
vote
1answer
79 views

one hot encoding target variable in tree and non tree (knn) methods

I am learning about label encoders, one hot encoding etc applied to datasets for classification via KNN and XGBoost type trees. However, I am a bit confused as to whether the target variable should be ...
1
vote
1answer
33 views

Efficient Decision Tree Pruning

Is there an efficient way to handle pruning in Decision Tree with Python ? Currently I'm doing that: ...
3
votes
2answers
126 views

List of samples that each tree in a random forest is trained on in Scikit-Learn

In Scikit-learn's random forest, you can set bootstrap=True and each tree would select a subset of samples to train on. Is there a way to see which samples are used in each tree? I went through the ...
0
votes
0answers
18 views

How do I extract the kernel matrix for a classifier created using `sklearn.svm.SVC`?

I am currently using the kernels that come with sk-learn support vector machine library. How do I extract the kernel matrix for a classifier created using ...
0
votes
0answers
21 views

Is it possible to fix the validation set when tuning hyperparameters using scikit learn?

I have a question regarding hyperparameter optimization in scikit learn. I am most familiar with tensorflow where you first split your data into three sets: Train, validation and test. Hyperparameters ...
0
votes
1answer
27 views

Evaluating model with categorical target variables

I converted all the numeric target variables of MNIST dataset into categorical variables. So, 0 became zero, and so on. Next, I ...
0
votes
1answer
18 views

Impute missing value: transpose or not?

I'm building a model that fills the missing values from a Dataframe that contains the number of visitors for different stores, each day: day store_a store_b store_c 2021-01-01 100 200 300 2021-01-...
1
vote
0answers
18 views

How to get KNN linearly hybridised by two similarities?

I'm writing a KNN (collaborative filtering) hybrid similarity recommender and I need some advice. It is based on this paper. I've currently got 2 datasets. The first one is ...
0
votes
1answer
16 views

Classification Based Collaborative Filtering Model

I was going through algorithms for collaborative filtering-based prediction. Most of the places, I read about using matrix factorization based on ratings of the likeness of the user. But for my use ...
1
vote
1answer
24 views

How do you perform multilabel classification that is also a multiclass problem?

I have a data set in which each row of data belongs to certain classes/labels. text class1 class2 class3 text1 pos neg na text2 na neg na text3 na neu na text4 pos neg neg text5 neg neg na ...
-2
votes
1answer
31 views

Help with Classification using scikit-learn models [closed]

I'm using the Titanic data set to classify the missing Cabins. There is a lot of missing Cabin values. My objective is just to assign the letter of the Cabin without the room number. So, I'm just ...
4
votes
1answer
224 views

Follow Up Question - Why use fit when already have fit_transform?

This is a follow up question to: What's the difference between fit and fit_transform in scikit-learn models? I want to know why should we use fit at all when we ...
0
votes
2answers
330 views

How to add epoch in sklearn LinearSVC?

I have a model that i need to train multiple times using epochs, i tried adding this code clf_svm.fit(train_features, train_labels, epochs=10, batch_size=64) and it ...
0
votes
2answers
25 views

Multiple Features with the same categorical value

In working with a telecommunications data set with multiple categorical variables which all depend on Internet Service, a separate categorical variable, I ran into the problem where 'No Internet ...
0
votes
1answer
35 views

Predicting the test data with LinearRegression model gives ValueError: shapes (8523,1606) and (1605,) not aligned: 1606 (dim 1) != 1605 (dim 0)

Fitting the model, testing and getting the score or r2 does not give the error. But when I try to predict the actual data I get this ValueError: ...
0
votes
1answer
83 views

Is it wrong to transform the target variable and test the model without dropping the column that was transformed? What's the disadvantage about it?

I have a linear regression model, I have transformed the target variable Item_Outlet_Sales into Item_Outlet_Sales_log on both training and testing dataset. I did not delete the Item_Outlet_Sales. Here ...
0
votes
0answers
33 views

Mutual Information Score for higher dimensional features?

Quick Background I am building a simple offline Motor Imagery classifier for a Brain Computer Interface system in Python and sklearn for educational purposes. I am following this pre-print. Here's a ...
0
votes
0answers
16 views

differences in NN optimization algorithm between Matlab and Scikit-Learn

I'm trying to build a neural network to estimate the responses of a nonlinear system. My database contains 1000 load cases (inputs) and maximum responses (outputs) from numeric simulations. I'm using ...
0
votes
1answer
143 views

Mututal Information in sklearn

I expected sklearn's mutual_info_classif to give a value of 1 for the mutual information of a series of values with itself but instead I'm seeing results ranging between about 1.0 and 1.5. What am I ...
0
votes
1answer
16 views

Unbalanced training set from balanced data

I am looking to get an unbalanced training set with a given ratio of classA:classB from a dataset without regarding if it is balanced or not. The point is to analyze the influence of data imbalance on ...
0
votes
0answers
12 views

How to handle features containing strings in XGBoost in AWS Sagemaker

How can i handle the string containing spaces and colons as a feature for my xgboost classifier model? AWS Sagemaker requires the input in csv format, I don't know how to convert the string to the ...
3
votes
2answers
144 views

How to use a set of pre-defined classifiers in Adaboost?

Suppose there are some classifiers as follows: ...
0
votes
1answer
66 views

How to use random forest with large number of categorical features and categories?

I have 2 features productName and productCategory , both of them are strings. I have a category named supplier. There are 4000 ...
2
votes
4answers
89 views

Are there ML Libs in Python robust to missing data?

So I was searching on how to handle missing data and came across this post from Machine Learning Mastery. This article states that some algorithms can be made robust to missing data, such as Naive ...
1
vote
1answer
161 views

How to use SMOTE in Stacking in SKLearn?

I have a data set X,y and split them to train and test data. ...
0
votes
1answer
20 views

How to prune the features using recursive feature elimination?

I have some kind of spatial data for nearly 1000 locations and at each location around 5000 features. I am doing neighborhood analysis to identify which features are predominant in local neighborhood. ...
1
vote
1answer
97 views

Using Sklearn's predefined split

I am working on a binary classification task using SVM. The dataset is quite large so I don't want to use k-fold CV for parameter tuning, but instead a simple train-validation-test split. I have done ...
0
votes
1answer
17 views

Neural network for a data with 5 inputs and 1 output of 3 different types

I am trying to create a neural network for my data which is as follows ...
1
vote
1answer
126 views

For multi-class classification in SGDClassifier how do I tell if it is using one-vs-rest or one-vs-one by default?

According to the Geron book, for multi-class classification, SGDClassifier in scikit-learn uses one-vs-rest. But how can I tell which one is used as it doesn't ...
0
votes
0answers
20 views

How to repeat classification experiment with different set of data by loop

I want to repeat my experiment pipeline to validate my feature extraction. My goal is with different set of data which randomly picked as train test and validation, I want to check if the result are ...
4
votes
1answer
214 views

How can precision be less than one in Leave-One-Subject-Out binary classification if each subject contains only one class

Say I'm trying to classify a medical condition. Theres only two classes: Sick and Healthy. I build a model and I can't split the data because I don't want data from the same patient being in training ...
1
vote
1answer
28 views

Why is the optimal C chosen by GridSearchCV so small?

I'm trying to use GridSearchCV to select the optimal C value in this simple SVM problem with non-separable samples. The issue I'm having is that when I run the code the optimal C is chosen to be ...
0
votes
0answers
217 views

How to Determine Alpha values in Random Forest Classifier

I am working on a classification problem where I am applying various machine learning models. I have used DecisionTreeClassifier from Sklearn on my dataset using the following steps: Calculated alpha ...
2
votes
2answers
41 views

Find 10 most similar data points from 100?

I am trying to solve a problem where I need to group battery cells that are most similar to each other to form a reliable battery pack. It seems like a clustering problem but I only need to find the ...
0
votes
2answers
80 views

How to professionally spell library names such as "scikit learn"?

For example for inclusion in a CV. This is mostly a question of whether one should use capital letters or not. Usually I search the library to find how the library name is spelled on the official page....
0
votes
0answers
19 views

How to write decider function for multiple models

I have trained two classifiers .. Text Classification and Image Classification. So both models gives score for each class. For example there are 3 classes. Each model give array of 3 confidence score ...
0
votes
1answer
96 views

Precision, recall and accuracy metrics significantly different between training/validation and actual predictions

I have two sequential models built with Keras that train on data from a CSV file. This is how they are built ...
0
votes
3answers
41 views

converting array to a true/false matrices

I have a data set where each record is a json document with a label, and an array of signals. The signals will vary for each record: ...
0
votes
1answer
200 views

How does class_weight work in Decision Tree?

I am interested in Cost-Sensitive learning. And I am trying to understand how class_weight in DecisionTree works in terms of math. I read a lot of articles that ...
2
votes
1answer
30 views

How does the inertia cython implementation in scikit-learn for kmeans work? [closed]

Specifically, what do the & symbol stand for? and why is the column index always 0? ...

1
3 4
5
6 7
40