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
2answers
37 views

How do I correctly build model on given data to predict target parameter?

I have some dataset which contains different paramteres and data.head() looks like this Applied some preprocessing and performed Feature ranking - ...
0
votes
0answers
7 views

Clustering list of list of integers

I have ~100 sets of samples with integer IDs. For example, 3 of them could be: a = [0, 1, 3, 4, 6...] b = [1, 5, 9, 102...] c = [1, 7, 10, 42...] I am looking to ...
0
votes
1answer
13 views

Does this line in Python indicate that KNN is weighted?

Does this line in Python indicate that KNN is weighted? clf = KNeighborsClassifier(n_neighbors=5, metric='euclidean', weights='distance') Are the weights the ...
2
votes
1answer
42 views

Item-based recommender using K-NN

I'm trying to build an item-based recommender using k-nn. I have a list of items, all of which have some properties (features) in common. ...
0
votes
1answer
326 views

How can I extract the residual array from the Scikit Learn PCA routine?

The Nipals PCA algorithm calculates the scores and loadings of a data array iteratively. If only (say) 3 scores and loadings are calculated from a data array with more than 3 variables, there is a ...
1
vote
1answer
10 views

How to use ADWIN with multiple columns

I want to perform drift detection on data with multiple input values (x0, x1, x2, x3). I'm using an adaptive window algorithm found from sci-kit found here. Doing ...
2
votes
2answers
451 views

How can I find anomalies in each row of data?

I have some reported data I want to spot anomalies on. The columns are a facility name then monthly reports of that given facility. ...
0
votes
1answer
272 views

How to calculate mean and standard deviation of all features in a class identified by k-nearest neighbors?

I have classified my data into several neighborhoods using k nearest neighbors. I need to efficiently calculate the mean and standard deviation for all features of data points belonging to a ...
1
vote
2answers
31 views

Can I force DecisionTreeClassifier to use integer conditions when the variable is integer?

I'm trying to visualize a decision tree in python for the purpose of explainability. I noticed that a condition like "NumGoals >= 1.23" could be quite vague for the user and I would much rather to see ...
2
votes
2answers
21 views

What is my training score the mean_train_score or mean_test_score?

I am using sklearn to train some models (random forest, decision tree). For the training I am using RandomsearchCV with Stratified k-fold as cross-validation. Then I make a predictions on the test set ...
2
votes
0answers
29 views

Why does classifier chain ask for at least 2 classes, when I have it

I'm using Classifier Chain with logistic regression and when i try to use fit, i get This solver needs samples of at least 2 classes in the data, but the data contains only one class: 1 but I'm ...
-3
votes
0answers
16 views

valueError:Expected 2D array, got scalar array instead ,reshape(1,-1) [closed]

This is the particular section of code: ...
1
vote
2answers
43 views

logistic like curve fitting using machine learning

I have a set of points of a function k(x). I am trying to do some curve fitting to find the exact k(x) function. It seems that the data points fit to a logistic like curve only a little shifted and ...
2
votes
2answers
6k views

feature names in LogisticRegression()

I want to know feature names that a LogisticRegression() Model has used along with their corresponding weights in scikit-learn. I can access to weights using coef_, ...
1
vote
1answer
19 views

Random Forest Model Giving Same Accuracy for different feature sets after tuning

I am having this weird issue and cannot seem to find a solution. I am trying to tune a different random forest model for every different feature-set. Basically from a given data set, I have created 3 ...
1
vote
1answer
35 views

Python sklearn PCA transform function output does not match

I am computing PCA on some data using 10 components and using 3 out of 10 as: ...
1
vote
0answers
15 views

How to create an roc plot and calculate AUC for an svm (that does not return probabilities)?

I have some SVM classifier outputting final classifications for every sample in the test set, something like 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1 and so on. The "...
0
votes
1answer
13 views

Testing if a sample fits into an existing cluster

I have a sample of data I'd like to create a model from, which would create N clusters. After the fitting to clusters, I'd like to test various samples against the existing clusters, seeing if the ...
1
vote
1answer
63 views

Why might trees work so much better than boosting classifiers?

I am predicting 10 classes label encoded using scikit-learn with 6 factors, 1.2M cases. DecisionTreeClassifier RandomForestClassifier ExtraTreesClassifier give accuracies (and precision and recall) of ...
2
votes
2answers
5k views

Creating Balanced Dataset Using Scikits

I have a classic User-Item dataset where each row (i.e., (user, item)) indicates the action of a user clicking/selecting an item....
15
votes
3answers
3k views

Difference between OrdinalEncoder and LabelEncoder

I was going through the official documentation of scikit-learn learn after going through a book on ML and came across the following thing: In the Documentation it is given about ...
0
votes
1answer
2k views

How to show progress of sklearn.multioutput.MultiOutputRegressor and XGBRegressor?

Is it possible to show the training progress of the MultiOutputRegressor in sklearn? When a huge dataset is processed, my program runs a long time and I have no clue how long it will take. I have ...
0
votes
2answers
29 views

How can I improve the results of my clustering

I am working on a project with the idea to cluster the sound waves of key strokes on a computer. So far what I have done was recorded about 50 keystrokes per key (only have done 1 - 10 so far), found ...
0
votes
1answer
31 views

metric accuracy for linear regression and non linear regression

Is there a one size fit all metric to measure accuracy / error rate for both linear or non linear regression models? For example adjust R2 is only for multi linear regression (or so they say). RMSE ...
1
vote
1answer
19 views

Functions in scikit that detect outliers automatically?

I know a way to visualize outliers is to make a box plot, but wanted to know if scikit had any quick ways to detect outliers for each variable?
0
votes
2answers
48 views

How to train model to predict 1 value from multiple input samples

