Questions tagged [multiclass-classification]

776 questions
3
votes
2 answers

Keras custom loss function for binary encoded (not one-hot encoded) categorical data

I need help writing a custom loss/metric function for Keras. My categories are binary encoded (not one-hot). I would like to do a bitwise comparison between the real classes and the predicted classes. For example, Real-label:…
3
votes
1 answer

how does sklearn.linear_model.SGDClassifier work for multi-class classifications?

I am working on multiclass classification (10 classes). I am using sklearn.linear_model.SGDClassifier. I see that this model uses a one-versus-all approach. SGDClassifier has a paramenter class_weight: "Weights associated with classes. If not given,…
3
votes
0 answers

How to export multiclass classification neural network built in Keras to PMML

I built a neural network for a multiclass classification in Keras and need to export it to a PMML file. I'm aware of the keras2pmml package, but unfortunately this only support binary classification problems. My code: modelnew2 = Sequential() #…
3
votes
1 answer

Multiclass Classification and probability prediction

import pandas as pd import numpy from sklearn import cross_validation from sklearn.naive_bayes import GaussianNB fi = "df.csv" # Open the file for reading and read in data file_handler = open(fi, "r") data = pd.read_csv(file_handler,…
3
votes
1 answer

Categorical classification in Keras Python

I am doing multi-class classification of 5 classes. I am using Tensorflow with Keras. My code is like this: # load dataset dataframe = pandas.read_csv("Data5Class.csv", header=None) dataset = dataframe.values # split into input (X) and output (Y)…
3
votes
1 answer

Error while doing multi-class classification in spacy

I am trying to do multi-class classification and using the crowdflower text classification dataset.Below is my code: from __future__ import unicode_literals, print_function from __future__ import unicode_literals from pathlib import Path import…
loginofdeath
  • 177
  • 11
3
votes
2 answers

Interpret predicted probabilities in multiclass logistic regression

I have a dataset as given below where A,B,C,D,E are features and 'T' is Target Variable. A B C D E T 32 22 55 76 98 3 12 41 90 56 33 2 31 78 99 67 89 1 51 85 71 21 37 …
3
votes
1 answer

How to do cross validation for multiclass data?

I was able to use following method to do cross validation on binary data, but it seems not working for multiclass data: > cross_validation.cross_val_score(alg, X, y, cv=cv_folds,…
Deqing
  • 14,098
  • 15
  • 84
  • 131
2
votes
1 answer

Dealing with multi-class problem. Can Random Forest Classifier handle >100,000 classes?

I need to create a Recommender System to be able to classify >100,000 unique classes. Can anyone tell me if Random Forest Classifier can handle this problem? As far as I understood thru numerous articles on this topic, people keep saying that…
2
votes
1 answer

Precision, Recall and F1 with Sklearn for a Multiclass problem

I have a Multiclass problem, where 0 is my negative class and 1 and 2 are positive. Check the following code: import numpy as np from sklearn.metrics import confusion_matrix from sklearn.metrics import ConfusionMatrixDisplay from sklearn.metrics…
Murilo
  • 533
  • 3
  • 15
2
votes
2 answers

Training difference between LightGBM API and Sklearn API

I'm trying to train a LGBClassifier for multiclass task. I tried first working directly with LightGBM API and set the model and training as follows: LightGBM API train_data = lgb.Dataset(X_train, (y_train-1)) test_data = lgb.Dataset(X_test,…
2
votes
1 answer

openai multiclass classification logprobs doesn't return defined classes, instead it returns one class and variations of it

As stated in the title, the multiclass classification doesn't return the correct classes I defined in the training set, instead it returns the first class (predicted class) and other classes are just a variation of it. example request: curl…
2
votes
1 answer

sklearn how to mock prediction of zero probabilities of the labels that were not present in the training set?

I hope I titled this correctly. I run a multiclass classification (3 classes). And score it with ROC AUC. make_scorer(roc_auc_score, needs_proba=True, average="macro", multi_class='ovo', labels=[-1, 0, 1]) I split the train/test data with a time…
2
votes
1 answer

Does following code give recall for multiclass classification in Keras?

Does following code give recall for multiclass classification in Keras? even though I am not passing y_true and y_pred while calling recall function in model.compile, it showed me result of the recall. def recall(y_true, y_pred): y_true =…
2
votes
0 answers

ROC curves using MultiClass Random Forest: native MultiClass approach or OnevsRest?

For a multiclass problem, I can use sklearn's RandomForestClassifier out of the box: from sklearn.datasets import load_iris from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split data =…