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
0
votes
0answers
6 views

Ordering of sklearn's confusion_matrix()

Trying to figure out how to sort integer labels on a 102X102 (oxford102 UK flower dataset) confusion matrix graph that I plot with plot_confusion_matrix from mlxtend. I see that basically conf_mat and ...
1
vote
1answer
20 views

relaying on feature during training that won't (necessarily) be available during prediction

I'm doing a little project of bugs prediction. My goal is to predict which bug will be (eventually) assigned to which relevant group (this is my label obviously). For training, I'm relaying on a bugs ...
0
votes
1answer
19 views

Is Cross validation and GridSearchCV required every time we train a model?

I have a repetitive process that will build a model weekly based on the previous week's data. So while in development I tried GridSearchCV and cross-validation to ...
0
votes
0answers
8 views

Do sklearn Pipelines automatically split big datasets in chunks for the transform method?

Do sklearn Pipelines automatically split big datasets in chunks for the transform method? Each transformer in the pipe has a transform method. It seems as sklearn by default pushes all X_train into ...
2
votes
1answer
19 views

Can I add new features in an existing dataset using function transformers in scikit-learn

I have written a code that can add 3 new columns into a NumPy array, using function transformer(1 st column is element-wise +, 2nd is element-wise *, 3rd is element-wise /. Just need to know if in ...
1
vote
0answers
13 views

Normalization before PCA in NLP domains?

I'm working on a basic bag-of-words toy NLP pipeline for sentiment analysis using scikit-learn. From research of other questions here, it seems that the main applicable scaler for before PCA is the ...
0
votes
1answer
19 views

Does Cross Validation require splitting/shuffling and fitting of data beforehand?

I am trying to evaluate a logistic regression classifier using k-fold cross validation. I wanted to know if I need to shuffle data before hand when using cross_validate_predict and if I need to fit ...
0
votes
1answer
19 views

Measure of Separation for fuzzy clustering

Is there a measure of separation such as the Sillohete score for fuzzy clustering? I understand the logic for Hard-clustering algorithms but not sure about fuzzy. Is there a Python package for that ...
0
votes
0answers
25 views

How to interpret predict_proba() when predicting one class?

When we try to predict a test set that contains just one class, the.predict_proba() method returns a 2D array with 2 columns instead of 1. My guess is that it ...
0
votes
1answer
13 views

How should a stateless data transformation be applied in regard to train/test split?

I want to apply spatial sign transformation to my data, but unlike other transformations this one is stateless. I am using sklearn and normallly i would first use ...
0
votes
0answers
23 views

Why am I getting good validation scores, but poor test scores in Kaggle competition

I am participating in a Kaggle multiclass classification competition. The submissions will be scored based on the 'logloss' score. I am using Keras and Scikit libraries and a deep learning network ...
0
votes
0answers
17 views

keras: How to connect Resnet 50 pre trained model to decision tree algorithm for classification?

can we extract features from Resnet50 pre trained model and connect it to Sci-kit learn decision tree for classification.
0
votes
0answers
16 views

Why is HistGradientBoostingRegressor in sklearn so fast and low on memory?

I trained multiple models for my problem and most ensemble algorithms resulted in lengthy fit and train time and huge model size on disk (approx 10GB for RandomForest) but when I tried ...
0
votes
0answers
15 views

Calibration of a few binary classifiers is not perfect - why?

I am working on a binary classifier using LightGBM. I try to see the results of the classifiers when changing the costs of false positives and false negatives, still working on the same training and ...
0
votes
0answers
16 views

Tertiary regression trees

Is there a prepackaged python or R set of functions which have ternary (three branches) decision trees? All of the out of the boxes I can find are for binary decision trees. A wiki can be found here.
1
vote
2answers
48 views

Is it usual for Scikit learn's standard scaler to cause non-invertibility?

For example, I am trying to perform linear regression on the following set of data Data examples: $X = [[1, 20], [3, 40], [5, 60]]$ (each row is an example, there are three examples, each with a ...
0
votes
0answers
21 views

In Decision Tree Use Feature only Once

Within sklearn.tree.DecisionTreeRegressor is it possible to specify to only use a feature once? I am thinking of a setting 'without replacement' in a Random Forest sense.
0
votes
0answers
27 views

why is my ANN performing worse with more training data?

I'm trying to build a NN to approximate the results of a non-linear finite element model. I'm using sklearn.neural_network.MLPRegressor with the LBFGS solver and ...
0
votes
1answer
9 views

Does the `cross_val_score` do cross validation on the sampled dataset or the original?

From this example taken from https://machinelearningmastery.com/smote-oversampling-for-imbalanced-classification/ ...
0
votes
0answers
22 views

classification of bugs ownership by their content (improve score for log analysis)

I'm doing a little project in which given a dataset of bugs and their relevant owner, I'd like to predict the "final owner" of a non-analyzed bug (bugs tends to assign back and forth between ...
0
votes
0answers
19 views

Label description for scikit-learn Diabetes dataset

I am studying how to build a regression model using the Diabetes dataset from scikit-learn and I cannot find a good interpretation for the target value, meaning that I do not know what value would be ...
0
votes
0answers
24 views
0
votes
1answer
18 views

Why do I get different coefficients from Logistic regression in Python and SPSS

I am a bit confused in regards to the model coefficients calculated by SPSS and sklearn's LogisticRegression. I am getting different coefficients and intercepts for both methods. in Python, I am ...
0
votes
0answers
20 views

Sine curve fitting

I want to fit a a * abs(sin(b*x - c)) + d function for each of the following data. In most of the cases I'm able to get decent accuracy. But for some cases, I'm not ...
0
votes
1answer
32 views

Text Classification misclassifying?

I am trying to solve a binary classification problem. My labels are abusive (1) and non-abusive (0). My dataset was imbalanced (more 1 than 0s) and I used oversampling of the minority label (i.e. 1) ...
1
vote
1answer
27 views

Handling nominal category features in decision tree

I have been reading some stackoverflow questions on how to handle nominal features for decision tree (sklearn implementation). One of the answer states that : Using a OneHotEncoder is the only current ...
1
vote
1answer
11 views

TPOT machine learning

I trained a regression TPOT algorithm on Google Colab, where the output of the TPOT process is some boiler plate Python code as shown below. ...
1
vote
1answer
41 views

Extremely negative r^2

I use a linear regression to predict house prices (https://www.kaggle.com/c/house-prices-advanced-regression-techniques/overview). My linear regression sometimes works great with R^2 of 0.8 and ...
1
vote
0answers
10 views

How marginal contributions of adding a variable in a model is calculated in determining SHAP feature importance?

I was trying to find feature importance using SHAP values in python for Isolation Forest. SHAP calculates the feature importance of a feature($i$) pertaining to a model($f$) for a datapoint($x$) using ...
1
vote
0answers
6 views

Predict pixels in optdigits data set

I'm using this dataset : https://archive.ics.uci.edu/ml/datasets/optical+recognition+of+handwritten+digits a dataset that consists of 65 columns , the last column is the label for 10 classes i.e 0,1,2,...
0
votes
0answers
21 views

Inconsistancy in Sklearn SVM predict() and predict_proba()

Actually I have two questions. One of them is related the bug of sklearn SVM model and the other one is about ROC-AUC score. My first question is related to ROC-AUC score but also includes a bug ...
1
vote
0answers
12 views

Dot product of two matrices in NLP how can i get this error be solved [closed]

from sklearn.metrics.pairwise import linear_kernel sim_matrix = linear_kernel(tfidf_matrix, tfidf_matrix) when I try to get dot product I am getting this errro <...
2
votes
1answer
16 views

SGDClassifier - Why do I need to use argmax instead of argmin to find the lowest threshold satisfying given precision?

I am an experienced programmer, but new to Python and data science. I am following Aurelien Gerone's book and I don't understand one thing. I create SGDClassifier and calculate its ...
2
votes
0answers
23 views

What would be a good randomization environment for data science?

I would like to know if there are any best practices to optimize random environment. Currently I use this simple structure in my config : ...
1
vote
0answers
16 views

Label spreading for classification/clustering problems

I have a question regarding label propagation and label spreading semi-supervised algorithms. I am working on building a look-alike model to identify marketing personas. Using supervised learning ...
1
vote
1answer
97 views

Big array and MemoryError: Unable to allocate memory (in Python)

I am trying to create a predictive model using linear regression with a dataset that has 157673 entries. The data (in a csv file) is in such format: ...
1
vote
1answer
29 views

Can anyone help with me how to train new data with already saved pickle file? [closed]

Can anyone help me with the code me to train new data with already saved pickle file? I've trained the model with RandomForestClassifier from sklearn and saved the model into .pickle Now I'm trying to ...
1
vote
1answer
14 views

How Sklearn-crfsuit interpret text features

As we see here, to build an NER model we can pass text features (parts of the word, pos tag, structure of the word etc.) to Sklearn-CRF. I was wondering how does this package convert the text features ...
2
votes
1answer
96 views

Feature importance with Text features

I would like to determine features importance in several models: support vector machine logistic regression Naive Bayes random forest I read that I will need an agnostic model, so I have thought to ...
0
votes
1answer
26 views

Best parameters to try while hyperparameter tuning in Decision Trees

I want to post prune my decision tree as it is overfitting, I can do this using cost complexity pruning by adjusting ccp_alphas parameters however this does not seem very intuitive to me. From my ...
0
votes
1answer
13 views

What's the default Scorer in Sci-kit learn's GridSearchCV?

Even if I don't define the scoring parameter, it scores and makes a decision for best estimator, but documentation says the default value for scoring is "None", so what is it using to score ...
0
votes
0answers
9 views

Minimising inputs for decision tree predictions

It is common for decision trees with asymmetrical shapes to have leave nodes that come early. For example, the model can already generate a prediction if the answer to the first question is FALSE, ...
0
votes
0answers
11 views

How to configure null hypothesis or what's the null hypothesis when using sklearn?

I'm predicting how BMI, GDP, ... factors affect life expectancy. Firstly, I tried to select topK features. ...
1
vote
1answer
30 views

How does transform work?

I was looking at the source codes of MinMaxScaler on Github. I know that when you fit a preprocessing class to a dataset, it takes the data and prepares it for transformation. Let's say, I fitted ...
0
votes
1answer
30 views

scikit learn target variable reversed (DecisionTreeClassifier)

I created a Decision Tree Classifier using sklearn, defined the target variable: ...
2
votes
1answer
39 views

Training is not stable with extreme class imbalance

I'm dealing with a multi-class classification problem with around 30 categories. This problem has a severe class imbalance: Around 300 examples for the least common class. Around 100k examples for ...
2
votes
2answers
47 views

Node Importance in scikit learn

I'm trying to understand exactly how feature_importances in scikit-learn's RandomForestClassifier works. I managed to find this helpful link explaining most of the process: https://towardsdatascience....
0
votes
1answer
20 views

How does sklearn random forest decide feature threshold at node splitting exactly?

Thinking of the RandomForestClassifier function in sklearn.ensemble, I understand that at each non-terminal node the algorithm: Randomly selects a subset of size max_features from the set of all ...
0
votes
0answers
17 views

Using class weight in decision trees with Information Gain

How are weights considered in a decision tree when we want to maximize Information Gain? In other words, what would the entropy calculation become when weights are involved? I can guess either $$ e_1 =...
0
votes
1answer
12 views

Train and predict two labels in a single process

I have a python program that makes predictions using scikit-learn RandomForestClassifier. The label is called "default" and it's the default status of a ...

1
2 3 4 5
38