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
4
votes
1answer
10k views

Python : How to use Multinomial Logistic Regression using SKlearn

I have a test dataset and train dataset as below. I have provided sample data with min records, but my data has more than 1000's of record. Here if you see E is my ...
4
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 ...
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 (...
4
votes
1answer
1k views

Multi-label compute class weight - unhashable type

Working in a multi-label classification problem with 13 possibles outputs in my neural network with Keras, sklearn, etc... Each output can be an array like [0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1 ,0]. I ...
4
votes
1answer
298 views

Does Gradient Boosting detect non-linear relationships?

I wish to train some data using the the Gradient Boosting Regressor of Scikit-Learn. My questions are: 1) Is the algorithm able to capture non-linear relationships? For example, in the case of y=x^2,...
4
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:...
4
votes
1answer
98 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 ...
4
votes
1answer
1k views

Product classification in e-commerce using attribute keywords

I am working on a product classification problem (E-Commerce) in which I have to identify product category based on keywords. Say for example, if input is given as 'Samsung Galaxy On Nxt 3 GB RAM 16 ...
4
votes
1answer
8k views

Use of TfidfVectorizer on dataframe

I have the dataframe which has two colums(Reviews and Label): ...
4
votes
2answers
601 views

Performance difference between decision trees and logistic regression when one of the features is a string

I have a set of features, one of which is a string. I convert the string to an integer by treating the string as a base 36 number (I only use the first 13 characters). Then I can use DecisionTrees ...
4
votes
1answer
1k views

How to explain the outcome of k-means clustering?

I am currently conducting some analysis using NTSB aviation accident database. There are cause statements for most of the aviation incidents in this dataset that describe the factors lead to such ...
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 ...
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 ...
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 ...
4
votes
1answer
96 views

TS-SS and Cosine similarity among text documents using TF-IDF in Python

A common way of calculating the cosine similarity between text based documents is to calculate tf-idf and then calculating the linear kernel of the tf-idf matrix. TF-IDF matrix is calculated using ...
4
votes
1answer
151 views

sklearn's cross_validate does not work with catboost

I would like to use cross validation with catboost. Since I do not just want to use catboost but also sampling I am using a ...
4
votes
1answer
6k views

Can Keras be used to build clustering models

keras.wrappers.scikit_learn can be used to build KerasClassifier model, Keras be used to ...
4
votes
1answer
5k views

Why is cross-validation score so low?

I am using Scikit-Learn for this classification problem. The dataset has 3 features and 600 data points with labels. First I used Nearest Neighbor classifier. ...
4
votes
1answer
2k views

How to predict user next purchase items

I have an e-commerce website where customers can purchase items directly from the site. I have training data which includes order id, user id, order number, days since prior order, product id, add to ...
4
votes
3answers
3k views

Categorical Variables - Classification

I have a categorical variable, country which takes on values like India, US, Pakistan etc. I am currently using a linear SLM for a classification task. So my country value varies from 1-20. How ...
4
votes
1answer
620 views

Sklearn Linear Regression examples

Could someone give an example of the application of Tf-idf with sparse data (lots of zeros) in sklearn? I am not quite sure where to insert the weight of Tf-idf and how to rightly obtain the weight. ...
4
votes
1answer
2k views

How does SelectKBest() perform feature selection?

SelectKBest(f_classif, k), where k is the number of features to select, is often used for feature selection, however, I am ...
4
votes
1answer
919 views

Prediction model for marketing to prospective customers (using pandas)

I'm currently working on a part-time project which involves predicting the likelihood of customers going to buy a product using data analytics. The company I'm interning with has given me a customer ...
4
votes
2answers
569 views

How to reduce dimensionality of audio data that comes in form of matrices and vectors?

I'm working on a project involved with identifying different types of sounds (such as screams, singing, and bangs) from each other. We've got our data a reasonable number of different transformations ...
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?
4
votes
2answers
58 views

LASSO remaining features for different penalisation

I am using the sklearn LASSOCV function and I am changing the penalisation parameter in order to adjust the number of features killed off. For example for $\alpha = 0.01$ I have 55 features remaining ...
4
votes
1answer
2k views

Sensitivity analysis of a machine learning model

Let’s say I have a set of input variables (A, B, C and D)...
4
votes
1answer
459 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: ...
4
votes
1answer
794 views

