Questions tagged [scikit-learn]

scikit-learn is a popular machine learning package for Python that has simple and efficient tools for predictive data analysis. Topics include classification, regression, clustering, dimensionality reduction, model selection, and preprocessing.

Filter by
Sorted by
Tagged with
4
votes
2answers
4k views

sklearn.neighbors.NearestNeighbors - knn for unsupervised learning?

From basic theory I know that knn is a supervised algorithm while for example k-means is an unsupervised algorithm. However, at Sklearn there are is an implementation of KNN for unsupervised learning ...
4
votes
2answers
861 views

Naive Bayes for SA in Scikit Learn - how does it work

Okay so i scrape data from the web on movie reviews. I also have already got my own 'dictionary' or 'lexicon' with words and their labels (1-poor, 2-ok, 3-good, 4-very good, 5-excellent). SO the ...
4
votes
1answer
12k views

How to use the same minmaxscaler used on the training data with new data?

Im using the keras LSTM model to make prediction, and the code above is to scale the data: inputs are shaped like (n, 11, 1) and the label is 1D DailyDemand.py ...
4
votes
1answer
566 views

Compute parameters of a PDF (probability density function) for which no closed form expression is available

I would like to compute parameters such as mean, variance, quantiles, etc. for a PDF which is only given as a piece of code. That is, it can only be evaluated numerically at given points; no closed-...
4
votes
2answers
3k views

Encode multi-class response variable

In a classification problem when the response variable has multi-class, e.g., "sunny","rainy","cloudy", how should we encode it? I know that for predictors like this, usually we do One Hot Encoding, ...
4
votes
1answer
1k views

Using machine learning specifically for feature analysis, not predictions

I'm new to machine learning and have spent the last couple months having a blast using Sci-Kit Learn to try to understand the basics of building feature sets and predictive models. Now I'm trying to ...
4
votes
3answers
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 ...
4
votes
1answer
186 views

How can precision be less than one in Leave-One-Subject-Out binary classification if each subject contains only one class

Say I'm trying to classify a medical condition. Theres only two classes: Sick and Healthy. I build a model and I can't split the data because I don't want data from the same patient being in training ...
4
votes
2answers
445 views

The impact of using different scaling strategy with Clustering

I'm currently learning about clustering. To practice clustering, I am using this dataset. After running K-means clustering for multiple values of k and plotting the results, I can see that scaling is ...
4
votes
1answer
1k views

How to balance class weights correct for a CNN in Keras, given an unbalanced data set?

I want to use class weights for training a CNN with a imbalanced data set. The question arise if the sum of the weights of all examples have to stays the same? My previous plan was to use the ...
4
votes
1answer
221 views

Combining 'class_weight' with SMOTE

This might sound a weird question, but I could not find enough details in sklearn documentation about 'class_weight'. Can we first oversample the dataset using SMOTE and then call the classifier with ...
4
votes
3answers
236 views

Unexpected results from scikit learn regression decision tree

Apologies for this newbie question. I have a scikit learn DecisionTreeRegressor with muti-variable output. If the output is in the format [ output_var1, ...
4
votes
1answer
3k 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. ...
4
votes
1answer
407 views

K-nearest neighbors complexity

Why does the complexity of KNearest Neighbors increase with lower value of k? And when does the plot for k-nearest neighbor have smooth or complex decision boundary? Please explain in detail. And ...
4
votes
1answer
2k views

Machine learning - 'train_test_split' function in scikit-learn: should I repeat it several times?

I am a beginner in machine learning, and I hope someone can help me. In Python's 'scikit-learn' library, the function 'train_test_split' splits the dataset into training and test sets. This is done ...
4
votes
1answer
1k views

Does MLPClassifier (sklearn) support different activations for different layers?

According to the documentation, it says the 'activation' argument specifies: "Activation function for the hidden layer" Does that mean that you cannot use a different activation function in ...
4
votes
2answers
7k 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
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
2answers
1k views

ROC curve for different hyperparameters of `RandomForestClassifier`?

I'm currently trying to train a RandomForestClassifier on a dataset consisting of 5000 instances with 12 (now) encoded features and a binary target label. Through <...
4
votes
4answers
3k views

Scikit Learn Missing Data - Categorical values

I have a dataset containing categorical features, which has 4 labels, and 4 features. (It is a meta classifier, so outputs from base classifier serve as input into this classifier) ...
4
votes
1answer
12k 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
3answers
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
1answer
2k 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 ...
4
votes
2answers
609 views

Extremely high MSE/MAE for Ridge Regression(sklearn) when the label is directly calculated from the features

Edit: Removing TransformedTargetRegressor and adding more info as requested. Edit2: There were 18K rows where the relation did not hold. I'm sorry :(. After ...
4
votes
2answers
62 views

Data prediction using scikit-learn and a list

I have a group of lists detailing temperatures over differing amounts of time. My goal is to use machine learning to identify periods in which a machine is turned on and off, where turning on the ...
4
votes
2answers
345 views

Hierarchical Clustering: Extract observations from large heatmap

I'm currently trying to visualize a large data set as heat map. That in itself works smoothly but I struggle with gaining insights from interestingly looking clusters. Specifically, I have two ...
4
votes
1answer
1k 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
4k 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
879 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
4k 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
1answer
10k 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
446 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
907 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
484 views

Why is the number of samples smaller than the number of values in my decision tree?

I'm using scikit-learn RandomForestClassifier for a classification problem. When taking a closer look at one of the trees I noticed that the number of samples at the root was 662, but there were 507 ...
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
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
290 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
425 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
2answers
1k views

Validation Curve Interpretations for Decision Tree

I'm working on a machine learning class, and we're using supervised learning right now, starting with decision trees. I'm using the UCI Credit Card dataset (whether or not certain people will default ...
4
votes
1answer
806 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
106 views

Is there an algorithm that imputes missing values based on n nearest columns? (KNN hybrid)

I have a dataset of 70 columns that have missing values. Each column has a few columns (3-5) that it is significantly more correlated than the others but each column's correlated columns are very ...
4
votes
1answer
2k 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
8k views

Can Keras be used to build clustering models

The keras.wrappers.scikit_learn module can be used to build KerasClassifier model. Can Keras ...
4
votes
1answer
5k 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
1answer
4k views

How to use precomputed distance matrix and min_sample for DBSCAN clustering method?

I want to perform DBSCAN on my datapoints, but I don't have access to the data, I just have the pairwise distance of datapoints. Additionally, I have no idea about the number of clusters but I do want ...
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
3answers
1k views

Feature Selection for K Nearest Neighbour and Decision Trees

I have 2 digits numbers and 9 features. I must pick 2 features, so decided to plot the features against each other to see whether I can get any insight on the best features to train my algorithm. ...
4
votes
1answer
795 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. ...

1
3 4
5
6 7
37