Questions tagged [multiclass-classification]
776 questions
43
votes
4 answers
ROC for multiclass classification
I'm doing different text classification experiments. Now I need to calculate the AUC-ROC for each task. For the binary classifications, I already made it work with this code:
scaler = StandardScaler(with_mean=False)
enc = LabelEncoder()
y =…

Bambi
- 715
- 2
- 8
- 19
42
votes
1 answer
Get Confusion Matrix From a Keras Multiclass Model
I am building a multiclass model with Keras.
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
model.fit(X_train, y_train, batch_size=batch_size, epochs=epochs, verbose=1, callbacks=[checkpoint],…

ATMA
- 1,450
- 4
- 23
- 33
39
votes
3 answers
What is the difference between OneVsRestClassifier and MultiOutputClassifier in scikit learn?
Can someone please explain (with example maybe) what is the difference between OneVsRestClassifier and MultiOutputClassifier in scikit-learn?
I've read documentation and I've understood that we use:
OneVsRestClassifier - when we want to do…

PeterB
- 2,234
- 6
- 24
- 43
18
votes
3 answers
True Positive Rate and False Positive Rate (TPR, FPR) for Multi-Class Data in python
How do you compute the true- and false- positive rates of a multi-class classification problem? Say,
y_true = [1, -1, 0, 0, 1, -1, 1, 0, -1, 0, 1, -1, 1, 0, 0, -1, 0]
y_prediction = [-1, -1, 1, 0, 0, 0, 0, -1, 1, -1, 1, 1, 0, 0,…

M K
- 406
- 1
- 3
- 9
18
votes
4 answers
Multiclass Classification with LightGBM
I am trying to model a classifier for a multi-class Classification problem (3 Classes) using LightGBM in Python. I used the following parameters.
params = {'task': 'train',
'boosting_type': 'gbdt',
'objective': 'multiclass',
…

Sreeram TP
- 11,346
- 7
- 54
- 108
13
votes
2 answers
XGBoost for multiclassification and imbalanced data
I am dealing with a classification problem with 3 classes [0,1,2], and imbalanced class distribution as shown below.
I want to apply XGBClassifier (in Python) to this classification problem, but the model does not respond to class_weight…

Pooyan Moradifar
- 145
- 1
- 1
- 6
12
votes
3 answers
AxisError: axis 1 is out of bounds for array of dimension 1 when calculating AUC
I have a classification problem where I have the pixels values of an 8x8 image and the number the image represents and my task is to predict the number('Number' attribute) based on the pixel values using RandomForestClassifier. The values of the…

Bálint Béres
- 168
- 1
- 1
- 9
12
votes
2 answers
Spark ML - MulticlassClassificationEvaluator - can we get precision/recall by each class label?
I am doing a multiclass prediction with random forest in Spark ML.
For this MulticlassClassificationEvaluator() in spark ML, is it possible to get precision/recall by each class labels?
Currently, I am only seeing precision/recall combined for all…

Sam
- 121
- 1
- 5
11
votes
4 answers
Assertion failed: predictions must be >= 0, Condition x >= y did not hold element-wise
I am running a multi-class model(total 40 class in total) for 2000 epochs. The model is running fine till 828 epoch but at 829 epoch it is giving me an InvalidArgumentError (see the screenshot below)
Below is the code that I used to build my…

learner
- 828
- 2
- 19
- 36
10
votes
1 answer
ValueError: Input 0 is incompatible with layer model: expected shape=(None, 14999, 7), found shape=(None, 7)
I'm trying to apply Conv1D layers for a classification model which has a numeric dataset. The neural network of my model is as follows:
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Conv1D(8,kernel_size = 3, strides = 1,padding =…

MOULISHANKAR
- 111
- 1
- 1
- 6
10
votes
2 answers
How to calculate multiclass overall accuracy, sensitivity and specificity?
Can anyone explain how to calculate the accuracy, sensitivity and specificity of multi-class dataset?

Rstynbl
- 545
- 2
- 6
- 10
9
votes
2 answers
How to convert one-hot vector to label index and back in Pytorch?
How to transform vectors of labels to one-hot encoding and back in Pytorch?
The solution to the question was copied to here after having to go through the entire forum discussion, instead of just finding an easy one from googling.

Gulzar
- 23,452
- 27
- 113
- 201
9
votes
1 answer
Tensorflow confusion matrix using one-hot code
I have multi-class classification using RNN and here is my main code for RNN:
def RNN(x, weights, biases):
x = tf.unstack(x, input_size, 1)
lstm_cell = rnn.BasicLSTMCell(num_unit, forget_bias=1.0, state_is_tuple=True)
stacked_lstm =…

SON.PARK
- 111
- 1
- 6
8
votes
1 answer
Why does binary accuracy give high accuracy while categorical accuracy give low accuracy, in a multi-class classification problem?
I'm working on a multiclass classification problem using Keras and I'm using binary accuracy and categorical accuracy as metrics. When I evaluate my model I get a really high value for the binary accuracy and quite a low one in for the categorical…

Ninja
- 103
- 1
- 1
- 6
7
votes
2 answers
Tensorflow, Keras: In a multi-class classification, accuracy is high, but precision, recall, and f1-score is zero for most classes
General Explanation:
My codes work fine, but the results are wired. I don't know the problem is with
the network structure,
or the way I feed the data to the network,
or anything else.
I am struggling with this error several weeks and so far I…

EhsanYaghoubi
- 145
- 3
- 14