confusion-matrix

Generate a confusion matrix for svm in e1071 for CV results

浪尽此生 提交于 2021-02-19 05:59:05
问题 I did a classification with svm using e1071 . The goal is to predict type through all other variables in dtm . dtm[140:145] %>% str() 'data.frame': 385 obs. of 6 variables: $ think : num 0 0 0 0 0 0 0 0 0 0 ... $ actually: num 0 0 0 0 0 0 0 0 0 0 ... $ comes : num 0 0 0 0 0 0 0 0 0 0 ... $ able : num 0 0 0 0 0 0 0 0 0 0 ... $ hours : num 0 0 0 0 0 0 0 0 0 0 ... $ type : Factor w/ 4 levels "-1","0","1","9": 4 3 3 3 4 1 4 4 4 3 ... To train/test the model, I used the 10-fold-cross-validation.

confusion matrix and classification report of StratifiedKFold

折月煮酒 提交于 2021-02-11 15:33:03
问题 I am using StratifiedKFold to checking the performance of my classifier. I have two classes and I trying to build Logistic Regression classier. Here is my code skf = StratifiedKFold(n_splits=10, shuffle=True, random_state=0) for train_index, test_index in skf.split(x, y): x_train, x_test = x[train_index], x[test_index] y_train, y_test = y[train_index], y[test_index] tfidf = TfidfVectorizer() x_train = tfidf.fit_transform(x_train) x_test = tfidf.transform(x_test) clf = LogisticRegression(class

confusion matrix and classification report of StratifiedKFold

独自空忆成欢 提交于 2021-02-11 15:32:06
问题 I am using StratifiedKFold to checking the performance of my classifier. I have two classes and I trying to build Logistic Regression classier. Here is my code skf = StratifiedKFold(n_splits=10, shuffle=True, random_state=0) for train_index, test_index in skf.split(x, y): x_train, x_test = x[train_index], x[test_index] y_train, y_test = y[train_index], y[test_index] tfidf = TfidfVectorizer() x_train = tfidf.fit_transform(x_train) x_test = tfidf.transform(x_test) clf = LogisticRegression(class

Confusion Matrix : Shuffle vs Non-Shuffle

不羁岁月 提交于 2021-02-11 15:23:15
问题 Here is the config of my model : "model": { "loss": "categorical_crossentropy", "optimizer": "adam", "layers": [ { "type": "lstm", "neurons": 180, "input_timesteps": 15, "input_dim": 103, "return_seq": true, "activation": "relu" }, { "type": "dropout", "rate": 0.1 }, { "type": "lstm", "neurons": 100, "activation": "relu", "return_seq": false }, { "type": "dropout", "rate": 0.1 }, { "type": "dense", "neurons": 30, "activation": "relu" }, { "type": "dense", "neurons": 3, "activation": "softmax"

ggplot2 Heatmap 2 Different Color Schemes - Confusion Matrix: Matches in Different Color Scheme than Missclassifications

自作多情 提交于 2021-02-11 05:54:18
问题 I adapted a heatmap plot for a confusion matrix from this answer. However I would like to twist it. In the diagonal (from top left to bottom right) are the matches (correct classifications). My aim would be, to plot this diagonal in a yellow color palette. And mismatches (so all tiles except those in the diagonal) in a red color palette. In my plot.cm function I can get the diagonal with cm_d$diag <- cm_d$Prediction == cm_d$Reference # Get the Diagonal cm_d$ndiag <- cm_d$Prediction != cm_d

How to construct the confusion matrix for a multi class variable

↘锁芯ラ 提交于 2021-02-07 17:49:57
问题 Suppose I have a factor variable y with n levels, for which I have both predictions and real outcomes available. How can I construct the confusion matrix? set.seed(12345) y_actual = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) set.seed(12346) y_predict = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) This question is already answered for the case n = 2. See R: how to make a confusion matrix for a predictive model? What I tried This is how far I got ones

How to construct the confusion matrix for a multi class variable

老子叫甜甜 提交于 2021-02-07 17:49:51
问题 Suppose I have a factor variable y with n levels, for which I have both predictions and real outcomes available. How can I construct the confusion matrix? set.seed(12345) y_actual = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) set.seed(12346) y_predict = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) This question is already answered for the case n = 2. See R: how to make a confusion matrix for a predictive model? What I tried This is how far I got ones

How to construct the confusion matrix for a multi class variable

谁说我不能喝 提交于 2021-02-07 17:49:03
问题 Suppose I have a factor variable y with n levels, for which I have both predictions and real outcomes available. How can I construct the confusion matrix? set.seed(12345) y_actual = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) set.seed(12346) y_predict = as.factor(sample(c('A','B', 'C', 'D', 'E'), 100, replace = TRUE)) This question is already answered for the case n = 2. See R: how to make a confusion matrix for a predictive model? What I tried This is how far I got ones

Seaborn Confusion Matrix (heatmap) 2 color schemes (correct diagonal vs wrong rest)

谁说我不能喝 提交于 2021-02-04 16:43:12
问题 Background In a confusion matrix, the diagonal represents the cases that the predicted label matches the correct label. So the diagonal is good, while all other cells are bad. To clarify what is good and what is bad in a CM for non-experts, I want to give the diagonal a different color than the rest. I want to achieve this with Python & Seaborn . Basically I'm trying to achieve what this question does in R (ggplot2 Heatmap 2 Different Color Schemes - Confusion Matrix: Matches in Different

How to normalize a confusion matrix?

拜拜、爱过 提交于 2021-02-04 09:45:49
问题 I calculated a confusion matrix for my classifier using the method confusion_matrix() from the sklearn package. The diagonal elements of the confusion matrix represent the number of points for which the predicted label is equal to the true label, while off-diagonal elements are those that are mislabeled by the classifier. I would like to normalize my confusion matrix so that it contains only numbers between 0 and 1. I would like to read the percentage of correctly classified samples from the