auc

一文让你彻底理解准确率,精准率,召回率,真正率,假正率,ROC/AUC

馋奶兔 提交于 2019-12-12 21:13:05
参考资料: https://zhuanlan.zhihu.com/p/46714763 ROC/AUC作为机器学习的评估指标非常重要,也是面试中经常出现的问题(80%都会问到)。其实,理解它并不是非常难,但是好多朋友都遇到了一个相同的问题,那就是:每次看书的时候都很明白,但回过头就忘了,经常容易将概念弄混。还有的朋友面试之前背下来了,但是一紧张大脑一片空白全忘了,导致回答的很差。 我在之前的面试过程中也遇到过类似的问题,我的面试经验是:一般笔试题遇到选择题基本都会考这个率,那个率,或者给一个场景让你选用哪个。面试过程中也被问过很多次,比如什么是AUC/ROC?横轴纵轴都代表什么?有什么优点?为什么要使用它? 我记得在我第一次回答的时候,我将准确率,精准率,召回率等概念混淆了,最后一团乱。回去以后我从头到尾梳理了一遍所有相关概念,后面的面试基本都回答地很好。现在想将自己的一些理解分享给大家,希望读完本篇可以彻底记住ROC/AUC的概念。 ▌什么是性能度量? 我们都知道机器学习要建模,但是对于模型性能的好坏(即模型的泛化能力),我们并不知道是怎样的,很可能这个模型就是一个差的模型,泛化能力弱,对测试集不能很好的预测或分类。那么如何知道这个模型是好是坏呢?我们必须有个评判的标准。为了了解模型的泛化能力,我们需要用某个指标来衡量,这就是性能度量的意义。有了一个指标,我们就可以对比不同模型了

How to explain high AUC-ROC with mediocre precision and recall in unbalanced data?

一曲冷凌霜 提交于 2019-12-12 05:14:49
问题 I have some machine learning results that I am trying to make sense of. The task is to predict/label "Irish" vs. "non-Irish". Python 2.7's output: 1= ir 0= non-ir Class count: 0 4090942 1 940852 Name: ethnicity_scan, dtype: int64 Accuracy: 0.874921350119 Classification report: precision recall f1-score support 0 0.89 0.96 0.93 2045610 1 0.74 0.51 0.60 470287 avg / total 0.87 0.87 0.87 2515897 Confusion matrix: [[1961422 84188] [ 230497 239790]] AUC-ir= 0.901238104773 As you can see, the

Can't seem to get Tensorflow's tf.metrics.auc working

拈花ヽ惹草 提交于 2019-12-11 03:44:36
问题 Tensorflow has a function to calculate AUC: tf.metrics.auc(). Here is my a section of my code trying to compute auc: init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) for epoch in range(training_epochs): sess.run(optimizer, feed_dict = {x : x_train, y : y_train, p_keep_input: 0.8, p_keep_hidden: 0.5}) avg_cost = sess.run(cost, feed_dict = {x : x_train, y : y_train, p_keep_input: 0.8, p_keep_hidden: 0.5}) if epoch % display_step == 0: training_acc = accuracy

Python: integrating area under curve with uneven steps in x

