You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

confusion_matrix.ipynb 2.8 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# 混淆矩阵(confusion matrix)\n",
  8. "\n",
  9. "混淆矩阵是用来总结一个分类器结果的矩阵。对于k元分类,其实它就是一个$k \\times k$的表格,用来记录分类器的预测结果。\n",
  10. "\n",
  11. "对于最常见的二元分类来说,它的混淆矩阵是2乘2的,如下\n",
  12. "![confusion_matrix1](images/confusion_matrix1.png)\n",
  13. "\n",
  14. "* `TP` = True Postive = 真阳性\n",
  15. "* `FP` = False Positive = 假阳性\n",
  16. "* `FN` = False Negative = 假阴性\n",
  17. "* `TN` = True Negative = 真阴性\n",
  18. "\n",
  19. "你要的例子来了。。。比如我们一个模型对15个样本进行预测,然后结果如下。\n",
  20. "\n",
  21. "* 预测值:1 1 1 1 1 0 0 0 0 0 1 1 1 0 1\n",
  22. "* 真实值:0 1 1 0 1 1 0 0 1 0 1 0 1 0 0\n",
  23. "\n",
  24. "![confusion_matrix2](images/confusion_matrix2.png)\n",
  25. "\n",
  26. "\n",
  27. "这个就是混淆矩阵。混淆矩阵中的这四个数值,经常被用来定义其他一些度量。\n",
  28. "\n",
  29. "\n",
  30. "### 准确度\n",
  31. "```\n",
  32. "Accuracy = (TP+TN) / (TP+TN+FN+TN)\n",
  33. "```\n",
  34. "\n",
  35. "在上面的例子中,准确度 = (5+4) / 15 = 0.6\n",
  36. "\n",
  37. "\n",
  38. "\n",
  39. "### 精度(precision, 或者PPV, positive predictive value) \n",
  40. "```\n",
  41. "precision = TP / (TP + FP)\n",
  42. "```\n",
  43. "在上面的例子中,精度 = 5 / (5+4) = 0.556\n",
  44. "\n",
  45. "\n",
  46. "\n",
  47. "### 召回(recall, 或者敏感度,sensitivity,真阳性率,TPR,True Positive Rate) \n",
  48. "\n",
  49. "```\n",
  50. "recall = TP / (TP + FN)\n",
  51. "```\n",
  52. "\n",
  53. "在上面的例子中,召回 = 5 / (5+2) = 0.714\n",
  54. "\n",
  55. "\n",
  56. "\n",
  57. "### 特异度(specificity,或者真阴性率,TNR,True Negative Rate)\n",
  58. "```\n",
  59. "specificity = TN / (TN + FP)\n",
  60. "```\n",
  61. "\n",
  62. "在上面的例子中,特异度 = 4 / (4+2) = 0.667\n",
  63. "\n",
  64. "\n",
  65. "\n",
  66. "### F1-值(F1-score) \n",
  67. "```\n",
  68. "F1 = 2*TP / (2*TP+FP+FN) \n",
  69. "```\n",
  70. "在上面的例子中,F1-值 = 2*5 / (2*5+4+2) = 0.625\n",
  71. "\n",
  72. "\n"
  73. ]
  74. }
  75. ],
  76. "metadata": {
  77. "kernelspec": {
  78. "display_name": "Python 3",
  79. "language": "python",
  80. "name": "python3"
  81. },
  82. "language_info": {
  83. "codemirror_mode": {
  84. "name": "ipython",
  85. "version": 3
  86. },
  87. "file_extension": ".py",
  88. "mimetype": "text/x-python",
  89. "name": "python",
  90. "nbconvert_exporter": "python",
  91. "pygments_lexer": "ipython3",
  92. "version": "3.5.2"
  93. },
  94. "main_language": "python"
  95. },
  96. "nbformat": 4,
  97. "nbformat_minor": 2
  98. }

机器学习越来越多应用到飞行器、机器人等领域,其目的是利用计算机实现类似人类的智能,从而实现装备的智能化与无人化。本课程旨在引导学生掌握机器学习的基本知识、典型方法与技术,通过具体的应用案例激发学生对该学科的兴趣,鼓励学生能够从人工智能的角度来分析、解决飞行器、机器人所面临的问题和挑战。本课程主要内容包括Python编程基础,机器学习模型,无监督学习、监督学习、深度学习基础知识与实现,并学习如何利用机器学习解决实际问题,从而全面提升自我的《综合能力》。