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

Is it possible to have a default class in multi class classification?

In the general text classification problem, training a machine learning model to detect if a text belongs to one of N number of classes always yields a value in N. Even if the text that was passed to ...
2
votes
1answer
19 views

(Feature selection) In which cases it is legitimate to remove features manually?

I am dealing with the feature in which only one category takes up about 90%, the instances of more than 30 other categories are sparse. Is it reasonable to remove this feature before building an ...
1
vote
1answer
36 views

(Feature Selection) different results from L2-based and Tree-based

I am doing feature selection using Sklearn: Tree-based feature selection : RandomForestClassifier.feature_importances_ L2-based feature selection: LogisticRegression.coef_ Target variable is binary ...
0
votes
1answer
47 views

Transform test data when using a persistent model

I'm quite new to data science and only slowly following the necessary steps to get valid results using scikit-learn. As far as I understand you fit and transform the training data and only transform ...
3
votes
1answer
76 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 ...
1
vote
1answer
31 views

(Scikit-learn) differences between LinearSVC, 'linear' kernel SVC and poly kernel SVC with degree 1

I would like to know the differences between: linearSVC() SVC(kernel='lineaer) ...
0
votes
0answers
16 views

How to get subsample indices from sklearn.BaggingRegressor

I'm trying to define the number of the repeated samples in sklearn random forest subsamples: Here is my code: ...
0
votes
1answer
44 views

sklearn: sklearn.linear_model.HuberRegressor vs sklearn.linear_model.ElasticNet

I am experimenting different loss functions for my regression model. I noticed that in the sklearn, there are: sklearn.linear_model.HuberRegressor and sklearn.linear_model.ElasticNet To me, both use ...
2
votes
1answer
72 views

Why is the result of CountVectorizer * TfidfVectorizer.idf_ different from TfidfVectorizer.fit_transform()?

I have a dataframe: df = pd.DataFrame({'docs': ['gamma alfa beta beta epsilon', 'beta gamma eta',], 'labels': ['alfa alfa beta', 'gamma fi']}) I use count ...
0
votes
1answer
137 views

Difference of sklearns accuracy_score() to the commonly accepted Accuracy metric

I am trying to evaluate the accuracy of a multiclass classification setting and I'm wondering why the sklearn implementation of the accuracy score deviates from the commenly agreed on accuracy score: $...
1
vote
1answer
20 views

How to approach this multi label classification problem and what will be its accuracy metric?

I have a dataset for people doing trade in various segments (classes) .I am trying to build a multi-label classifier to predict people trading in various segments (classes). My dataset : ...
0
votes
0answers
19 views

Same topics appearing multiple times in a NMF model

I am using NMF (Non-negative Matrix factorization) module from Scikit learn to extract 100 topics from a corpus. In contrast to LDA, the output of NMF modeling includes some of the topics multiple ...
2
votes
0answers
20 views

Scikit learn - best model to classify supervised two-feature data?

I'm quite new to scikit learn but I am looking for the best approach to go about classifying some data I've collected where each set contains two measurements made over several points of time, along ...
1
vote
0answers
18 views

Minimizing overfitting when doing hyperparameter Tuning

Generaly when using Sklearn's GridSearchCV (or RandomizedGridSearchCV), we get best model with best test score even if the model overfits a little bit. How can we compute generalization error ...
1
vote
0answers
32 views

Classify the input set into categories based on pre-defined rule set

I'm trying to solve a problem where there are 2 input files given, Input 1: A set of strings in the format. All the strings start with "A". A-B-C-D A-B-C-3 A-X-Y-Z-4 A-X-5 A-X-P-Q-R A-X-P-Q-S A-M-9-...
1
vote
3answers
42 views

When to normalize or regularize features in Data Science

How can I know when I need to use normalization and when regularization of features. I know that when I have big difference between min and max values in some feature / column that i need to scale ...
0
votes
0answers
14 views

Using selected variables after dimensionality reduction throws a value error

I am working on a regression problem, namely the Boston House prediction problem hosted on Kaggle. I am currently using Random Forest Classifier to reduce the dimensions of my dataset. But right now, ...
2
votes
1answer
40 views

Data sets that have strings and numerical data all in one column

I m new to the field of Data Science, but I have a great passion for it. Here's a code I wrote for pre processing a data set. It works ...
2
votes
1answer
113 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: <...
0
votes
0answers
19 views

Anomaly detection when doing clustering of text data

Im doing clustering of text data and Im wondering is there a way to do anomaly detection when doing clustering of text data. I have a code that works, I have vectorized the data but I do not know how ...
0
votes
0answers
14 views

How it works the tree.query() method for kdtree?

I already saw the implementation in Cython, but still I can't understand how the search happens? It's used some Maxheap in order to store the k-nearest-neighbors that are found util yet, but it seems ...
1
vote
0answers
80 views

Use LightGBM or FFM - imbalanced dataset

I have a highly imabalanced dataset but one that is not sparse. In train there are 1328 positives out of 104000. In validation ...
2
votes
1answer
135 views

sklearn.accuracy_score(y_test, y_predict) vs np.mean(y_predict == y_test)

What is the difference between these two methods for finding model accuracy? I have used both methods in python3 and i normally get identical results. However in few cases i get completely different ...
1
vote
1answer
36 views

Is it compulsary to normalize the dataset if doing so can negatively impact a Binary Logistic regression performance?

I am using raw data set with 4 feature variables to do a Binominal Classification using Logistic Regression Algorithm. I made sure that the class counts are balanced. i.e., an equal number of ...
-1
votes
1answer
50 views

Word Embeddings with TFIDF vectorizer

I am a beginner in machine learning. I have a large corpus of texts, divided into thematic groups. I would like to get idf values for the whole corpus, and then apply it on each group before ...
0
votes
1answer
26 views

Flattening output before calculating metrics

I use scikit-learn to calculate precision, recall and f1 scores which only accept 1D arrays, but my model's outputs are 2D (binary segmentation maps). My question is, is it ok to simply flatten the ...
1
vote
1answer
26 views

Does the length of the text data affects the score of clustering

I'm learning about clustering with Pythons Scikit-Learn lib. I have a list of sentences (strings) . Im wondering, does the length of the string affects the ...
0
votes
0answers
11 views

Scikit learn kneighbors_graph: distances needed as input?

I'm building a graph using Scikit-learn's kneighbors_graph() function. What I didn't understand is whether I need to provide a distance matrix as input, or if the ...
0
votes
0answers
16 views

How to use skimage.feature.hog to calculate hog of training data where examples are stacked vertically

I have a $n*1024$ dimensional $2D$ array where n is number of examples which contain n images($32*32$) stacked vertically. I would like to calculate the hog of these images ...
1
vote
0answers
43 views

MultiOutput Regression Model

I have a dataset of 187 data points (numeric data) with 8 features that I need to train to predict 4 target variables. What would be a good algorithm to go about solving this? Ideally, I want an ...
0
votes
0answers
26 views

Linear/Logistic Regression for unknown values or how to get a good prior for new coefficients

Suppose, we model the probability of making holidays by country and town. The input data are people and how many people actually made holiday in that particular town: ...
0
votes
1answer
33 views

How to use a a trained model

I just trained my first model in Python 3.7/scikitlearn (Linear Regression) (well I copied most of the code but its something ^^). Now I want to actually Use the model. Specifically its about sons ...
2
votes
1answer
440 views

How to interpret Logistic regression coefficients using scikit learn

I have created a model using Logistic regression with 21 features, most of which is binary. I created these features using get_dummies. Few of the other features are numeric. I get a very good ...
1
vote
0answers
120 views

Naive Bayes for Categorical Features (Non Binary)

How do i use Naive Bayes Classifier (Using sklearn) for a Dataset considering that my feature set is categorical, ie more than 2 categories per feature are present. I've looked everywhere, some ...
0
votes
1answer
43 views

Python can't take input while using functions

While building my model, I figured that it makes sense to reuse some of the code that I've been using for the train dataset, on the test set as well so I took the code performing mutual operations ...
0
votes
1answer
22 views

How to derive association from a regression model?

I understand how to make predictions with a trained neural network model that uses loss=binary_crossentropy and a 1-node ...
9
votes
3answers
2k views

How to encode a class with 24,000 categories?

I'm currently working on a logistic regression model for genomics. One of the input fields I want to include as a covariate is genes. There are around 24,000 known ...
0
votes
1answer
34 views

How to structure my data into features and targets for PCA on Big Data?

I want to apply the PCA algorithm from Scikit-Learn.(https://scikit-learn.org/stable/modules/generated/sklearn.decomposition.PCA.html ) At the part where I have to separate the features and the ...
0
votes
0answers
4 views

Questions about LabelPropagation

I have been tasked with identifying which of our customers are most similar to a specific subset. My instinct was to treat this as a semi-supervised problem and use scikit-learn's LabelPropagation ...
1
vote
1answer
22 views

How to compare a sentence with a paragraph and get its probability in terms of correctness?

This is my first post on stackoverflow network and I am dealing with a machine learning. Lets say I have a paragraph describing a rabbit and tortoise story. The story concludes that tortoise is a ...
1
vote
0answers
25 views

ValueError when reshaping to 4 dim array for the Keras API

DL beginner here. I'm trying to implement LeNet using Keras and apply it on good ol' MNIST. ...
1
vote
0answers
13 views

different outcome of feature importance and coefficient from same data

I built a regression model to predict profit based on client, sales person, product category, client industry and client region. After trying several models with tuning hyperparameters, I found that ...
1
vote
1answer
21 views

making predictions from detrended data

I am building a machine learning based model (random forest in scikit-learn) to predict maize yields in the U.S. based on data on historical maize yields and temperature and precipitation information. ...
0
votes
1answer
33 views

a bit confused about the norm in Ordinary Least Squares

I'm learning Scikit-learn and I can't understand a part of math. Can anyone explain to me?
1
vote
0answers
24 views

Difference between RFECV and SFS?

I used scikit.REFCV and mlxtend.SFS (backward) on the same data, same classifier, same cv, same scorer,... I also did a third version with sample weights passed to SFS's estimator And i'm conflicted ...
0
votes
1answer
107 views

Using a LinearSVC() for multilabel classification with MultiOutputClassifier() in a pipeline in sci-kit learn

My input data is a (23948,) pandas.Series of strings containing newspaper headlines. My target are 20 labels of the headline (e.g. 'crime', 'politics') each binarily encoded with [0, 1]. The labels ...
1
vote
1answer
22 views

Suggestion on tag clustering visualization

I have a database of tags given by users to the product. For example user; product; tag 1; A; Tag1 1; A; Tag2 2; A; Tag1 2; B; Tag1 .. .. I am trying to cluster ...
0
votes
2answers
98 views

What is “data scaling” regarding StandardScaler()?

I'm trying to figure out the purpose of StandardScaler() in sklearn. The tutorial I am following says "Remember that you also need to perform the scaling ...
0
votes
1answer
43 views
1
vote
0answers
22 views

Scikit-compatible network lasso implementation

Is anyone aware of a scikit-compatible network Lasso (nLasso) implementation? These papers have source code as well: D. Hallac, J. Leskovec, and S. Boyd, “Network lasso: Clustering and ...