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.
2,312
questions
1
vote
1
answer
59
views
Extremely negative r^2
I use a linear regression to predict house prices (https://www.kaggle.com/c/house-prices-advanced-regression-techniques/overview). My linear regression sometimes works great with R^2 of 0.8 and ...
1
vote
0
answers
73
views
How marginal contributions of adding a variable in a model is calculated in determining SHAP feature importance?
I was trying to find feature importance using SHAP values in python for Isolation Forest. SHAP calculates the feature importance of a feature($i$) pertaining to a model($f$) for a datapoint($x$) using ...
1
vote
0
answers
55
views
Predict pixels in optdigits data set
I'm using this dataset : https://archive.ics.uci.edu/ml/datasets/optical+recognition+of+handwritten+digits
a dataset that consists of 65 columns , the last column is the label for 10 classes i.e 0,1,2,...
1
vote
0
answers
99
views
Dot product of two matrices in NLP how can i get this error be solved [closed]
from sklearn.metrics.pairwise import linear_kernel
sim_matrix = linear_kernel(tfidf_matrix, tfidf_matrix)
when I try to get dot product I am getting this errro
<...
1
vote
0
answers
61
views
Label spreading for classification/clustering problems
I have a question regarding label propagation and label spreading semi-supervised algorithms. I am working on building a look-alike model to identify marketing personas. Using supervised learning ...
1
vote
1
answer
142
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?
1
vote
1
answer
121
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
1
answer
605
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 ...
1
vote
0
answers
21
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 ...
1
vote
1
answer
44
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
1
answer
1k
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 ...
1
vote
1
answer
1k
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 ...
1
vote
1
answer
82
views
Classification using texts as features
I want to build a classification model to match customers and products. I have a description of each product, and a description of each customer, and the label : ...
1
vote
0
answers
89
views
How to evaluate KDE against histogram?
I am currently testing some approaches for density estimation, and I think the basic approach of histograms may not be the best option to me and KDE is certainly a good alternative to go. While ago I ...
1
vote
1
answer
111
views
What is different between R2 and mean of R2 in multiclassification probelm? Which one is correct?
I have a question. I have a big dataset (unfortunately confidential).
What I did?
I have trained my model with Naive-Bayes.
...
1
vote
0
answers
26
views
Multiclass Classifier comparison decision regions
How can I get the very same effect of this tutorial in Scikit Documentation with more than 2 classes?
Let's say we'll keep only the first dataset (the linear separable one) and substitute it with <...
1
vote
1
answer
119
views
Accuracy over different sample sizes from dataset
What I'm trying to do is predict how much more data would help in a classification task.
So, what I'm doing is bootstrapping entries in my dataset to get a sample, with a specified size. Then, I fine-...
1
vote
0
answers
192
views
Implementing Connectivity: "IndexError: too many indices for array: array is 3-dimensional, but 4 were indexed"
I am trying to implement connectivity as a feature within my code, but am unsure of how to fix this error code. Here is my code up until the point of the error.
...
1
vote
1
answer
347
views
Getting very low/ wrong accuracy from RandomizedSearchCV
I am currently using RandomizedSearchCV to optimize my hyper-parameters. However the reported scores of each iteration is very low. When I then evaluate the highest scoring candidate I get very high ...
1
vote
0
answers
59
views
How to use sklearn's Matrix factorization to predict new users' scores
I'm trying to use sklearn.decomposition.NMF to a matrix R that contains data on how users rated items to predict user ratings ...
1
vote
0
answers
72
views
Can you estimate average precision from log loss?
I am doing my final thesis in the field of Deepfakes and their detection. The final outcome is to have a binary classifier which could predict which video was updated and which was not. In other words,...
1
vote
0
answers
26
views
KNN with high-variance data [closed]
KNN doesn't work well with high-variance data, so how should I fit my data?
Here is an example of what the data looks like:
1
vote
2
answers
810
views
How to combine two logistic regression models trained on different set of data?
My data has a hierarchy structure - meaning that there is an N class at level 1 and an M class at level M. After training both models separately with a different set of data (both are Logistic ...
1
vote
0
answers
48
views
How do I convert strings in a dataframe column to int or float [closed]
Encoding the column seperately works ,but when I try it on the dataset directly it throws an error.
The error is something like this.
...
1
vote
0
answers
63
views
How to compare hyperparameter tuning in R and Python
I tried random forest in both R (Caret) and Python (Scikit-learn), but the results differ drastically.
Pearson correlation between predicted value and actual value was 0.2 in python whereas 0.8 in R.
...
1
vote
0
answers
584
views
Can elastic net l1 ratio be greater than 1?
I have multiple datasets that I trained with ElasticNetCV (sklearn), and I noticed that many of them selected l1_ratio = 1 as ...
1
vote
2
answers
1k
views
How to interpret my logistic regression result with statsmodels
so I'am doing a logistic regression with statsmodels and sklearn.
My result confuses me a bit. I used a ...
1
vote
0
answers
392
views
Best practice to select precision vs. recall threshold for a binary classifier
I have a logistic regression model in Scikit-Learn doing a binary classification.
Looking at the Roc curve for the classifier I can see that it performs really well:
The AUC score is 0.99 which is ...
1
vote
0
answers
62
views
Machine Learning algorithms and Panel data
I have a large panel dataset composed of $N$ stocks, $T$ quarterly dates and $K$ features for each stock. The dataset looks like the following:
...
1
vote
1
answer
597
views
Distribution of Regression Residuals: Is this a normal distribution?
I've created a histogram as well as a QQPlot from the residuals of my Regression Model:
Mean: 0.35
Standard Deviation: 18.14
Judging from these plots, is it okay to say that my residuals are normally ...
1
vote
0
answers
75
views
Sklearn - multiclass text classification
I took a challenge to classify bugs (by scanning their logs) into a different groups (classes).
I've already accomplished part of the task by fetching + cleaning the data, but I'm now stuck on getting ...
1
vote
0
answers
91
views
Issue with miscount on test train split in Python
Problem
Hey everyone. I think I am missing something incredibly easy, but because I am wokring in resampling for the first time it is giving me all sorts of inadequacy. I performed an ADASYN up sample ...
1
vote
1
answer
331
views
Comparing TFIDF vectors of different shapes
I'm working on a project using TF-IDF vectors and agglomerative clustering -- the idea is that the corpus of documents increases over time, and when a new document is added, the mean cosine similarity ...
1
vote
0
answers
28
views
Performing Regression on Text and Image together in the most efficient way
I have a dataset with texts and images. The texts are present in a CSV file, which I am able to read using Pandas. The CSVs contain the image names, and I have the corresponding pngs which are ...
1
vote
0
answers
139
views
How can I use a validation set to tune the hyperparameters of an XGBClassifier?
I'm currently building a ranking model using an XGBClassifier.
I have training, testing, and validation sets. I want to use the validation set to tune the hyperparameters of the XGBClassifier before ...
1
vote
1
answer
33
views
Classifying based on irregular number of features
Ok, so I am trying to classify a rather large data set where the training set has some peculiar issues...
There are a different number of features available for each row. For example, I might have 10 ...
1
vote
0
answers
25
views
I'm worried that I'm training my model wrong
So I'm trying to classify some fashion mnist like photos into either boots or sneakers. I'm using a perception from sklearn to do so. The data set is a CSV containing pixel values. The model is ...
1
vote
1
answer
39
views
adding a feature as "generic"
I am using sklearn and python, to build a "malicious" login identifier. Reading some documents and examples, I chose the RandomForest classifier, then I decided to use the following features:...
1
vote
1
answer
2k
views
Convert Neural network to Keras Classifier
I am training a Neural Network for Multi-Class classification. After successfully training it and validating the model through cross-validation, I would like to use this network inside a voting ...
1
vote
0
answers
645
views
SVM on BERT-Embeddings with very small dataset does not converge
I am trying to reproduce the results from this paper where they use a linear SVM on top of BERT-Embeddings for text-classification. They use the average of the token-embeddings which results in a 768 ...
1
vote
0
answers
215
views
How to implement large-scale Poisson Regression in Python
I am trying to implement a Poisson Regression in Python to predict rates. I am dealing with a ton of data (too much to store in a DataFrame), which means that using the standard statsmodels.api GLM ...
1
vote
0
answers
25
views
Use predicted data to improve Multinomial Naive Bayes model for text classification [closed]
For a small project, I am making use of Naïve Bayes Multinomial Model to do some text classification. It has shown some very promising results, especially since I don't have a lot of Training data.
...
1
vote
0
answers
15
views
Redo preprocess on unknown row
I'm trying to write a script to get the most similar rows in a certain dataframe, based on a single row. Using scikit-learn
The method I need is ...
1
vote
0
answers
237
views
Stacking - Appropriate base and meta models
When implementing stacking for model building and prediction (For example using sklearn's StackingRegressor function) what is the appropriate choice of models for the base models and final meta model?...
1
vote
1
answer
350
views
Is it a good practice to evaluate model performance by comparing the metrics of rescaled (inverse transformed) predictions and true target values?
I am now working with a Linear Regression for a time-series regression problem (I am sorry that I cannot say too much about the problem and feature vector due to NDA).
I scaled both the input values ...
1
vote
1
answer
53
views
General practices for building an incremental learning model which never forgets?
I'm new to datascience and appreciate your sage advice! I need to build an incremental learning model, and I know there's a lot that goes into something like that, but I'd like to highlight the most ...
1
vote
1
answer
271
views
How can access to modify feature_importances of Random Forest Classifier model?
My goal is to extract the feature importances from already trained random forest classifier and transfer them to another classifier. How this can be done? and How can access to modify ...
1
vote
1
answer
37
views
Escaping from overfitting hell: introducing regularization vs increasing training data
I am trying to identify noisy intervals in geomagnetic data using logistic regression, working with scikit-learn.
Here is a typical spectrum of the data that I am working with:
In this example, the ...
1
vote
1
answer
33
views
create sequence of non dictionary words
I have a few word vectors-
recvfrom,sendto,epoll_pwait,recvfrom,sendto,epoll_pwait
getuid,recvfrom,writev,getuid,epoll_pwait,getuid
Now i want to tokenized them ...
1
vote
0
answers
587
views
How to plot centroids and clusters resulting from a KMean model based on a text variable
I hope you can help as after several attempts, I'm no longer sure I can get a decent result.
I have a text corpus made of several documents, like the one below (which has been simplified for the sake ...