≡放荡痞女 提交于 2019-12-10 07:28:30
问题 I have a list of y values and a list of x values. I would like to find the area under the curve defined by these points. I have found a couple of solutions to this problem for x values with even spacing: 1) Calculating the area under a curve given a set of coordinates, without knowing the function 2) Using scipy to perform discrete integration of the sample But neither of these works when the x values are not evenly spaced. For example: >>> from scipy.integrate import simps >>> y = np.array(

信息检索(IR)的评价指标介绍

扶醉桌前 提交于 2019-12-09 12:52:32
准确率、召回率、F1 信息检索、分类、识别、翻译等领域两个最基本指标是召回率(Recall Rate)和准确率(Precision Rate),召回率也叫查全率,准确率也叫查准率,概念公式: 召回率(Recall) = 系统检索到的相关文件 / 系统所有相关的文件总数 准确率(Precision) = 系统检索到的相关文件 / 系统所有检索到的文件总数 图示表示如下: 注意:准确率和召回率是互相影响的,理想情况下肯定是做到两者都高,但是一般情况下准确率高、召回率就低,召回率低、准确率高,当然如果两者都低,那是什么地方出问题了。一般情况,用不同的阀值,统计出一组不同阀值下的精确率和召回率,如下图: 如果是做搜索,那就是保证召回的情况下提升准确率;如果做疾病监测、反垃圾,则是保准确率的条件下,提升召回。 所以,在两者都要求高的情况下,可以用F1来衡量。 F1 = 2 * P * R / (P + R) 公式基本上就是这样,但是如何算图1中的A、B、C、D呢?这需要人工标注,人工标注数据需要较多时间且枯燥,如果仅仅是做实验可以用用现成的语料。当然,还有一个办法,找个一个比较成熟的算法作为基准,用该算法的结果作为样本来进行比照,这个方法也有点问题,如果有现成的很好的算法,就不用再研究了。 AP和mAP(mean Average Precision) mAP是为解决P,R,F

Scikit learn GridSearchCV AUC performance

巧了我就是萌 提交于 2019-12-08 05:15:56
问题 I'm using GridSearchCV to identify the best set of parameters for a random forest classifier. PARAMS = { 'max_depth': [8,None], 'n_estimators': [500,1000] } rf = RandomForestClassifier() clf = grid_search.GridSearchCV(estimator=rf, param_grid=PARAMS, scoring='roc_auc', cv=5, n_jobs=4) clf.fit(data, labels) where data and labels are respectively the full dataset and the corresponding labels. Now, I compared the performance returned by the GridSearchCV (from clf.grid_scores_ ) with a "manual"

Plotting a linear discriminant analysis, classification tree and Naive Bayes Curve on a single ROC plot

女生的网名这么多〃 提交于 2019-12-08 04:55:09
问题 The data is present at the very bottom of the page and is called LDA.scores'. This is a classification task where I performed three supervised machine learning classification techniques on the data-set. All coding is supplied to show how these ROC curves were produced. I apologise for asking a loaded question but I have been trying to solve these issues using different combinations of code for almost two weeks, so if anyone can help me, then thank you. The main issue is the Naive Bayes curve

How can I tell h2o deep learning grid to have AUC instead of residual deviance

纵然是瞬间 提交于 2019-12-07 17:15:41
问题 I would like to measure models performance by looking for AUC or Accuracy. In the grid search I get results with residual deviance ,how can I tell h2o deep learning grid to have AUC instead of residual deviance and present the results as atable like the one attached below ? train <- read.table(text = "target birds wolfs snakes 0 9 7 a 0 8 4 b 1 2 8 c 1 2 3 a 1 8 3 a 0 1 2 a 0 7 1 b 0 1 5 c 1 9 7 c 1 8 7 c 0 2 7 b 1 2 3 b 1 6 3 c 0 1 1 a 0 3 9 a 1 1 1 b ",header = TRUE) trainHex <- as.h2o

AUC及TensorFlow AUC计算相关

倖福魔咒の 提交于 2019-12-07 14:45:16
最近在打天池的比赛,里面需要用AUC来评测模型的性能,所以这里介绍一下AUC的相关概念,并介绍TensorFlow含有的函数来计算AUC。 先介绍一些前置的概念。在一个二分类问题中,如果本身是正例(positive),预测正确也预测成正例,则称为真正例(true positive),简称TP,而预测错误预测成了反例,则称为假反例(false negative),简称FN,如果本身是反例(negative),预测正确也预测成反例,则称为真反例(true negative),简称TN,而预测错误预测成了正例,则称为假正例(false positive),简称FP。查准率、查全率以及F1值都是根据上述四个值计算出来的,这里不做赘述。 真正例率(True Positive Rate,简称TPR),计算公式为TPR = TP / (TP + FN),和查全率的公式一致,表示预测为正例且本身是正例的样本数占所有本身是正例的样本数的比重。假正例率(False Positive Rate,简称FPR),计算公式为FPR = FP / (TN + FP),表示预测为正例且本身是反例的样本数占所有本身是反例的样本数的比重。 ROC全称是受访者工作特征(Receiver Operating Characteristic)曲线,用来研究一般情况下模型的泛化性能。先根据模型的预测结果将样本进行排序

How to compute AUC with ROCR package

喜夏-厌秋 提交于 2019-12-06 22:27:41
问题 I have fitted a SVM model and created the ROC curve with ROCR package. How can I compute the Area Under the Curve (AUC)? set.seed(1) tune.out=tune(svm ,Negative~.-Positive, data=trainSparse, kernel ="radial",ranges=list(cost=c(0.1,1,10,100,1000),gamma=c(0.5,1,2,3,4) )) summary(tune.out) best=tune.out$best.model ##prediction on the test set ypred = predict(best,testSparse, type = "class") table(testSparse$Negative,ypred) ###Roc curve yhat.opt = predict(best,testSparse,decision.values = TRUE)