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
5
votes
2answers
493 views

Does using unimportant features hurt accuracy?

I'm using the scikit-learn gradient boosting classifier found here. If I run the classifier on the same data without seeding the random number generator, I get different feature importances, and ...
5
votes
2answers
463 views

RandomForest and tree feature importance in scikit-learn

What is the difference between model.feature_importances_ and tree.feature_importances_ in the following code: ...
5
votes
1answer
5k views

Does increasing the n_estimators parameter in decision trees always increase accuracy

I'm using some ML algorithms (from sklearn lib) and on most of them there is a parameter n_estimators which is (if I understood well) the number of used trees. Intuitevely I would say that the more ...
5
votes
2answers
1k views

How can I use variable length inputs to train a regression model?

I'm working predicting a value $y \in \mathbb{R}$ from the value of $x_{n+1}$, where $n$ is the number of samples ($x_{i \in [1,n]}$) used for training. Each training sample $x_{i}$ is a time series ...
5
votes
2answers
4k views

Naive Bayes: Divide by Zero error

OK this is my first time in ML and for starter I am implementing Naive Bayes. I have Cricket(sports) data in which I have to check whether the team will win or lost based on Toss Won|Lost and Bat ...
5
votes
2answers
4k views

Image clustering by similarity measurement (CW-SSIM)

I'm trying to use scikit-learn and pyssim for clustering a set of images - less than 100. The end goal is to place the images into several buckets (clusters) according to the calculated similarity ...
5
votes
1answer
1k views

Is shuffling training data beneficial for machine learning?

I was curious to know if shuffling ML training data is beneficial to better results? Sorry not a lot of wisdom here, but I have been reading a post from pythonprogramming.net for this topic. I ...
5
votes
1answer
5k views

How to train ML model with multiple variables?

I am trying to learn Machine Learning concepts these days. I understand in a traditional ML data, we will have features and labels. I have following toy data in my mind where I have features like '...
5
votes
1answer
3k views

How can l get 50 % examples in training set and 50% in test set for each class when splitting data?

l have a dataset of 200 examples with 10 classes. l would like to split the dataset into training set 50% and test set 50%. for each class, l have 20 examples. Hence, l would like to get for each ...
5
votes
3answers
1k views

Predicting contract churn/cancellation: Great model results does not work in the real world

I'm busy with a supervised machine learning problem where I am predicting contract cancellation. Although a lengthy question, I do hope someone will take the time as I'm convinced it will help others ...
5
votes
2answers
2k views

Varying results when calculating scatter matrices for LDA

I'm following a Linear Discriminant Analysis tutorial from here for dimensionality reduction. After working through the tutorial (did the PCA part, too), I shortened the code using sklearn modules ...
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 ...
5
votes
1answer
966 views

Gaussian Mixture Models as a classifier?

I'm learning the GMM clustering algorithm. I don't understand how it can used as a classifier. Here are my thought: 1) GMM is an unsupervised ML algorithm. At least that's how ...
5
votes
1answer
2k views

AUC ROC in keras is different when using tensorflow or scikit functions.

Two solutions for using AUC-ROC to train keras models, proposed here worked for me. But using tensorflow or scikit rocauc functions I get different results. ...
5
votes
1answer
102 views

Why would a fake feature with random numbers get selected in feature importance?

I'm using a sklearn.ensemble.RandomForestClassifier(n_estimators=100) to work on this challenge: https://kaggle.com/c/two-sigma-financial-news I've plotted my ...
5
votes
1answer
172 views

Sklearn PCA with zero components example

I'm simply trying to repeat a benchmark from the sklearn's docs. The unclear part is: n_components = np.arange(0, n_features, 5). They are applying a PCA transform ...
5
votes
3answers
2k views

How to estimate the variance of regressors in scikit-learn?

Every classifier in scikit-learn has a method predict_proba(x) that predicts class probabilities for x. How to do the same thing ...
5
votes
2answers
116 views

Online news classification

I am performing an online news classification. The idea is to recognize group of news of the same topic. My algorithm has these steps: 1) I go through a group of feeds from news sites and I recognize ...
5
votes
1answer
9k views

Use of TfidfVectorizer on dataframe

I have the dataframe which has two colums(Reviews and Label): ...
5
votes
1answer
6k views

KL-divergence returns infinity

Given an original probability distribution P, I want to measure how much an approximation Q differs from the initial distribution. For that I calculate the KL-divergence via ...
5
votes
1answer
71 views

How to pass custom distance functions to K nearest neighbors function in scikit-learn

I am trying to solve a problem where I am asked to perform classification using KNN but with a custom euclidean function: The function is the following: ...
5
votes
3answers
2k views

using sklearn class weight to increase number of positive guesses in extremely unbalanced data set?

Hi I have a poorly correlated and unbalanced data set I have to work with. The set is 2 classes, 0 has 96,000 values and 1 has about 200. When I run random forest or other methods I get an output like:...
5
votes
2answers
1k 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: ...
5
votes
2answers
7k views

How to plot learning curve and validation curve while using pipeline

I would appreciate if you could let me know in the following example code: ...
5
votes
1answer
854 views

How to use machine learning to extract product info from the titles of eBay listings

Reposting here because someone correctly pointed out it is better suited for here. So I have a bunch of titles of eBay listings. I want to extract product information from each title, so I can ...
5
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?
5
votes
1answer
246 views

