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
1answer
385 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 ...
9
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 ...
0
votes
1answer
604 views

Using sklearn DictVectorizer in real-time systems

Any binary one-hot encoding is aware of only values seen in training, so features not encountered during fitting will be silently ignored. For real time, where you have millions of records in a second,...
6
votes
3answers
2k views

Linear kernel in SVM performing much worse than RBF or Poly

When trying to train a SVM on some Kaggle data, I have encountered a situation where the linear kernel fails to give any results. This doesn't make sense to me because the RBF kernel works just fine, ...
107
votes
3answers
62k views

When to use One Hot Encoding vs LabelEncoder vs DictVectorizor?

I have been building models with categorical data for a while now and when in this situation I basically default to using scikit-learn's LabelEncoder function to transform this data prior to building ...
4
votes
1answer
5k views

How to customise cost function in Scikit learn's model?

For example, when I have a problem that false negative should be penalised more, how can I incorporate that requirement in the algorithm such as SVM?
2
votes
1answer
2k views

Handling categorical features in Factorization Machines algorithm - Feature Hashing vs. One-Hot encoding

For solving a prediction problem I'm willing to use the Factorization Machines, a model that in addition to learning linear weights on features, learn a vector space for each feature to learn pairing ...
3
votes
4answers
1k views

Extremely dominant feature?

I'm new to datascience. I was wondering how one should treat an extremely dominant feature. For example, one of the features is "on"/"off", and when it's "off", none of the other features matter and ...
3
votes
2answers
2k views

Scikit Learn's RandomForestRegressor is not giving results on large data set

I have a Pandas dataframe X(20346, 4116). All independent columns have binary variable as 0 or 1. Whereas dependent column has continuous variable. When I execute below code using the scikit-learn ...
2
votes
2answers
1k views

Is $R^2$ an appropriate evaluation metric for k-Nearest Neighbors?

I found a source that stated that $R^2$ is the ”percentage of the response variable variation that is explained by a linear model.” (Source) Since kNN is not a linear model (it is nonparametric), is ...
23
votes
5answers
38k views

Calculating KL Divergence in Python

I am rather new to this and can't say I have a complete understanding of the theoretical concepts behind this. I am trying to calculate the KL Divergence between several lists of points in Python. I ...
2
votes
1answer
660 views

How many features do you generally use for your ML Model? [closed]

I am working on a certain kaggle competition and users there say that they are using >5000 features and training a XGBoost or Random Forest on it. The mentioned post is here: https://www.kaggle.com/...
8
votes
4answers
18k views

Clustering for mixed numeric and nominal discrete data

My data includes survey responses that are binary (numeric) and nominal / categorical. All responses are discrete and at individuals level. Data is of shape (n=7219, p=105). Couple things: I am ...
2
votes
1answer
478 views

One multilabel classifier or one for each type of label?

Let's say I need to classify addresses with scikit-learn, so if I want my classifier to be able to classify addresses by the street name, and post/zip code, should I do a OneVsRest classifier, or ...
1
vote
3answers
2k views

Reduce dimension, then apply SVM

Just out of curiousity, is it generally a good idea to reduce the dimension of training set before using it to train SVM classifier? I have a collection of documents, each of them is represented by a ...
2
votes
1answer
2k views

Extract the “path” of a data point through a decision tree in sklearn

I'm working with decision trees in python's scikit learn. Unlike many use cases for this, I'm not so much interested in the accuracy of the classifier at this point so much as I am extracting the ...
2
votes
2answers
1k views

Deploying machine learning modules

I am looking to find some resources about what I wan't to do :I wan't to make some GUI of my machine learning models and finally deploy them as a web app.I find R Shiny to be somehow ok , but it ...
6
votes
3answers
1k views

Classifier and Technique to use for large number of categories

I am designing a scikit learn classifier for a sequence labelling task which has 5000+ categories and training data is at least 80 million and may grow upto an additional 100 million each year. I have ...
2
votes
1answer
3k views

Feature importance for random forest classification of a sample [closed]

Using a random forest is it possible to determine which features were the driving features to classify a specific sample as class A? I know I can ask which features are more important to perform ...
4
votes
2answers
2k 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 ...
0
votes
1answer
151 views

Classifying text documents using linear/incremental topics

I'm attempting to classify text documents using a few different dimensions. I'm trying to create arbitrary topics to classify such as size and relevance, which are linear or gradual in nature. For ...
8
votes
2answers
8k views

How to use Cohen's Kappa as the evaluation metric in GridSearchCV in Scikit Learn?

I have class imbalance in the ratio 1:15 i.e. very low event rate. So to select tuning parameters of GBM in scikit learn I want to use Kappa instead of F1 score. My understanding is Kappa is a better ...
1
vote
2answers
926 views
2
votes
1answer
2k views

NLTK: Tuning LinearSVC classifier accuracy? - Looking for better approaches/advices

