Questions tagged [multilabel-classification]

Multi-label classification refers to the problem in Machine Learning of assigning multiple target labels to each sample, where the labels represent a property of the sample point and need not be mutually exclusive.

844 questions
14
votes
2 answers

Is One-Hot Encoding required for using PyTorch's Cross Entropy Loss Function?

For example, if I want to solve the MNIST classification problem, we have 10 output classes. With PyTorch, I would like to use the torch.nn.CrossEntropyLoss function. Do I have to format the targets so that they are one-hot encoded or can I simply…
14
votes
3 answers

Multi-class multi-label confusion matrix with Sklearn

I am working with a multi-class multi-label output from my classifier. The total number of classes is 14 and instances can have multiple classes associated. For example: y_true = np.array([[0,0,1], [1,1,0],[0,1,0]) y_pred = np.array([[0,0,1],…
14
votes
2 answers

Is there a way to perform grid search hyper-parameter optimization on One-Class SVM

Is there a way to use GridSearchCV or any other built-in sklearn function to find the best hyper-parameters for OneClassSVM classifier? What I currently do, is perform the search myself using train/test split like this: Gamma and nu values are…
14
votes
1 answer

Scikit-learn multi-output classifier using: GridSearchCV, Pipeline, OneVsRestClassifier, SGDClassifier

I am attempting to build a multi-output model with GridSearchCV and Pipeline. The Pipeline is giving me trouble because standard classifier examples don't have the OneVsRestClassifier() wrapping the classifier. I'm using scikit-learn 0.18 and python…
MyopicVisage
  • 1,333
  • 1
  • 19
  • 33
13
votes
3 answers

Keras class_weight in multi-label binary classification

Having trouble using class_weight for my multi-label problem. That is, each label is either 0 or 1, but there are many labels for each input sample. The code (with random data for MWE purposes): import tensorflow as tf from keras.models import…
12
votes
5 answers

why is my fastapi or uvicorn getting shutdown?

I am trying to run a service that uses simple transformers Roberta model to do classification. the inferencing script/function itself is working as expected when tested. when i include that with fast api its shutting down the…
10
votes
1 answer

Dumping XGBClassifier model into text

I train a multi label classification model with XGBBoost and want to code this model in another system. Is it possible to see the text output of my XGBClassifier model as dump_model in XGB Booster. Edit: I found that…
Sabri Karagönen
  • 2,212
  • 1
  • 14
  • 28
9
votes
2 answers

How to do GridSearchCV for F1-score in classification problem with scikit-learn?

I'm working on a multi classification problem with a neural network in scikit-learn and I'm trying to figure out how I can optimize my hyperparameters (amount of layers, perceptrons, other things eventually). I found out that GridSearchCV is the…
9
votes
1 answer

Doing Multi-Label classification with BERT

I want to use BERT model to do multi-label classification with Tensorflow. To do so, I want to adapt the example run_classifier.py from BERT github repository, which is an example on how to use BERT to do simple classification, using the…
Nakeuh
  • 1,757
  • 3
  • 26
  • 65
9
votes
2 answers

Error: Classification metrics can't handle a mix of multiclass-multioutput and multilabel-indicator targets

I am newbie to machine learning in general. I am trying to do multilabel text classification. I have the original labels for these documents as well as the result of the classification (used mlknn classifier) represented as one hot encoding (19000…
Lossan
  • 411
  • 1
  • 8
  • 16
9
votes
2 answers

Classification: skewed data within a class

I'm trying to build a multilabel-classifier to predict the probabilities of some input data being either 0 or 1. I'm using a neural network and Tensorflow + Keras (maybe a CNN later). The problem is the following: The data is highly skewed. There…
8
votes
1 answer

How To Calculate F1-Score For Multilabel Classification?

I try to calculate the f1_score but I get some warnings for some cases when I use the sklearn f1_score method. I have a multilabel 5 classes problem for a prediction. import numpy as np from sklearn.metrics import f1_score y_true =…
8
votes
1 answer

Python scikit learn multi-class multi-label performance metrics?

I ran Random Forest classifier for my multi-class multi-label output variable. I got below output. My y_test values Degree Nature 762721 1 7 548912 0 6 727126 1 12 14880 …
8
votes
3 answers

Sklearn - How to predict probability for all target labels

I have a data set with a target variable that can have 7 different labels. Each sample in my training set has only one label for the target variable. For each sample, I want to calculate the probability for each of the target labels. So my…
Bert Carremans
  • 1,623
  • 4
  • 23
  • 47
8
votes
1 answer

scikit-learn: get selected features when using SelectKBest within pipeline

I am trying to do features selection as a part of the a scikit-learn pipeline, on a multi-label scenario. My purpose is to select best K features, for some given k. It might be simple, but I don't understand how to get the selected features indices…
1
2
3
56 57