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
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 ...
22
votes
5answers
36k 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
622 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
17k 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
475 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
147 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
912 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 ...
19
votes
2answers
33k 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 ...
3
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
950 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
367 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 ...
11
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
32k 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
756 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
392 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
262 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
786 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
866 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
361 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
576 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
811 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
86k 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
795 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
898 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
107 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 ...
4
votes
1answer
1k views

Scikit Learn Logistic Regression Memory Leak

I'm curious if anyone else has run into this. I have a data set with about 350k samples, each with 4k sparse features. The sparse fill rate is about 0.5%. The data is stored in a ...
9
votes
2answers
264 views

How much time do scikit classifiers take to classify?

I am planning to use scikit linear support vector machine (SVM) classifier for text classification on a corpus consisting of 1 million labeled documents. What I am planning to do is, when a user ...
81
votes
11answers
77k views

SVM using scikit learn runs endlessly and never completes execution

I am trying to run SVR using scikit learn ( python ) on a training dataset having 595605 rows and 5 columns(features) and test dataset having 397070 rows. The data has been pre-processed and ...
17
votes
1answer
12k views

Algorithms for text clustering

I have a problem of clustering huge amount of sentences into groups by their meanings. This is similar to a problem when you have lots of sentences and want to group them by their meanings. What ...
38
votes
5answers
61k views

Does scikit-learn have forward selection/stepwise regression algorithm?

I'm working on the problem with too many features and training my models takes way too long. I implemented forward selection algorithm to choose features. However, I was wondering does scikit-learn ...
2
votes
2answers
1k views

how to impute missing values on numpy array created by train_test_split from pandas.DataFrame?

I'm working on the dataset with lots of NA values with sklearn and pandas.DataFrame. I implemented different imputation strategies for different columns of the dataFrame based column names. For ...