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
10 views

Why do i get different accuracy value when i use different values for random_state? [on hold]

I know the use of random_state. Please tell me why do i get different accuracy values for different value of random_state between 0-100? P.s: Im using it for DT and Naive Bayes.
0
votes
0answers
17 views

How to do Little’s MCAR Test using python? [on hold]

How can I execute Little's Test, to find MCAR in Python? I have looked at the R package for the same test, but I want to do it in Python. Is there an alternate approach to test MCAR? Is their any way ...
0
votes
1answer
6 views

Error while performing multiclass classification using Gridsearch CV

I am trying to solve a multiclass classification problem using SVC as the base estimator and GridSearchCV to tune my results. Mentioned below is the code and the error being received: ...
1
vote
0answers
22 views

Bayesian Optimization does not improve RMSE of XGBoost

I have some serious problems with Bayesian optimization of an XGBoost model. The optimal hyperparameters resulting from Bayesian Optimization lead to an RMSE that is higher than through ...
0
votes
0answers
9 views

Residuals Matrix in PLS in Python's scikitlearn [closed]

I'm running PLS on a small set of spectra data (31, 3326). I've run PLS on spectra data before, however with more samples, with no issues. However, on the small dataset, the same code never runs to ...
0
votes
1answer
34 views

Analyse distribution of class information in clustered data [on hold]

I want to cluster a data set with 100 features and more that 9 millions records. I have 300 labels on output, multiple observations for each label. ...
1
vote
0answers
51 views

RandomizedSearchCV - worse accuracy than standard parameters