What does the “dual” parameter in sklearn.svm.LinearSVC and sklearn.svm.LinearSVR do?

While I am more or less familiar with the idea of the SVM, I do not understand the meaning of the dual parameter, which is described in the documentation as: ...
4
votes
1answer
1k views

How to avoid resampling part of pipeline on test data (imblearn package, SMOTE)

I am using the imblearn package to resample some data before applying other transformation/prediction techniques. Specfically, I am using SMOTE in a slightly unconventional way, as a data ...
4
votes
1answer
4k views

Multivariate outlier detection with isolation forest..How to detect most effective features?

I am trying to detect outliers in my data-set with 5000 observations and 800 features. I have followed the simple steps told in http://scikit-learn.org/stable/auto_examples/ensemble/...
4
votes
2answers
12k views

ValueError: Input contains NaN, infinity or a value too large for dtype('float64') [duplicate]

I am trying to fit my data into my model which takes numpy as input, so I feed the model with the dataframe values ...
4
votes
1answer
832 views

Why the estimated Lasso coefficients of almost all variables are equal to zero?

I would greatly appreciate if you could guide me. In fact, I used "Bayesian Optimization " to tune hyper-parameters of Lasso but the estimated Lasso coefficients of almost all variables are equal to ...
4
votes
2answers
2k views

Find effective feature on machine learning classification task with scikit-learn

I'm tackling a binary classification task using SVM implemented in python scikit-learn. Datasize is around 10,000 and the number of feature is 34. After finding nice parameter set (using ...
4
votes
2answers
828 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 <...
4
votes
1answer
263 views

Scikit-learn average_precision_score() vs. auc score of precision_recall_curve()

I've been searching around for an explanation to this, and haven't come across one yet- in scikit-learn, when I compute the auc() of the ...
4
votes
1answer
399 views

How to implement patternet in python as it is in matlab?

NOTE: This question was first posted in cross-validated website but I was instructed to move it off that website as it was not a good fit. I am new in implementation of machine learning, neural ...
3
votes
2answers
6k views

First steps with Python and scikit-learn

I believe I have a simple if not trivial question. I have a background in statistics and I tend to use Stata and R quite a bit. I am interested in learning Python. I used it for a while now and ...
3
votes
5answers
281 views

GridSearch without CV

I create a Random Forest and Gradient Boosting Regressor by using GridSearchCV. For the Gradient Boosting Regressor it takes too long for me. But i need to know which are the best Parameter for the ...
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
1answer
219 views

Why would one crossvalidate the random state number?

Still learning about machine learning, I've stumbled across a kaggle (link), which I cannot understand. Here are lines 72 and 73: ...
3
votes
2answers
4k views

Outlier detection by unsupervised algorithm: Fraud Detection

I have set of 300,000 set of rows with credit card transactions and my job is to find outliers (suspicious transactions) in those dataset. I have created around 5 features (All continuous data, with ...
3
votes
6answers
134 views

Removing Categorial Features in Linear Regression

This is more of a design question regarding linear regression. Here is some info on our dataset: Our dataset has 8 features; 3 of them being categorical. We are willing to perform linear regression ...
3
votes
3answers
6k views

sklearn : missing pruning for decision trees

Why pruning is not currently supported in scikit-learn? How can we tune the decision trees to make a workaround?
3
votes
1answer
2k views

Passing a custom kernel with more than two arguments into `svm.SVC` in scikit-learn

I'm trying to use a custom kernel that accepts 3 arguments, with the SVM in sk-learn: ...
3
votes
1answer
3k views

Pandas categorical variables encoding for regression (one-hot encoding vs dummy encoding)

Pandas has a method called get_dummies() that creates a dummy encoding of a categorical variable. Scikit-learn also has a OneHotEncoder that needs to be used along with a LabelEncoder. What are the ...
3
votes
2answers
1k views

one-hot-encoding categorical data gives error

I am currently working on the Boston problem hosted on Kaggle. The dataset is nothing like the Titanic dataset. There are many categorical columns and I'm trying to one-hot-encode these columns. I'...
3
votes
2answers
216 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
6k views

Learning rate in logistic regression with sklearn

In sklearn, for logistic regression, you can define the penalty, the regularization rate and other variables. Is there a way to set the learning rate?
3
votes
2answers
37k 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 ...