Questions tagged [scikit-learn]

A machine-learning library for Python. Use this tag for any on-topic question that (a) involves scikit-learn either as a critical part of the question or expected answer, & (b) is not just about how to use scikit-learn.

Filter by
Sorted by
Tagged with
0
votes
0answers
6 views

Calculate the confidence score (decision_function) of perceptron, by the signed distance of that sample to the hyperplane

I've implemented the binary version of perceptron from scratch, in python. I would like to use it for one vs all classification, by using the one vs all of sklearn. for that, I need to implement the ...
1
vote
0answers
10 views

Gaussian Process Classifier and specifying kernel

I am using scikitlearn's gaussian process classifier and either I don't think I understand how the kernel is used (more likely), or there is an error in the module (less likely). In short, the ...
0
votes
0answers
12 views

evaluating an empirical multivariate PDF in python

I have multivariate (bivariate in the simplest case) residuals from a VAR time series regression and I'd like to estimate the joint pdf and then be able to draw from this pdf. If I have bivariate ...
2
votes
1answer
21 views

Which algorithm is implemented in sklearn's SVM method?

I'd like to know which exact version of svm is implemented in slearn. The references section on sklearn's svm page cites libsvm package and a paper from 1999 which is about comparing classification ...
0
votes
0answers
23 views

How does scikit-learn handle high dimensionality in its Gaussian Mixture Model implementation?

I have a dataset of 50,000 rows that I plan to fit with scikit-learn's GMM model. The dataset has 15 features, therefore I treat each row as a vector in the space $\mathbb{R}^{15}$. My question is, ...
0
votes
0answers
13 views

Applying different kernels to parts of a dataset and merging the output [duplicate]

I am trying to create a classifier using SVM on a dataset that is composed of 6 sets of data for each of my observations. When I train the SVM (rbf kernel), I get a better performance of the ...
2
votes
0answers
14 views

How to prepare the training data for Support Vector Machine?

I'm currently doing some comparison of Naive Bayes Algorithm and Support Vector Machine classifying news to see each algorithm's accuracy. I already know how to prepare the training data for Naive ...
0
votes
0answers
8 views

Scaling test set based on training will cause test set to have values greater than the scale