Very new in ML... Actual problem is more complex, but I'll give it shorter. Train data is a collection of samples, describing features of some items. There are many samples for each item. So ML ...
0
votes
1answer
41 views

adding a supervizing process during knn process

I try to improve my knn regression process (I use sklearn / python, but it doesn't matter). Because I can have a scientific point of view on my data, I would like to improve my results. I give you an ...
0
votes
0answers
317 views

Machine Learning Model Alert/Notification system - Python

Let's say, I have a Machine Learning model built and does predictions for the future. If I have some predicted values that exceed a threshold, can I set up some type of notification system? It can be ...
0
votes
2answers
18 views

How do I fix mis-rendered matplotlib?

How do I correct my data or format it so that it is presentable, and fix my graphs? Dataset is 345551 rows × 7 columns. I am using numpy, pandas, seaborn and matplot lib. It seems that my pricing ...
0
votes
1answer
27 views

bad input shape (5634, 2)

I tried everything and I am not sure how to resolve the following error: "ValueError: bad input shape (5634, 2)" This is my first machine learning example so please bear with me. This is the python ...
1
vote
3answers
1k views

How to use sklearn train_test_split to stratify data for multi-label classification?

I am attempting to mirror a machine learning program by Ahmed Besbes, but scaled up for multi-label classification. It seems that any attempt to stratify the data returns the following error: ...
0
votes
3answers
23 views

How to find the driver features towards a particular result in Classification problems

In a classifier model, we can predict the outcome class, but here I need to find out the features that drive towards a particular result in a classification problem, that are a strong indicator of a ...
1
vote
2answers
90 views

how does splitting occur at a node in a decision-tree with non-categorical data?

According to a website (:http://dataaspirant.com/2017/01/30/how-decision-tree-algorithm-works/) , these values are chosen randomly: I don't think this is the case with any optimized way of creating ...
1
vote
4answers
93 views

How to combine GridSearchCV with Early Stopping?

I'm a beginner in machine learning and want to train a CNN (for image recognition) with optimized hyperparameter like dropout rate, learning rate and number of epochs. The optimal hyperparameter I ...
2
votes
3answers
52 views

GridSearchCV vs RandomSearchCV and How it works?

GridSearchCV vs RandomSearchCV Can somebody explain in-detailed differences between GridSearchCV and RandomSearchCV? And how the algorithms work under the hood? As per my understanding from the ...
1
vote
0answers
14 views

Is kFoldLoss simply the average classification error?

I'm using a kNN classifier in MATLAB to classify ECG signals, with 5 fold cross validation I get almost 97% accuracy. However, I'm not entirely sure if this is truly the accuracy value. By default the ...
0
votes
2answers
28 views

Sklearn LocalOutlierFactor contamination parameter

Can anyone provide an intuitive explanation of the choice of contamination parameter used in sklearn's LocalOutlierFactor implementation when ...
0
votes
1answer
11 views

Feature Selection algorithm/library for CRF

I am using the Conditional Random Fields CRF suite scikit-learn wrapper algorithm. I have read on the literature various approaches for feature selection, but I cannot find any on that package or, ...
1
vote
0answers
297 views

How to calculate pedigree function in diabetes prediction?

I am developing a model for diabetes prediction using this dataset using Logistic Regression. I have completed the model and my input variables are - Pregnancies, Glucose, blood pressure, BMI, ...
6
votes
2answers
4k views

Predicting probability from scikit-learn SVC decision_function with decision_function_shape='ovo'

I have a multiclass SVM classifier with labels 'A', 'B', 'C', 'D'. This is the code I'm running: ...
0
votes
1answer
58 views

ValueError: Expected 2D array, got 1D array instead

I would like to extract the 20 most informative features of a very large set of features $X$ coming from a dataset containing clinical data by using the RFE function from scikit-learn in Python. $X$ ...
0
votes
1answer
24 views

Naive Bayes / SVM classifiation - min. number of records (Python)

I am doing text classification with Python. I have around 120 records with 2 columns: text class I tokenize, stem and lematize the words, I also did some of my own text preprocessing. When I run the ...
0
votes
0answers
18 views

Split time series data into Train Test and Valid sets in Python

I'm working on a project in which I have combined 2 datasets if time series (e.g D1, D2). D1 was with the 5-minutes interval and ...
0
votes
2answers
25 views

Managing NaN in target variables (testing)

Please can someone advise me on how to handle NaN in my target variables set? I've tried a variety of things but none is working. Here's what I've tried: Imputing zeros (0) in Y_test Replacing NaN ...
1
vote
1answer
34 views

What to do with large number of collinear variables?

I have this time-series dataset that has 63 features, out of which 57 were manually engineered. While checking for collinearity, I get this correlation matrix: As can be seen there are a number of ...
3
votes
2answers
36k views

Could not convert string to float error on KDDCup99 dataset

I am trying to perform a comparison between 5 algorithms against the KDD Cup 99 dataset and the NSL-KDD datasets using Python and I am having an issue when trying to build and evaluate the models ...
2
votes
1answer
66 views

Is there any optimal way on feature selection for more than one classification algorithms?

I have a wine dataset with 13 features that indicates 3 different wine classes (target), and k-NN, SVM with linear kernel and SVM with rbf kernel algorithms to be tried with this dataset. My goal is ...
2
votes
1answer
896 views

K-fold cross validation of scikit-learn with confusion matrix of Keras

I intend to display confusion matrix using Keras while K-fold of scikit-learn. My code using Keras is: ...
3
votes
1answer
2k views

Predict the accuracy of Linear Regression

How do I test if the predicted values in Linear Regression model are matching with the actuals? I tried using - Confusion matrix, but I get this error - ...