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
0answers
11 views

How to configure null hypothesis or what's the null hypothesis when using sklearn?

I'm predicting how BMI, GDP, ... factors affect life expectancy. Firstly, I tried to select topK features. ...
1
vote
1answer
26 views

How does transform work?

I was looking at the source codes of MinMaxScaler on Github. I know that when you fit a preprocessing class to a dataset, it takes the data and prepares it for transformation. Let's say, I fitted ...
0
votes
1answer
28 views

scikit learn target variable reversed (DecisionTreeClassifier)

I created a Decision Tree Classifier using sklearn, defined the target variable: ...
1
vote
1answer
27 views

Training is not stable with extreme class imbalance

I'm dealing with a multi-class classification problem with around 30 categories. This problem has a severe class imbalance: Around 300 examples for the least common class. Around 100k examples for ...
0
votes
1answer
29 views

Node Importance in scikit learn

I'm trying to understand exactly how feature_importances in scikit-learn's RandomForestClassifier works. I managed to find this helpful link explaining most of the process: https://towardsdatascience....
0
votes
1answer
19 views

How does sklearn random forest decide feature threshold at node splitting exactly?

Thinking of the RandomForestClassifier function in sklearn.ensemble, I understand that at each non-terminal node the algorithm: Randomly selects a subset of size max_features from the set of all ...
0
votes
0answers
11 views

Using class weight in decision trees with Information Gain

How are weights considered in a decision tree when we want to maximize Information Gain? In other words, what would the entropy calculation become when weights are involved? I can guess either $$ e_1 =...
0
votes
1answer
11 views

Train and predict two labels in a single process

I have a python program that makes predictions using scikit-learn RandomForestClassifier. The label is called "default" and it's the default status of a ...
1
vote
0answers
14 views

Using scikit-learn iterative imputer with extra tree regressor eats a lot of RAM

I'm imputing a table around 150K by 60 floats and has about 45% missing values, I'm using ExtraTreeRegressor with IterativeImputer ...
0
votes
2answers
29 views

Applying Sci-kit Learn's kNN algorithm to Fresh Data

While I was studying Scikit-learn's kNN algorithm, I realized that if I use sklearn.model_selection.train_test_split, the provided data gets automatically split ...
0
votes
0answers
15 views

scikit-learn sample weight interpretation

I'm trying to use scikit-learn to plot a confusion matrix from raw data I have obtained (contains just predictions and ground truths). The data contains a total of 4 classes: ...
0
votes
0answers
15 views

Why is my training score below my testing score?

I'm learning data science, and currently practicing with the Titanic Dataset. I'm doing a simple logistic regression using scikit-learn, and plotting the learning curves of that model with Matplotlib: ...
0
votes
0answers
7 views

Metrics for each class in a multi-class training/testing dataset

I am working with the NSL_KDD Dataset for cyber security and training a number of different models. There are five different classes: benign, dos, probe, r2u, and u2l. (I am using scikitlearn.) I ...
0
votes
0answers
11 views

How do i improve my accuracy in LinearSVC? Looking for better approaches/advices

I'm struggled to get accuracy around 70 used all the tricks and tips to improve it but couldn't make it my goal is to get at least 90+ accuracy. Trained 2 folders with 4000 images 2000 images for each ...
0
votes
0answers
11 views

ValueError: Input contains NaN, infinity or a value too large for dtype('float32') on predicting case (similar to titanic predicting)

I am still newbie on python with jupyter notebook I'd like to ask how to solve error "ValueError: Input contains NaN, infinity or a value too large for dtype('float32')" first I make ...
0
votes
1answer
41 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 ...
1
vote
1answer
25 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
12 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
13 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 ...
0
votes
0answers
18 views

sklearn FutureWarning message when running a CNN model

When I run my model, I am receiving the following error message: ...
1
vote
1answer
18 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
47 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
20 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
32 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
16 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
30 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
27 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
94 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
13 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
16 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
16 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
15 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
15 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
19 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
28 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 ...
3
votes
1answer
154 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
25 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
23 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
0answers
15 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
26 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
26 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
25 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
15 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
7 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 ...
2
votes
2answers
112 views

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

Suppose there are some classifiers as follows: ...
0
votes
1answer
23 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 ...
1
vote
3answers
36 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
115 views

How to use SMOTE in Stacking in SKLearn?

I have a data set X,y and split them to train and test data. ...

1
2 3 4 5
37