How backpropagation through gradient descent represents the error after each forward pass

In Neural NEtwork Multilayer Perceptron, I understand that the main difference between Stochastic Gradient Descent (SGD) vs Gradient Descent (GD) lies in the way of how many samples are chosen while ...
5
votes
1answer
1k views

Reproducing randomForest Proximity Matrix from R package in Python

I am trying to port this little piece of R code to python: ...
5
votes
1answer
1k views

Isolation forest sklearn contamination param

I'm working on an unsupervised anomaly detection task on time series using isolation forest algorithm. I'm developing in Python, more in detail using sklearn. I found out a lot of examples on this, ...
5
votes
2answers
1k views

Columntransformer multiple columns with vector inputs

This is perhaps more of a coding question than data science so apologies if this is not the right platform to ask this. My question is related to the sklearn's <...
5
votes
2answers
3k views

Sci-kit learn function to select threshold for higher recall than precision

When we care more that there should be no false negatives, as far as possible… ie. higher recall (video is suitable for kid or not), we should use (receiver operating characteristic) ROC (area under ...
5
votes
3answers
1k views

How to Deploy a Scikit-learn Model into the Cloud?

I have generated a common Sklearn model for text classification which I want to make accessible in the cloud (there is no provider preference) as an API. So far the closest solution that I managed to ...
4
votes
3answers
2k views

Can we remove features that have zero-correlation with the target/label?

So I draw a pairplot/heatmap from the feature correlations of a dataset and see a set of features that bears Zero-correlations both with: every other feature and also with the target/label ....
4
votes
6answers
13k views

issue with oneHotEncoding

So i have a PandasDataFrame with categorical variables in a column which i want to one hot encode i've used the following code from an ML udemy course ...
4
votes
3answers
164 views

Reward negative derivative on linear regression

I'm actually new to Data Science and I'm trying to make a simple linear regression with only one feature X ( which I added the feature log(X) before adding a polynomial features) on a motley dataset ...
4
votes
2answers
256 views

Training a model sample by sample

I'm training a Scikit model but it seems that in all examples, they call the fit method on the entire training set. What I want to do however is call it per sample (...
4
votes
2answers
261 views

Cross Validation - Why does more folds increase variation?

Can someone explain why increasing the number of folds in a cross validation increases the variation (or the standard deviation) of the scores in each fold. I've logged the data below. I'm working on ...
4
votes
2answers
6k views

NLTK Sklearn Genism Text to Topic

I aint no data scientist/machine learner. What Im Lookin for ...
4
votes
1answer
8k views

Obtaining a confidence interval for the prediction of a linear regression

The data I am working with is being used to predict the duration of a trip between two points. There are about 100 different trips in the data and ~90k observations. I am using the standard pattern: ...
4
votes
1answer
2k views

How do I interpret the length-scale parameter of the RBF kernel?

According to the Scikit-Learn documentation for the RBF kernel: The length scale of the kernel. If a float, an isotropic kernel is used. If an array, an anisotropic kernel is used where each dimension ...
4
votes
2answers
10k views

How to determine feature importance while using xgboost in pipeline?

How to determine feature importance while using xgboost (XGBclassifier or XGBregressor) in pipeline? ...
4
votes
2answers
203 views

Compare Coefficients of Different Regression Models

in my project, I am using asuite of shallow and deep learning models in order to see which has the best performance on my data. However, in the pool of shallow machine learning models, I want to be ...
4
votes
1answer
1k views

What is GridSearchCV doing after it finishes evaluating the performance of parameter combinations that takes so long?

I'm running GridSearchCV to tune some parameters. For example: ...
4
votes
2answers
3k views

RandomForest - Reasons for memory usage / consumption?

Which factors influence the memory consumption? Is it the number of trees (n_estimators) or rather the number of data records of the training data or something other?
4
votes
1answer
875 views

Clustering by common elements in a list

Suppose I have these elements: a = [1, 6, 3, 4, 10, 32, 2, 54] b = [20, 5, 14, 25, 18, 1] c = [54, 3, 6, 12, 41, 1, 9] d = [3, 4, 1] e = [19, 20, 25, 5] Each ...
4
votes
1answer
55k views

AttributeError: 'numpy.ndarray' object has no attribute 'predict'

I have trained and saved a model : ...
4
votes
3answers
3k views

Same SVM configuration, same input data gives different output using Matlab and scikit-learn implementation of SVM, in a classification problem

I have a classification problem with 60 data points in a 2-dimensional feature space. The data originally is divided into 2 classes. Earlier I was using Statistics Toolbox of Matlab so it was giving ...
4
votes
1answer
700 views

Difference between learning_curve and validation_curve

What is the difference between these two curves: learning_curve and validation_curve ?
4
votes
3answers
260 views

Train classifier on balanced dataset and apply on imbalanced dataset?

I have a labelled training dataset DS1 with 1000 entries. The targets (True/False) are nearly balanced. With sklearn, I have tried several algorithms, of which the GradientBoostingClassifier works ...
4
votes
2answers
4k views

How do I get the feature importace for a MLPClassifier?

I use the MLPClassifier from scikit learn. I have about 20 features. Is there a scikit method to get the feature importance? I found clf.feature_importances_ but it seems that it only exists for ...

1 2
3
4 5
29