Problem/Main objective/TLDR: Train a classifier, then feed it a random review and get the correspondent predicted review rating (number of stars from 1 to 5) - only 60% accuracy! :( I have a big ...
21
votes
2answers
34k views

Can you explain the difference between SVC and LinearSVC in scikit-learn?

I've recently started learning to work with sklearn and have just come across this peculiar result. I used the digits dataset ...
6
votes
2answers
5k views

Is there a way of performing stratified cross validation using xgboost module in python?

I am training and predicting on the same data-set, but I want to perform 10-fold cross-validation and predict on the left out fold and thus predict on the whole data set. How can I do this? The ...
4
votes
1answer
12k views

How to plot/visualize clusters in scikit-learn (sklearn)?

I have done some clustering and I would like to visualize the results. Here is the function I have written to plot my clusters: ...
8
votes
1answer
974 views

sklearn - overfitting problem

I'm looking for recommendations as to the best way forward for my current machine learning problem The outline of the problem and what I've done is as follows: I have 900+ trials of EEG data, where ...
1
vote
2answers
429 views

Random forest model gives same result for all test data, Next step?

I am teaching myself some data science and have started a Kaggle project. I have fitted a random forest classification model (using sci-kit learn) with a few millions rows of data. There are two ...
12
votes
1answer
15k views

Feature selection using feature importances in random forests with scikit-learn

I have plotted the feature importances in random forests with scikit-learn. In order to improve the prediction using random forests, how can I use the plot information to remove features? I.e. how to ...
24
votes
4answers
33k views

Scikit-learn: Getting SGDClassifier to predict as well as a Logistic Regression

A way to train a Logistic Regression is by using stochastic gradient descent, which scikit-learn offers an interface to. What I would like to do is take a scikit-learn's SGDClassifier and have it ...
9
votes
1answer
777 views

Feature selection for Support Vector Machines

My question is three-fold In the context of "Kernelized" support vector machines Is variable/feature selection desirable - especially since we regularize the parameter C to prevent overfitting and ...
2
votes
1answer
393 views

Scalable open source machine learning library written in python

I believe sci kit learn is written in python,however that not scalable.Spark mlib or ml is scalabale but written in scala.I am looking for an ongoing effort where a machine learning library is being ...
4
votes
1answer
266 views

Can you use clustering to pick out signals in noisy data?

As my first project into data science, I would like to pick out the main clusters in noisy data. I think a good example would be trying to pick out certain links on a given StackExchange question that ...
9
votes
2answers
818 views

Is there a method that is opposite of dimensionality reduction?

I am new to the field of machine learning, but have done my share of signal processing. Please let me know if this question has been mislabeled. I have two dimensional data which is defined by at ...
5
votes
2answers
142 views

How to cluster a link traversal dataset

I'm using Google Analytics on my mobile app to see how different users use the app. I draw a path based on the pages they move to. Given a list of paths for say a 100 users, how do I go about ...
0
votes
1answer
879 views

Why is the Naive Bayes classifier of sklearn faster than sklearns SVM?

I've used scikit-learn in Python to compare results of naive Bayes and SVM. I've found that naive Bayes is quicker than SVM. Could anyone shed some light on reasons ...
1
vote
0answers
225 views

non-linear optimization for a linear classifier? (scikit-learn)

Using scikit-learn, why would you use bfgs optimization which is non-linear for a linear classifier as logistic regression? I am confused. Does the optimization method finds the optimum of the chosen ...
2
votes
1answer
364 views

Finding parameters with extreme values (classification with scikit-learn)

I am currently working with the forest cover type prediction from Kaggle, using classification models with scikit-learn. My main purpose is learning about the different models, so I don't pretend to ...
1
vote
1answer
584 views

Difference between OLS(statsmodel) and Scikit Linear Regression

I have a question about two different methods from different libraries which seems doing same job. I am trying to make linear regression model. Here is the code which I using statsmodel library with ...
2
votes
1answer
897 views

sk-learn - ValueError: array is too big.

I have a large dataset with characters and 90000 intances and I have the error ValueError: array is too big when I have the following code before the plot_kmeans_digits.py code: data2=list(csv....
65
votes
6answers
88k views

strings as features in decision tree/random forest

I am doing some problems on an application of decision tree/random forest. I am trying to fit a problem which has numbers as well as strings (such as country name) as features. Now the library, scikit-...
0
votes
1answer
807 views

Getting Scikit-Learn RandomForestClassifier to output Top N results

I'd like to see the top N results for a RandomForestClassifier prediction, ordered by descending probability. The answer may be predict_proba, but I have no idea how to interpret the results. Help ...
2
votes
1answer
543 views

Normalize weekly data - Python

I have a weekly dataset and I have to normalize this data. Data is something like this : ...
4
votes
2answers
4k views

Scikit Learn: KMeans Clustering 3D data over a time period (dimentionality reduction?)

I have a dataset of xyz coordinates with a date component in a pandas dataframe ex: date1: $[x_1,y_1,z_1]$, date2: $[x_2,y_2,z_2]$, date3: $[x_3,y_3,z_3]$, .. I would like to classify a sample of ...
3
votes
1answer
2k views

Sci-kit Pipeline and GridsearchCV returns indexError: too many indices for array

I'm trying to get to grips with sci-kit learn for some simple machine learning projects but I'm coming unstuck with Pipelines and wonder what I've done wrong... I'm trying to work through a tutorial ...
4
votes
3answers
3k 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 (...
3
votes
2answers
925 views

How to ensemble classifier incorporating all features in python?

I am doing a text classification task(5000 essays evenly distributed by 10 labels). I explored LinearSVC and got an accuracy of 80%. Now I guess whether accuracy ...
1
vote
0answers
108 views

scikit-learn OMP mem error

I tried to use OMP algorithm available in scikit-learn. My net datasize which includes both target signal and dictionary ~ 1G. However when I ran the code, it exited with mem-error. The machine has ...