auc

How to calculate AUC for One Class SVM in python?

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have difficulty in plotting OneClassSVM's AUC plot in python (I am using sklearn which generates confusion matrix like [[tp, fp],[fn,tn]] with fn=tn=0 . from sklearn.metrics import roc_curve, auc fpr, tpr, thresholds = roc_curve(y_test, y_nb_predicted) roc_auc = auc(fpr, tpr) # this generates ValueError[1] print "Area under the ROC curve : %f" % roc_auc plt.plot(fpr, tpr, label='ROC curve (area = %0.2f)' % roc_auc) I want to handle error [1] and plot AUC for OneClassSVM . [1] ValueError: Input contains NaN, infinity or a value too large

Sklearn: ROC for multiclass classification

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 = enc.fit_transform(labels) feat_sel = SelectKBest(mutual_info_classif, k=200) clf = linear_model.LogisticRegression() pipe = Pipeline([('vectorizer', DictVectorizer()), ('scaler', StandardScaler(with_mean=False)), ('mutual_info', feat_sel), ('logistregress', clf)]) y_pred = model_selection.cross_val

Easy way of counting precision, recall and F1-score in R

北战南征 提交于 2019-12-03 04:25:03
问题 I am using an rpart classifier in R. The question is - I would want to test the trained classifier on a test data. This is fine - I can use the predict.rpart function. But I also want to calculate precision, recall and F1 score. My question is - do I have to write functions for those myself, or is there any function in R or any of CRAN libraries for that? 回答1: The ROCR library calculates all these and more (see also http://rocr.bioinf.mpi-sb.mpg.de): library (ROCR); ... y <- ... # logical

Feature Selection in caret rfe + sum with ROC

亡梦爱人 提交于 2019-12-03 03:19:49
I have been trying to apply recursive feature selection using caret package. What I need is that ref uses the AUC as performance measure. After googling for a month I cannot get the process working. Here is the code I have used: library(caret) library(doMC) registerDoMC(cores = 4) data(mdrr) subsets <- c(1:10) ctrl <- rfeControl(functions=caretFuncs, method = "cv", repeats =5, number = 10, returnResamp="final", verbose = TRUE) trainctrl <- trainControl(classProbs= TRUE) caretFuncs$summary <- twoClassSummary set.seed(326) rf.profileROC.Radial <- rfe(mdrrDescr, mdrrClass, sizes=subsets,

How to calculate AUC with tensorflow?

こ雲淡風輕ζ 提交于 2019-12-03 03:09:21
I've built a binary classifier using Tensorflow and now I would like to evaluate the classifier using AUC and accuracy. As far as accuracy is concerned, I can easily do like this: X = tf.placeholder('float', [None, n_input]) y = tf.placeholder('float', [None, n_classes]) pred = mlp(X, weights, biases, dropout_keep_prob) correct_prediction = tf.equal(tf.argmax(pred, 1), tf.argmax(y, 1)) accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) When calculating AUC I use the following: print(tf.argmax(pred, 1).dtype.name) print(tf.argmax(pred, 1).dtype.name) a = tf.cast(tf.argmax(pred, 1)

Difference between using train_test_split and cross_val_score in sklearn.cross_validation

匿名 (未验证) 提交于 2019-12-03 02:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a matrix with 20 columns. The last column are 0/1 labels. The link to the data is here . I am trying to run random forest on the dataset, using cross validation. I use two methods of doing this: using sklearn.cross_validation.cross_val_score using sklearn.cross_validation.train_test_split I am getting different results when I do what I think is pretty much the same exact thing. To exemplify, I run a two-fold cross validation using the two methods above, as in the code below. import csv import numpy as np import pandas as pd from

Matlab, how to calculate AUC (Area Under Curve)?

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have the file data.txt with two columns and N rows, something like this: 0.009943796 0.4667975 0.009795735 0.46777886 0.009623984 0.46897832 0.009564759 0.46941447 0.009546991 0.4703958 0.009428543 0.47224948 0.009375241 0.47475737 0.009298249 0.4767201 [...] Every couple of values in the file correspond to one point coordinates (x,y). If plotted, this points generate a curve. I would like to calculate the area under curve (AUC) of this curve. So I load the data: data = load ( "data.txt" ); X = data (:, 1 ); Y = data (:, 2 ); So,

Heatmap with text in each cell with matplotlib&#039;s pyplot

匿名 (未验证) 提交于 2019-12-03 01:54:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I use matplotlib.pyplot.pcolor() to plot a heatmap with matplotlib: import numpy as np import matplotlib.pyplot as plt def heatmap(data, title, xlabel, ylabel): plt.figure() plt.title(title) plt.xlabel(xlabel) plt.ylabel(ylabel) c = plt.pcolor(data, edgecolors='k', linewidths=4, cmap='RdBu', vmin=0.0, vmax=1.0) plt.colorbar(c) def main(): title = "ROC's AUC" xlabel= "Timeshift" ylabel="Scales" data = np.random.rand(8,12) heatmap(data, title, xlabel, ylabel) plt.show() if __name__ == "__main__": main() Is any way to add the corresponding

Tensorflow 1.4 tf.metrics.auc for AUC calculation

匿名 (未验证) 提交于 2019-12-03 01:37:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to log AUC during training time of my model. According to the documentation , tf.metric.auc needs a label and predictions , both of same shape. But in my case of binary classification, label is a one-dimensional tensor, containing just the classes. And prediction is two-dimensional containing probability for each class of each datapoint. How to calculate AUC in this case? 回答1: Let's have a look at the parameters in the function tf.metrics.auc : labels : A Tensor whose shape matches predictions. Will be cast to bool . predictions

Plot ROC curve and calculate AUC in R at specific cutoff info

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given such data: SN = Sensitivity; SP = Specificity Cutpoint SN 1-SP 1 0.5 0.1 2 0.7 0.2 3 0.9 0.6 How can i plot the ROC curve and calculate AUC. And compare the AUC between two different ROC curves. In the most of the packages such pROC or ROCR, the input of the data is different from those shown above. Can anybody suggest the way to solve this problem in R or by something else? ROCsdat <- data.frame(cutpoint = c(5, 7, 9), TPR = c(0.56, 0.78, 0.91), FPR = c(0.01, 0.19, 0.58)) ## plot version 1 op <- par(xaxs = "i", yaxs = "i") plot(TPR ~