I have a time series data that does not have an upper limit (data is somewhat monotonically increasing). Making the Test set values larger than the training set. (I am not shuffling because time ...
0
votes
1answer
10 views
0
votes
0answers
15 views

sklearn ColumnTransformer based preprocessor outputs different columns on Train and Test dataset [migrated]

I was trying to learn how to use Pipelines and ColumnTransformer to effectively preprocess data before Regression. Here's my attempt: ...
0
votes
1answer
121 views

Logistic Regression Loss Function: Scikit Learn vs Glmnet

The loss function in sklearn is $$\min_{w,c}{\frac{1}{2}w^Tw+C\sum_{i=1}^N{\log(\exp(-y_i(X_i^Tw+c))+1)}}$$ Whereas the loss function in glmnet is $$\min_{\beta,\beta_0}{-\bigg[\frac{1}{N} \sum_{i=...
1
vote
0answers
35 views

PCA returns duplicated features for different components

I performed (sklearn) PCA on a (1416960,140) pandas DataFrame. The resulting components_ attribute is a matrix where each ...
0
votes
0answers
10 views

Using Gaussian Process Regression in scikit-learn

I have a simple dataset with multiple trials of position over time, and I'm trying to fit a Gaussian Process over it. Here's a plot of all the raw data (6180 data points): My goal is to fit a ...
2
votes
0answers
41 views

R alternative to scikit-learn [closed]

As a statics researcher, I've been using R since university and I know it quite well, I also know that it's immediate, but it quickly gets chaotic, and this also happens because of the variety and ...
0
votes
1answer
25 views

Derivative of all the parameters in Logistic Regression

$\mathcal{L}$ is the loss function, $\mathcal{L} = y_i \text{log} \sigma(z) + (1-y_i) \text{log} (1-\sigma(z))$, where $z = \sum_i w_ix_i$, with $w_i$ representing the weights and $x_i$ the features. ...
1
vote
0answers
127 views

Predict output when an outcome occurs - Python

I have a dataset containing a continuous time series. There is approx 50,000 continuous samples with 3 columns. ...
2
votes
2answers
29 views

How to interpret the meaning of KMeans clusters

Using the elbow method, I determine the correct number of clusters for the KMeans function. Having done that, I still have no idea how to interpret the clusters in a meaningful way. If someone asked ...
0
votes
0answers
18 views

Calibration of RF classifier: with sample_weight vs. without sample_weight

I am working with Random Forest binary classifier and use isotonic regression (using CalibratedClassifierCV from sklearn) for probability calibration. The question: assuming that RF classifier is ...
0
votes
0answers
17 views

Latest XGboost and Sklearn giving error [migrated]

xgb=XGBClassifier(objective="binary:logistic", n_estimators=100, random_state=42, eval_metric=["auc"]) xgb.fit(X_train, y_train) KeyError ...
0
votes
0answers
14 views

Understanding probability calibration with isotonic regression in sklearn

After reading sklearn manual it was not very obvious for me to understand how Isotonic regression works in the case of probability calibration (using CalibratedClassifierCV). I briefly read sklearn's ...
0
votes
1answer
25 views

How improve linear regression model in my example

I try to perform an example of linear regression model in python. The aim is find a linear relationship among two features in my dataset, this features are 'Year' and 'Obesity (%)'. I want train my ...
1
vote
0answers
22 views

Calculating three average precisions and a single value for ROC from raw predicted class outputs

I'm not a statistician or mathematician so I apologize if I use any terms incorrectly. Please do point out any errors in my use of terminology. The four values I need are the equivalent of Weka's ROC ...
0
votes
0answers
9 views

sklearn Logistic Regression Sample Weights & Duplicate Samples

Can you achieve the same model w/ two different, but arguably same datasets: Dataset A: Duplicate samples w/o sample weights Dataset B: No duplicates w/ sample weights where the sample weights equal ...
0
votes
1answer
16 views
1
vote
2answers
26 views

Random forest on data having only one feature

So I'm applying Random forest regression from sklearn library to a dataset having only one feature and I'm getting a very good score. The output labels are continuous. The problem is I don't quite ...
1
vote
1answer
26 views

how to combine recursive feature elimination and grid/random search inside one CV loop?

I've seen taught several places that feature selection needs to be inside the CV training loop. Here are three examples where I have seen this: Feature selection and cross-validation Nested cross-...
0
votes
0answers
33 views

Is it reasonable to do log transformation on both input and output variables in multioutput regression problem?

I have been working on a small machine learning project, and I decided to use regression algorithms to solve the problem, however, I have encountered some problems in the project. Let me show some ...
0
votes
0answers
11 views

Recursive Feature Elimination with a maximum number of features?

I want to find the optimal number of features and feature names in a dataset with 500 features. Let’s say that I ran recursive feature elimination with cross validation (RFECV) and found 25 optimal ...
1
vote
0answers
16 views

OneHotEncoding and Scaler in Pipeline, avoid data leak?

so I have my data and split it in the beginning in test and train set. Then I apply following Pipelines on it: ...
2
votes
0answers
21 views

Literary author classification from books content

Some background: I'm pretty much a newbie in NLP and in machine learning in general, I'm currently following some courses in my university about these topics. I'm working on my first ml project using ...
1
vote
1answer
17 views

Sklearn PCA Calculation Seems to Use Truncated Division as Opposed to Floating Point Division

I am working with the following dataset: Housing dataset From this dataset, I am only interested in the following columns: GrLivArea (independent variable), and SalePrice (dependent variable). What ...
3
votes
1answer
14 views

Machine learning (KNeighborsRegressor) Train score = 1

I'm trying to understand the outcome of this model. What I don't understand is why the score train is always one. I understand that this type of behavior is due to overfitting. However, I have already ...
1
vote
1answer
18 views

Why accuracy and prediction changes when random state is changed in machine learning?

When random state is changed between 0,1,2 manually I observed accuracy is changing and at the same time when the model was checked with random state '0' and with internally split X_test data it ...
1
vote
3answers
57 views

Logistic Regression Failed in statsmodel but works in sklearn; Breast Cancer dataset

I am learning about both the statsmodel library and sklearn. I am trying to construct a logistic model for both libraries trained on the same dataset. In sklearn, the following works: ...
1
vote
1answer
47 views

Interpretation of y-axis in partial dependence plot

First off, I know there are many questions on this site similar to this one. I've read them, and have not been able to find a solution. In Elements of Statistical Learning, the following figure shows ...
0
votes
2answers
33 views

How to train model when Data is consist of matrices [closed]

I am new to ML and python. I am facing an issue related to the training SVM model. I have a training data file size (200,50,120). Where 200 are my examples (or experiments). While Actual data is a ...
1
vote
0answers
14 views

Multi Output Regressor Random Forest - Every output looks at different features

I am supposed to predict a hourly timeseries T 48 hours ahead in the feature. For technical reasons, I can only use a Random Forest Regressor, with 48 output ...
1
vote
1answer
28 views

Categorical and Numerical Features - Correlation [closed]

I am working with a dataset that has both numerical and categorical features. I have seen this post which discusses the problem in R, and was wondering if someone could recommend the same in ...
0
votes
1answer
27 views

Algorithm for recognizing similar data?

I've been given a youtube trending dataset with the assignment to make a predictive model which outputs the probability of a video getting into trending with at least 60% accuracy. I have the title, ...
3
votes
0answers
98 views

Mann Whitney U and ROC AUC relationship

I've been learning about the relationship between Mann-Whitney U. Supposedly, the area under the ROC curve should be U/(n0 * n1), where U is the Mann-Whitney ...
0
votes
0answers
9 views

What algorithm suits for very uncorrelated features towards the target in classification problem

My problem is classifying product type based on sales. I have my features which are very lowly correlated with my target (only 0.1 or below). I have done ...
0
votes
1answer
33 views

How can I replicate the process sklearn calculates the posterior probabilities?

I have a question pertaining to scikit-learn methods. Can I get the same probabilities obtained with predict_log_proba() by hand calculating the likelihoods and prior obtained with feature_log_prob_ ...
0
votes
0answers
11 views

Can I adjust sample_weight in Scikit-learn for each feature in each sample separately?

My understanding is that when using sample_weight when training a classification model in Scikit-learn, I can supply different weights for each sample. Is it also possible to give a different weight ...
0
votes
1answer
31 views

Partial Least Squares Using Python - Understanding Predictions

I am having trouble constructing/applying a regression equation from PLS to make a prediction in a manner that can obtain the same predicted values that the model produces when calling the model....
0
votes
1answer
27 views

Can training with too much data cause overfitting in a random forest?

I have a dataset with around 3.4 million records. I am predicting a binary target variable. The distribution of the target variable is 10%. I am using 17 features for prediction and am comparing ...
1
vote
1answer
29 views

Bagging classifier vs RandomForestClassifier [duplicate]

Is there a difference between using a bagging classifier with base_estimaton=DecisionTreeClassifier and using just the RandomForestClassifier? This question refers to models from python library called ...
1
vote
1answer
16 views

LDA vs QDA on the AT&T dataset, poor QDA performance

I am obtaining two very different accuracies for the AT&T face database when fitting the model with lda & qda. Before using QDA I first search for the ideal regularisation parameter, AFAIK the ...
0
votes
1answer
13 views
0
votes
1answer
14 views

Obtain feature names from model when training data is not available

Is it possible to obtain the feature names expected by a model if we don't have the training data available? I want to ensure that I am giving the model the data with features in the correct/expected ...
4
votes
2answers
49 views

SciKit Learn: Multilayer perceptron early stopping, restore best weights

In the SciKit documentation of the MLP classifier, there is the early_stopping flag which allows to stop the learning if there is not any improvement in several ...

1
2 3 4 5
27