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
3
votes
2answers
306 views

Why do we choose principal components based on maximum variance explained?

I've seen many people choose # of principal components for PCA based on maximum variance explained. So my question is do we always have to choose principal components based on maximum variance ...
3
votes
2answers
144 views

Is Label Encoding with arbitrary numbers ever useful at all?

From what I read online, there seems to be some confusion regarding the taxonomy and the terms used, so to avoid misunderstanding I'm going to define them here: Label Encoding - encoding a nominal ...
3
votes
2answers
42k 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
81 views

Can I create random forest with RandomForestClassifier which will consist the same trees?

Based on answers to this question, I should be able to build a random forest with all the same trees by using ...
2
votes
4answers
2k views

is it possible to output more than 2 nodes away from a node in a decision tree? if yes, how to do that with sklearn?

usually a decision tree has one root node, some nodes, and some leaves. lots tutorial illustrate this as something like binary tree. is it possible more than 2 nodes away from a node in a decision ...
1
vote
2answers
471 views

Scikitlearn grid search random forest using oob as metric?

Have looked at data on oob but would like to use it as a metric in a grid search on a Random Forest classifier (multiclass) but doesn't seem to be a recognised scorer for the scoring parameter. I do ...
1
vote
2answers
112 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 ...
1
vote
1answer
5k views

GridSearch mean_test_score vs mean_train_score

I am working with scikit learn and GridSearch in order to find the best parameters in my classifiers. I have a map of different hyperparameters and I want to print out GridSearch results, but I do ...
10
votes
3answers
4k views

Building a machine learning model to predict crop yields based on environmental data

I have a dataset containing data on temperature, precipitation and soybean yields for a farm for 10 years (2005 - 2014). I would like to predict yields for 2015 based on this data. Please note that ...
10
votes
2answers
2k views

Is max_depth in scikit the equivalent of pruning in decision trees?

I was analyzing the classifier created using a decision tree. There is a tuning parameter called max_depth in scikit's decision tree. Is this equivalent of pruning a decision tree? If not, how could I ...
8
votes
1answer
23k views

cosine_similarity returns matrix instead of single value