I am currently training a text classification model to infer product category (198 different ones) from product names. After evaluating a few models I have decided to stick with a Random Forest (...
1
vote
0answers
18 views

Boundary point errors in PCA projection using sklearn

I am preparing a small example of a projection using python, numpy and sklearn to perform <...
0
votes
0answers
12 views
-1
votes
0answers
20 views

Do I have to scale my features again to the test set that I want predictions for? How do I apply and Export model predictions as a CSV in python?

I was able to generate an SVM model with an accuracy of 96%. The features have all been scaled (StandardScaler) and I have also upsampled the minority class (y=0). I want to be able to apply this SVM ...
0
votes
0answers
8 views

hinge loss functions in SVM

Hi as I am writing report regarding the topic SVM and I have to elaborate on the differences between SVC and linearSVC in Scikit Learn, I search online that the two algorithms differ in terms of hinge ...
2
votes
0answers
27 views

Feature selection using leave one out regression results

Disclaimer: I'm a basic scientist who only starting to dabble in ML I saw a presentation today where the presenter did feature selection by identifying the variables that resulted in a univariate ...
0
votes
0answers
9 views

Fitting KDE with scikitlearn and pandas to plot. However, distributions lie outside the range of data

I am fitting a distribution of scores ranging from 1-13 for a set of data using scikitlearns KDE functions and Pandas plot.kde. I have set the bandwidth with a gridsearchCV method. However, when the ...
1
vote
1answer
20 views

What does the y parameter in .fit() of scikit-learn's Gaussian Mixture Model do?

From my understanding, Gaussian Mixture Models are an unsupervised method and can perform clustering similar to k-means. In the scitkit-learn implementation of GMM, the .fit() function (and ....
0
votes
0answers
15 views

Is it a good idea to implement a sklearn model for a real time image processing application?

I'm testing a support vector machine (SVM) model trained with scikit learn library for image processing, but i don't know exactly if for real time this library could be better than tensorflow or both ...
0
votes
0answers
17 views

sklearn SVC never ending training, features extracted from VGG16

SVC is based on libsvm. When I train SVM with a small image dataset the training finishes but for a large image dataset not converging even after 11 hours on GPU server. ...
0
votes
1answer
31 views

does statsmodels support multi-level modeling for classifiers [closed]

I have searched and searched the statsmodels documentation for a useable multilevel classifier but have not found any at all. sklearn also provides no support for hiearchical classification models. Is ...
3
votes
2answers
53 views

What type of multi-label method does sklearn's random forest classifier use? [closed]

I have trained RandomForestClassifier on data with 3 labels. The label set Y looks like this: ...
0
votes
1answer
47 views

Is it compulsary to normalize the dataset if doing so can negatively impact a Binary Logistic regression performance?

I am using raw data set with 4 feature variables (Total Cholesterol, Systolic Blood Pressure, Diastolic Blood Pressure, and Cigraeette count) to do a Binominal Classification (find stroke likelihood) ...
0
votes
2answers
63 views

Discrete Regression with Neural Networks

I'm currently building a neural network(NN) for regression on a dataset that came from a lab experiment, each sample was ran against a sensor 10 times, yielding 39 independent variables having the ...
0
votes
0answers
18 views

How does sklearn.SelectKBest uses chi2 test on continous data?

I am asking a question very closely related to this one (same question as one of the answers). https://stackoverflow.com/questions/49847493/using-chi2-test-for-feature-selection-with-continuous-...
2
votes
1answer
84 views

Regression tree splitting (CART, Scikit Learn) [closed]

I am working with a Random Forest using scikit-learn and still have some questions and thoughts I am not sure about regarding the splits in regression trees: 1. It seems to me that scikit-learn's ...
0
votes
1answer
25 views

Machine Learning Algorithm implementation in Python [closed]

For a beginner in Machine Learning, if we have taken course from Andrew Ng's class, what is the correct approach to implement them? directly using the scikit learn algorithms or implementing them ...
0
votes
0answers
12 views

Precision of decision nodes in RandomForestRegressor

I have trained a RandomForestRegressor in Scikit-learn. I am comparing the prediction of new samples from the trained model versus my own implementation of running through the forest. ...
1
vote
0answers
63 views

Naive Bayes for Categorical Features (Non Binary)

How do i use Naive Bayes Classifier (Using sklearn) for a Dataset considering that my feature set is categorical, ie more than 2 categories per feature are present. I've looked everywhere, some ...
0
votes
1answer
29 views

What is the difference between sklearn IsolationForests score_samples and decision_function?

The predict method will output -1 (anomaly) where forest.decision_function(X) < forest.threshold_ and 1 otherwise. But what does ...
0
votes
1answer
15 views

Does it make sense to normalize vectors after PCA for cosine distance?

I start off with word2vec embeddings and process them in the following way: Standardize dimensions to mean 0 and standard deviation of 1 PCA to keep the top k-dimensional eigenvector, whereby ...
1
vote
1answer
16 views

Finding and using a single (best) decision tree from random forest to evalute a sample [duplicate]

Is there a way that we can find an optimum tree (highly accurate) from a random forest? The purpose is to run some samples manually through the optimum tree and see how the tree classify the given ...
0
votes
0answers
30 views

How to read/interpret a distance matrix?

I ran some data through scikit's MeanShift clustering and had it spit out a distance matrix. I don't know how to interpret the image or understand the value it provides. Just looking for a clear ...
0
votes
1answer
14 views

Retraining model in scikit learn Random Forest

I have a machine learning Random Forest model that predicts a certain variable. It's implemented with scikit learn and it works fine. Now, assuming that the prediction relates to month 1, I need a ...
0
votes
1answer
21 views

The idea behind sk-learn's combined grid-search and cross-validated estimators?

I am trying incorporate a formal strategy to find the most optimal set hyper-parameters for a machine learning algorithm. I understand you can either do a grid-search or a k-fold cross validation, ...
1
vote
1answer
32 views

K-Means clustering: optimal clusters for common data sets

I use scikit-learn to get IRIS and WINE clusters for evaluating an algorithm for K-means clustering. The K-means algorithm is a heuristic algorithm for solving the "minimum-sum-of-squares-clustering (...
0
votes
0answers
14 views

Using Random Forest to analyse repeated measures data [duplicate]

I have crop disease data categorized into 2 classes, i.e., healthy and diseased status of the crop. The aim of the analysis is to see how early the disease status can be detected in crop using ...
0
votes
1answer
50 views

Why the dot product of two vectors in sklearn is not a scalar? [closed]

In a 2d Euclidean space, Let point $a=(a_x, a_y)=(1,1)$; Let point $b=(b_x, b_y)=(5,1)$; Let point $c=(c_x, c_y)=(4,4)$; the squared Euclidean distance between point a and point b is equal to $(...
0
votes
1answer
38 views

In sklearn, it seems that `dot(x, x)` corresponds to `np.sum(X*X,axis=1)[:, np.newaxis]`, why is that? [closed]

In a 2d Euclidean space, Let point $a=(a_x, a_y)=(1,1)$; Let point $b=(b_x, b_y)=(5,1)$; Let point $c=(c_x, c_y)=(4,4)$; the squared Euclidean distance between point a and point b is equal to $(...
0
votes
0answers
35 views

Interpreting Local Outlier Factor (LOF) results

Using this example on the scikit-learn site, I am attempting to do some anomaly detection using LOF. What I end up with is this: ...
0
votes
1answer
49 views

Why does feature scaling improves accuracy? [duplicate]

With feature scaling we just change representation of the data. This can make our model run faster but how this can improve accuracy? It is the same data after all. When I train my SVM without ...
1
vote
1answer
44 views

Imputing missing values of one of the independent variable using dependent variable in addition to other independent variables?

I want to impute missing values of an independent variable say variable X1, the other independent variables are weakly related to X1. However, the dependent variable has strong relation with X1. I ...
1
vote
1answer
45 views

How to calculate tf-idf for a single term

I am following the tf-idf method described in this paper: Measuring, Predicting and Visualizing Short-Term Change in Word Representation and Usage in VKontakte ...
2
votes
1answer
165 views

SelectKBest score function with mixed categorical and continuous data

I am building a classification model where my label is categorical (0 or 1). I want to use scikit-learn’s SelectKBest to select my top 10 features, but I’m not sure which score function to use. I ...
0
votes
1answer
25 views

Measuring R-Squared by category

It makes sense to look at metrics like recall/precision by category when performing classification. sklearn has classification_report for this purpose. But what if I want to look at error by category ...
0
votes
1answer
24 views

how does class 0 scores in the classification report are calculated ( sklearn python )?

Here how these class-0 probability are calculated?? print(classification_report(y_true, y_pred, target_names=target_names)) precision recall f1-score support ...
1
vote
1answer
56 views

How are the scores computed with SelectKBest (sklearn)

I was expecting the scores_ provided by SelectKBest() to be the result of the score_func (e....
0
votes
1answer
26 views

Saved PCA model produce different result

I'm using PCA to reduce my feature vector dimension. I'm saving its model and transformed output like this: ...
2
votes
1answer
20 views

Scikit's permuted features in decision tree implementation

In the Scikit's docummentation of decision trees I found a note: "The features are always randomly permuted at each split. Therefore, the best found split may vary, even with the same training data ...
1
vote
1answer
71 views

Specifying separable covariance functions for 2D gaussian process regression

I would like to fit a gaussian process regression with two input variables. But I am not sure how to construct or interpret the covariance function with multiple input dimensions. There are different ...
0
votes
0answers
21 views

C penalty in SVM - larger C increases the margin or reduces the margin?

I get contradictory information on what the penalty value C does in SVM. page 346,347 of the following book says, larger C means larger misclassification is allowed and margin will be larger. http:/...
1
vote
1answer
26 views

scikit-learn feature selection on k-fold loop

I am using the iterator of StratifiedKFold from sklearn and i've noticed that i must include a process of feature selection on ...
0
votes
0answers
20 views

Different scores in each cross val folds?

I have about ~800,000 data points and highly imbalanced dataset with <1% of the population being positive . I used SMOTE sampling to up sample my minority class. I used cross_val_score to do a 10 ...
0
votes
1answer
22 views

Build confusion matrix for cross validated results? [closed]

I am using python , and I want to know how to build a confusion matrix after I have cross validated my dataset. If build a confusion matrix at each fold then I have too many confusion matrices. I ...