multiclass-classification

Why does binary accuracy give high accuracy while categorical accuracy give low accuracy, in a multi-class classification problem?

坚强是说给别人听的谎言 提交于 2020-01-23 01:35:27
问题 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 accuracy. I tried to recreate the binary accuracy metric in my own code but I am not having much luck. My understanding is that this is the process I need to recreate: def binary_accuracy(y_true, y_pred): return K.mean(K.equal(y_true, K.round(y_pred

Which is the loss function for multi-class classification in XGBoost?

二次信任 提交于 2020-01-22 19:52:06
问题 I'm trying to know which loss function uses XGBoost for multi-class classification. I found in this question the loss function for logistic classification in the binary case. I had though that for the multi-class case it might be the same as in GBM (for K classes) which can be seen here, where y_k=1 if x's label is k and 0 in any other case, and p_k(x) is the softmax function. However, I have made the first and second order gradient using this loss function and the hessian doesn't match the

Which is the loss function for multi-class classification in XGBoost?

こ雲淡風輕ζ 提交于 2020-01-22 19:52:05
问题 I'm trying to know which loss function uses XGBoost for multi-class classification. I found in this question the loss function for logistic classification in the binary case. I had though that for the multi-class case it might be the same as in GBM (for K classes) which can be seen here, where y_k=1 if x's label is k and 0 in any other case, and p_k(x) is the softmax function. However, I have made the first and second order gradient using this loss function and the hessian doesn't match the

Tensorflow confusion matrix using one-hot code

余生长醉 提交于 2020-01-11 06:50:12
问题 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 = rnn.MultiRNNCell([lstm_cell]*lstm_size, state_is_tuple=True) outputs, states = tf.nn.static_rnn(stacked_lstm, x, dtype=tf.float32) return tf.matmul(outputs[-1], weights) + biases logits = RNN(X, weights, biases) prediction = tf.nn.softmax(logits) cost =tf.reduce

Higher ROC-AUC and F-1 scores but poor looking ROC-curves

China☆狼群 提交于 2020-01-06 05:39:05
问题 I recreated a new Ensemble method that does Voting manually between my three classifiers. (Courtesty of Daniel who helped me make the function from here: Improving the prediction score by use of confidence level of classifiers on instances). The purpose of this manual voting was to accept the answers for each instance for the most confident classifier. Below is the code with their accuracy scores: # parameters for random forest rfclf_params = { 'n_estimators': 500, 'bootstrap': True, 'class

Multiclass Classification and probability prediction

佐手、 提交于 2019-12-24 08:57:16
问题 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, sep=",") file_handler.close() # split the data into training and test data train, test = cross_validation.train_test_split(data,test_size=0.6, random_state=0) # initialise Gaussian Naive Bayes naive_b = GaussianNB() train_features = train.ix[:,0:127] train_label

ValueError: Can't handle mix of multilabel-indicator and binary

 ̄綄美尐妖づ 提交于 2019-12-22 09:12:19
问题 I am using Keras with the scikit-learn wrapper. In particular, I want to use GridSearchCV for hyper-parameters optimisation. This is a multi-class problem, i.e. the target variable can have only one label chosen on a set of n classes. For instance, the target variable can be 'Class1', 'Class2' ... 'Classn'. # self._arch creates my model nn = KerasClassifier(build_fn=self._arch, verbose=0) clf = GridSearchCV( nn, param_grid={ ... }, # I use f1 score macro averaged scoring='f1_macro', n_jobs=-1

Multiclass Classification with LightGBM

允我心安 提交于 2019-12-22 04:45:17
问题 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', 'num_class':3, 'metric': 'multi_logloss', 'learning_rate': 0.002296, 'max_depth': 7, 'num_leaves': 17, 'feature_fraction': 0.4, 'bagging_fraction': 0.6, 'bagging_freq': 17} All the categorical features of the dataset is label encoded with LabelEncoder . I trained the

Model() got multiple values for argument 'nr_class' - SpaCy multi-classification model (BERT integration)

早过忘川 提交于 2019-12-21 17:02:53
问题 Hi I am working on implementing a multi-classification model (5 classes) with the new SpaCy Model en_pytt_bertbaseuncased_lg . The code for the new pipe is here: nlp = spacy.load('en_pytt_bertbaseuncased_lg') textcat = nlp.create_pipe( 'pytt_textcat', config={ "nr_class":5, "exclusive_classes": True, } ) nlp.add_pipe(textcat, last = True) textcat.add_label("class1") textcat.add_label("class2") textcat.add_label("class3") textcat.add_label("class4") textcat.add_label("class5") The code for the

Model() got multiple values for argument 'nr_class' - SpaCy multi-classification model (BERT integration)

风流意气都作罢 提交于 2019-12-21 17:01:04
问题 Hi I am working on implementing a multi-classification model (5 classes) with the new SpaCy Model en_pytt_bertbaseuncased_lg . The code for the new pipe is here: nlp = spacy.load('en_pytt_bertbaseuncased_lg') textcat = nlp.create_pipe( 'pytt_textcat', config={ "nr_class":5, "exclusive_classes": True, } ) nlp.add_pipe(textcat, last = True) textcat.add_label("class1") textcat.add_label("class2") textcat.add_label("class3") textcat.add_label("class4") textcat.add_label("class5") The code for the