I am using below code to compute cosine similarity between the 2 vectors. It returns a matrix instead of a single value 0.8660254. [[ 1. 0.8660254] [...
8
votes
2answers
637 views

Is over fitting okay if test accuracy is high enough? [duplicate]

I am trying to build a binary classifier. I have tried deep neural networks with various different structures and parameters and I was not able to get anything better than ...
8
votes
3answers
11k views

Why does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?

As I increase the number of trees in scikit learn's GradientBoostingRegressor, I get more negative predictions, even though there are no negative values in my ...
6
votes
2answers
2k views

Binary text classification with TfidfVectorizer gives ValueError: setting an array element with a sequence

I am using pandas and scikti-learn to do binary text classification using text features encoded using TfidfVectorizer on a DataFrame. Here is some dummy code that illustrates what I'm doing: ...
6
votes
3answers
965 views

What is difference between Multi-class One vs All and Multilabel Classification?

Although Multi class is different from Multi label classification, whats difference does adding One vs All make in Multi-class. Edit 1: http://scikit-learn.org/stable/modules/multiclass.html#...
5
votes
3answers
5k views

What cost function and penalty are suitable for imbalanced datasets?

For an imbalanced data set, is it better to choose an L1 or L2 regularization? Is there a cost function more suitable for imbalanced datasets to improve the model score (...
5
votes
1answer
769 views

What's the difference between finding the average Euclidean distance and using inertia_ in KMeans in sklearn?

I've found two different approaches online when using the Elbow Method to determine the optimal number of clusters for K-Means. One approach is to use the following code: ...
5
votes
1answer
608 views

Why Scikit and statsmodel provide different Coefficient of determination?

First of all, I know there is a similar question, however, I didn't find it so much helpful. My issue is concerning simple Linear regression and the outcome of R-Squared. I founded that results can ...
4
votes
1answer
1k views

Does MLPClassifier (sklearn) support different activations for different layers?

According to the documentation, it says the 'activation' argument specifies: "Activation function for the hidden layer" Does that mean that you cannot use a different activation function in ...
4
votes
1answer
86 views

Is there an algorithm that imputes missing values based on n nearest columns? (KNN hybrid)

I have a dataset of 70 columns that have missing values. Each column has a few columns (3-5) that it is significantly more correlated than the others but each column's correlated columns are very ...
4
votes
2answers
3k views

Can I fine tune the xgboost model instead of re-training it?

I am using the xgboost library. My system runs a cronjob each night, where it pulls the data from the database and trains the model. However, I would like to remove the re-training of the model again ...
3
votes
1answer
405 views

Assigning values to missing target vector values in scikit-learn

I have a dataset containing data on temperature, precipitation, and soybean yields for a farm for 10 years (2005 - 2014). I would like to predict yields for 2015 based on this data. Please note that ...
3
votes
1answer
123 views

How to make machine learning specifically for an individual in a group when we have the data on the group?

Lets specify the question with the help of the figure below: We know that one part of the behaviour (our target Y) will depend on common parameters (for the group). It is represented by the grey zone ...
2
votes
1answer
107 views

Gradient Boosted Decision Trees How to Find Prediction of Each Tree?

I'm doing a project. I have a classification problem that I should solve using gradient boosted decision trees. What I want to do is create a matrix that gives prediction of each decision tree for ...
2
votes
4answers
2k views

Using HashingVectorizer for text vectorization

Here is the sample data I have: Tag 1(Val: X), Tag 2(Val: Y), Tag 3(Val: Z), Label (Val: P) Tag 1(Val: A), Tag 2(Val: B), Tag 3(Val: C), Label (Val: Q) Tag 1(Val: D), Tag 2(Val: E), Tag 3(Val: F), ...
2
votes
1answer
1k views

About sklearn.metrics.average_precision_score documentation

There is a example in sklearn.metrics.average_precision_score documentation. ...
1
vote
0answers
561 views

How to compute G-mean score?

I would greatly appreciate if you could let me know how to fix the following issue: I used sklearn.metrics.fowlkes_mallows_score to compute G-mean score for my binary classification problem, but it ...
1
vote
1answer
2k views

How to calculate Accuracy, Precision, Recall and F1 score based on predict_proba matrix?

I found this link that defines Accuracy, Precision, Recall and ...
1
vote
1answer
342 views

Naive bayes, all of the elements in predict_proba output matrix are less than 0.5

I've created a MultinomialNB classifier model by which I'm trying to label some test texts: ...
1
vote
1answer
280 views

Why won't my SVM learn a sequence of repeated elements

I recently started playing with SVMs for a one class classification, I was able to get some reasonable classifications from real data and but was trying to optimize the nu and gamma parameters when I ...
1
vote
2answers
1k views

Nearest Neighbors on mixed data types in high dimensions

I would like to be able to use nearest neighbors to attempt to find the most similar samples to a subclass of samples (think treated vs untreated) in a dataset with continuous, categorical, and text ...
1
vote
0answers
154 views

predict rank from physical measurements with various lengths

I have physical measurements with length 2*n, where the first vector represents a charge or a capacity (in Coulomb) $C$ and the second one is a voltage $V$. Let's call this measurement "forming". A ...
1
vote
2answers
6k views

sklearn.cross_validation.cross_val_score “cv” parameter question

I was working through a tutorial on the titanic disaster from Kaggle and I'm getting different results depending on the details of how I use ...
1
vote
1answer
160 views

How is the 'feature_importance_' value calculated in sklearn random forest regressor?

I have 9000 sample, with five features, and one output variable (all are numerical, continuous values). I used random forest regression method using scikit modules. ...

1
2