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
671 views

how to pass parameters over sklearn pipeline's stages?

I'm working on a deep neural model for text classification using Keras. To fine tune some hyperparameters i'm using Keras Wrappers for the Scikit-Learn API. So I builded a Sklearn Pipeline for that: <...
4
votes
1answer
3k 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
564 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
2answers
3k views

Kmeans using silhouette_score

I am using silhouette_score to find the optimal k value. So I am running a for loop with a range of possible k values. I have added my code below. this program takes a very long time to run. Could you ...
4
votes
2answers
15k views

How to prevent/tell if Decision Tree is overfitting?

In SKLearn's documentation on Decision Trees, they say we should pay special attention not to overfit the tree. How can we do this? I am aware that using random forests may prevent it, but how do I ...
4
votes
1answer
389 views

Creating dummy variables to match fitted model at inference

I have built a machine learning classifier using Sklearn and pandas as my main tools. Now, one of the input features to the model is country (to letter country code such as US). I have fit a model ...
4
votes
2answers
742 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
2k 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
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 ...
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
3answers
263 views

Reducing the size of a dataset

I am trying to classify gestures. I am using Python's scikit learn library classification algorithms for that. I have collected depth images for this purpose. 200 samples are collected for each ...
4
votes
1answer
302 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
477 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
8k views

cross_val_score meaning

I'm studying the following code, which cross_val_score_ was used as well as .mean() and ...
4
votes
1answer
7k 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
6k 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
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
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
688 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
3k 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
966 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
601 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
2answers
1k 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 ...
4
votes
1answer
35 views

Data-preprocessing for Machine Learning model

I am confused about how to preprocess range based category such as age, tumor-size & inv-nodes. Should I take an average of the limits, as in - 14.5, 24.5 and so on or do one hot encoding of the ...
4
votes
1answer
48 views

weightage attributes

If I have a dataset with binary classification and has many attributes with value of (0 or 1) means the occurrence of attribute is represented by 1 and absence is represented by 0, can I add weight ...
4
votes
2answers
62 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
554 views

K Nearest Neighbour with different distance matrix to each datapoint

I'm wondering if there is library support in python (such as sklearn) for doing KNN on a data set that has a custom distance matrix (positive definite) for each data point (x is a query point, $x_i$ ...
4
votes
1answer
3k 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
1k 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
2k 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
1k views

Unable to Use The K-Fold Validation Sklearn Python

I have an dataset. I am unable to use the K-Fold Validation. I am getting the error raised: ValueError("{0} is not supported".format(y_type)) ValueError: continuous is not supported . I do ...
4
votes
2answers
17k 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
2answers
5k views

K-means clustering on the data frame having only one column

unsup_df is a DataFrame which has only one column: review. I want to form 2 clusters of the reviews. One positive and one ...
4
votes
1answer
2k views

Should we use discrete or continuous input for decision trees

I have 2 datasets, a continuous dataset(75 datapoints and 14 variables) and a discretized dataset which was made by placing the continuous datasets into buckets. I have built a decision tree ...
4
votes
1answer
3k views

how to remove columns in Transformer function in Pipeline

I already use a custom transformation function in a sklearn's pipeline. In this function I only add features to my data frame. It works greatly. Below is a working example. ...
4
votes
1answer
4k views

Is it possible to customize the activation function in scikit-learn's MLPClassifier?

Scikit-learn lists these as the implemented activation functions for it's multi-layer perceptron classifier: ...
4
votes
1answer
1k 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
1answer
138 views

What regressors are recommended with text modeling?

For the sake of my own exploration, I am working on a sales prediction project. I am using text extracted from a set of books to build a predictive model. With scikit learn, I have created a Tfidf, ...
4
votes
1answer
32 views

Spatially constrained geospatial similarity

What's the current methodology for clustering geospatial data by features? Example: I have some demographic dataset. Let's say this contains average home price and population density. So, an example ...
4
votes
2answers
435 views

ML regression poor performance

I am experimenting with 3 years time series electrical demand data (kW) for a building and attempting to create regression supervised ML models from sci kit learn regressor algorithms but I have very ...
4
votes
1answer
686 views

How many coefficients does the Logistic regression model has as a function of the number of features?

I have built a logistic regression model using Python anaconda and was surprised to see that the number of model coefficients turned out to be proportional to the training sample size i.e. My ...
4
votes
0answers
2k views

Isolation Forest Feature Importance

As of scikit-learn version 0.19.1, there is no implementation for calculating feature importance in an Isolation Forest. I'm also having trouble finding any online resources proposing ways to get at ...
4
votes
1answer
88 views

Gridsearch XGBoost for ensemble. Do I include first-level prediction matrix of base learners in train set?

I'm not quite sure how I should go about tuning xgboost before I use it as a meta-learner in ensemble learning. Should I include the prediction matrix (ie. df containing columns of prediction results ...
4
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
1answer
493 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 ...
4
votes
2answers
401 views

Can I do incremental learning with the sklearn implementation of Linear Discriminant Analysis

I have a large number of pictures that I would like to use LDA on. However, it requires too much memory, so I was wondering if it would be possible to make the learning incremental, using a sklearn ...
4
votes
0answers
11k views

Tuning Gradient Boosted Classifier's hyperparametrs and balancing it

I am not sure if it is a correct stack. Maybe I should have put my question into crossvalidated. Nevertheless, I perform following steps to tune the hyperparameters for a gradient boosting model: ...
3
votes
2answers
7k 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 ...

1
3 4
5
6 7
33