You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
667 lines
30 KiB
667 lines
30 KiB
6 years ago
|
|
||
|
<!DOCTYPE HTML>
|
||
|
<html lang="" >
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||
|
<title>聚类性能评估指标 · GitBook</title>
|
||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||
|
<meta name="description" content="">
|
||
|
<meta name="generator" content="GitBook 3.2.3">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="stylesheet" href="gitbook/style.css">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-highlight/website.css">
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-search/search.css">
|
||
|
|
||
|
|
||
|
|
||
|
<link rel="stylesheet" href="gitbook/gitbook-plugin-fontsettings/website.css">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<meta name="HandheldFriendly" content="true"/>
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
|
||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
||
|
<link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
|
||
|
<link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
|
||
|
|
||
|
|
||
|
<link rel="next" href="sklearn.html" />
|
||
|
|
||
|
|
||
|
<link rel="prev" href="regression_metrics.html" />
|
||
|
|
||
|
|
||
|
</head>
|
||
|
<body>
|
||
|
|
||
|
<div class="book">
|
||
|
<div class="book-summary">
|
||
|
|
||
|
|
||
|
<div id="book-search-input" role="search">
|
||
|
<input type="text" placeholder="Type to search" />
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<nav role="navigation">
|
||
|
|
||
|
|
||
|
|
||
|
<ul class="summary">
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<li class="chapter " data-level="1.1" data-path="./">
|
||
|
|
||
|
<a href="./">
|
||
|
|
||
|
|
||
|
简介
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.2" data-path="machine_learning.html">
|
||
|
|
||
|
<a href="machine_learning.html">
|
||
|
|
||
|
|
||
|
机器学习概述
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3" data-path="algorithm.html">
|
||
|
|
||
|
<a href="algorithm.html">
|
||
|
|
||
|
|
||
|
常见机器学习算法
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
<ul class="articles">
|
||
|
|
||
|
|
||
|
<li class="chapter " data-level="1.3.1" data-path="kNN.html">
|
||
|
|
||
|
<a href="kNN.html">
|
||
|
|
||
|
|
||
|
近朱者赤近墨者黑-kNN
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.2" data-path="linear_regression.html">
|
||
|
|
||
|
<a href="linear_regression.html">
|
||
|
|
||
|
|
||
|
最简单的回归算法-线性回归
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.3" data-path="logistic_regression.html">
|
||
|
|
||
|
<a href="logistic_regression.html">
|
||
|
|
||
|
|
||
|
使用回归的思想进行分类-逻辑回归
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.4" data-path="decision_tree.html">
|
||
|
|
||
|
<a href="decision_tree.html">
|
||
|
|
||
|
|
||
|
最接近人类思维的算法-决策树
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.5" data-path="random_forest.html">
|
||
|
|
||
|
<a href="random_forest.html">
|
||
|
|
||
|
|
||
|
群众的力量是伟大的-随机森林
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.6" data-path="kMeans.html">
|
||
|
|
||
|
<a href="kMeans.html">
|
||
|
|
||
|
|
||
|
物以类聚人以群分-kMeans
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.3.7" data-path="AGNES.html">
|
||
|
|
||
|
<a href="AGNES.html">
|
||
|
|
||
|
|
||
|
以距离为尺-AGNES
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.4" data-path="metrics.html">
|
||
|
|
||
|
<a href="metrics.html">
|
||
|
|
||
|
|
||
|
模型评估指标
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
<ul class="articles">
|
||
|
|
||
|
|
||
|
<li class="chapter " data-level="1.4.1" data-path="classification_metrics.html">
|
||
|
|
||
|
<a href="classification_metrics.html">
|
||
|
|
||
|
|
||
|
分类性能评估指标
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.4.2" data-path="regression_metrics.html">
|
||
|
|
||
|
<a href="regression_metrics.html">
|
||
|
|
||
|
|
||
|
回归性能评估指标
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter active" data-level="1.4.3" data-path="cluster_metrics.html">
|
||
|
|
||
|
<a href="cluster_metrics.html">
|
||
|
|
||
|
|
||
|
聚类性能评估指标
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
</ul>
|
||
|
|
||
|
</li>
|
||
|
|
||
|
<li class="chapter " data-level="1.5" data-path="sklearn.html">
|
||
|
|
||
|
<a href="sklearn.html">
|
||
|
|
||
|
|
||
|
使用sklearn进行机器学习
|
||
|
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</li>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<li class="divider"></li>
|
||
|
|
||
|
<li>
|
||
|
<a href="https://www.gitbook.com" target="blank" class="gitbook-link">
|
||
|
Published with GitBook
|
||
|
</a>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
|
||
|
</nav>
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="book-body">
|
||
|
|
||
|
<div class="body-inner">
|
||
|
|
||
|
|
||
|
|
||
|
<div class="book-header" role="navigation">
|
||
|
|
||
|
|
||
|
<!-- Title -->
|
||
|
<h1>
|
||
|
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||
|
<a href="." >聚类性能评估指标</a>
|
||
|
</h1>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<div class="page-wrapper" tabindex="-1" role="main">
|
||
|
<div class="page-inner">
|
||
|
|
||
|
<div id="book-search-results">
|
||
|
<div class="search-noresults">
|
||
|
|
||
|
<section class="normal markdown-section">
|
||
|
|
||
|
<h1 id="聚类模型性能评估指标">聚类模型性能评估指标</h1>
|
||
|
<p>聚类的性能度量大致分为两类:一类是将聚类结果与某个参考模型作为参照进行比较,也就是所谓的<strong>外部指标</strong>;另一类是则是直接度量聚类的性能而不使用参考模型进行比较,也就是<strong>内部指标</strong>。</p>
|
||
|
<h2 id="外部指标">外部指标</h2>
|
||
|
<p><strong>外部指标通常使用 Jaccard Coefficient(JC系数)、Fowlkes and Mallows Index(FM指数)以及 Rand index(Rand指数)。</strong></p>
|
||
|
<p>想要计算上述指标来度量聚类的性能,首先需要计算出<script type="math/tex; ">a</script>,<script type="math/tex; ">c</script>,<script type="math/tex; ">d</script>,<script type="math/tex; ">e</script>。假设数据集<script type="math/tex; ">E=\{x_1,x_2,...,x_m\}</script>。通过聚类模型给出的簇划分为<script type="math/tex; ">C=\{C_1,C_2,...C_k\}</script>,参考模型给出的簇划分为<script type="math/tex; ">D=\{D_1,D_2,...D_s\}</script>。<script type="math/tex; ">\lambda</script>与<script type="math/tex; ">\lambda^*</script>分别表示<script type="math/tex; ">C</script>与<script type="math/tex; ">D</script>对应的簇标记,则有:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
a=|\{(x_i, x_j)|\lambda_i=\lambda_j, \lambda^*_i=\lambda^*_j,i < j\}|
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
b=|\{(x_i, x_j)|\lambda_i=\lambda_j, \lambda^*_i\neq\lambda^*_j, i < j\}|
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
c=|\{(x_i, x_j)|\lambda_i\neq\lambda_j, \lambda^*_i=\lambda^*_j, i < j\}|
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
d=|\{(x_i, x_j)|\lambda_i\neq\lambda_j, \lambda^*_i\neq\lambda^*_j, i < j\}|
|
||
|
</script></p>
|
||
|
<p>举个例子,参考模型给出的簇与聚类模型给出的簇划分如下:</p>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>编号</th>
|
||
|
<th>参考簇</th>
|
||
|
<th>聚类簇</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>1</td>
|
||
|
<td>0</td>
|
||
|
<td>0</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2</td>
|
||
|
<td>0</td>
|
||
|
<td>0</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3</td>
|
||
|
<td>0</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4</td>
|
||
|
<td>1</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>5</td>
|
||
|
<td>1</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>6</td>
|
||
|
<td>1</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<p>那么满足<script type="math/tex; ">a</script>的样本对为<script type="math/tex; ">(1, 2)</script>(<strong>因为<script type="math/tex; ">1</script>号样本与<script type="math/tex; ">2</script>号样本的参考簇都为<script type="math/tex; ">0</script>,聚类簇都为<script type="math/tex; ">0</script></strong>),<script type="math/tex; ">(5, 6)</script>(<strong>因为<script type="math/tex; ">5</script>号样本与<script type="math/tex; ">6</script>号样本的参考簇都为<script type="math/tex; ">1</script>,聚类簇都为<script type="math/tex; ">2</script></strong>)。总共有<script type="math/tex; ">2</script>个样本对满足<script type="math/tex; ">a</script>,因此<script type="math/tex; ">a=2</script>。</p>
|
||
|
<p>满足<script type="math/tex; ">b</script>的样本对为<script type="math/tex; ">(3, 4)</script>(<strong>因为<script type="math/tex; ">3</script>号样本与<script type="math/tex; ">4</script>号样本的参考簇不同,但聚类簇都为<script type="math/tex; ">1</script></strong>)。总共有<script type="math/tex; ">1</script>个样本对满足<script type="math/tex; ">b</script>,因此<script type="math/tex; ">b=1</script>。</p>
|
||
|
<p>那么满足<script type="math/tex; ">c</script>的样本对为<script type="math/tex; ">(1, 3)</script>(<strong>因为<script type="math/tex; ">1</script>号样本与<script type="math/tex; ">3</script>号样本的聚类簇不同,但参考簇都为<script type="math/tex; ">0</script></strong>),<script type="math/tex; ">(2, 3)</script>(<strong>因为<script type="math/tex; ">2</script>号样本与<script type="math/tex; ">3</script>号样本的聚类簇不同,但参考簇都为<script type="math/tex; ">0</script></strong>),<script type="math/tex; ">(4, 5)</script>(<strong>因为<script type="math/tex; ">4</script>号样本与<script type="math/tex; ">5</script>号样本的聚类簇不同,但参考簇都为<script type="math/tex; ">1</script></strong>),<script type="math/tex; ">(4, 6)</script>(<strong>因为<script type="math/tex; ">4</script>号样本与<script type="math/tex; ">6</script>号样本的聚类簇不同,但参考簇都为<script type="math/tex; ">1</script></strong>)。总共有<script type="math/tex; ">4</script>个样本对满足<script type="math/tex; ">c</script>,因此<script type="math/tex; ">c=4</script>。</p>
|
||
|
<p>满足<script type="math/tex; ">d</script>的样本对为<script type="math/tex; ">(1, 4)</script>(<strong>因为<script type="math/tex; ">1</script>号样本与<script type="math/tex; ">4</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(1, 5)</script>(<strong>因为<script type="math/tex; ">1</script>号样本与<script type="math/tex; ">5</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(1, 6)</script>(<strong>因为<script type="math/tex; ">1</script>号样本与<script type="math/tex; ">6</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(2, 4)</script>(<strong>因为<script type="math/tex; ">2</script>号样本与<script type="math/tex; ">4</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(2, 5)</script>(<strong>因为<script type="math/tex; ">2</script>号样本与<script type="math/tex; ">5</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(2, 6)</script>(<strong>因为<script type="math/tex; ">2</script>号样本与<script type="math/tex; ">6</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(3, 5)</script>(<strong>因为<script type="math/tex; ">3</script>号样本与<script type="math/tex; ">5</script>号样本的参考簇不同,聚类簇也不同</strong>),<script type="math/tex; ">(3, 6)</script>(<strong>因为<script type="math/tex; ">3</script>号样本与<script type="math/tex; ">6</script>号样本的参考簇不同,聚类簇也不同</strong>)。总共有<script type="math/tex; ">8</script>个样本对满足<script type="math/tex; ">d</script>,因此<script type="math/tex; ">d=8</script>。</p>
|
||
|
<h3 id="jc系数">JC系数</h3>
|
||
|
<p><strong>JC系数</strong>根据上面所提到的<script type="math/tex; ">a</script>,<script type="math/tex; ">b</script>,<script type="math/tex; ">c</script>来计算,并且值域为<script type="math/tex; ">[0, 1]</script>,值越大说明聚类性能越好,公式如下:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
JC=\frac{a}{a+b+c}
|
||
|
</script></p>
|
||
|
<p>因此刚刚的例子中,<script type="math/tex; ">JC=\frac{2}{2+1+4}=\frac{2}{7}</script></p>
|
||
|
<h3 id="fm指数">FM指数</h3>
|
||
|
<p><strong>FM指数</strong>根据上面所提到的<script type="math/tex; ">a</script>,<script type="math/tex; ">b</script>,<script type="math/tex; ">c</script>来计算,并且值域为<script type="math/tex; ">[0, 1]</script>,值越大说明聚类性能越好,公式如下:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
FMI=\sqrt{\frac{a}{a+b}*\frac{a}{a+c}}
|
||
|
</script></p>
|
||
|
<p>因此刚刚的例子中,<script type="math/tex; ">FMI=\sqrt{\frac{2}{2+1}*\frac{2}{2+4}}=\sqrt{\frac{4}{18}}</script></p>
|
||
|
<h3 id="rand指数">Rand指数</h3>
|
||
|
<p><strong>Rand指数</strong>根据上面所提到的<script type="math/tex; ">a</script>和<script type="math/tex; ">d</script>来计算,并且值域为<script type="math/tex; ">[0, 1]</script>,值越大说明聚类性能越好,假设<script type="math/tex; ">m</script>为样本数量,公式如下:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
RandI=\frac{2(a+d)}{m(m-1)}
|
||
|
</script></p>
|
||
|
<p>因此刚刚的例子中,<script type="math/tex; ">RandI=\frac{2*(2+8)}{6*(6-1)}=\frac{2}{3}</script>。</p>
|
||
|
<h2 id="内部指标">内部指标</h2>
|
||
|
<p><strong>内部指标通常使用 Davies-Bouldin Index (DB指数)以及 Dunn Index(Dunn指数)。</strong></p>
|
||
|
<h5 id="db指数">DB指数</h5>
|
||
|
<p><strong>DB指数</strong>又称 DBI ,计算公式如下:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
DBI=\frac{1}{k}\sum_{i=1}^kmax(\frac{avg(C_i)+avg(C_j)}{d_c(\mu_i,\mu_j)}), i \neq j
|
||
|
</script></p>
|
||
|
<p>公式中的表达式其实很好理解,其中<script type="math/tex; ">k</script>代表聚类有多少个簇,<script type="math/tex; ">\mu_i</script>代表第<script type="math/tex; ">i</script>个簇的中心点,<script type="math/tex; ">avg(C_i)</script>代表<script type="math/tex; ">C_i</script>第<script type="math/tex; ">i</script>个簇中所有数据与第<script type="math/tex; ">i</script>个簇的中心点的平均距离。<script type="math/tex; ">d_c(\mu_i, \mu_j)</script>代表第<script type="math/tex; ">i</script>个簇的中心点与第<script type="math/tex; ">j</script>个簇的中心点的距离。</p>
|
||
|
<p>举个例子,现在有<script type="math/tex; ">6</script>条西瓜数据<script type="math/tex; ">\{x_1,x_2,...,x_6\}</script>,这些数据已经聚类成了<script type="math/tex; ">2</script>个簇。</p>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>编号</th>
|
||
|
<th>体积</th>
|
||
|
<th>重量</th>
|
||
|
<th>簇</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>1</td>
|
||
|
<td>3</td>
|
||
|
<td>4</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2</td>
|
||
|
<td>6</td>
|
||
|
<td>9</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3</td>
|
||
|
<td>2</td>
|
||
|
<td>3</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4</td>
|
||
|
<td>3</td>
|
||
|
<td>4</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>5</td>
|
||
|
<td>7</td>
|
||
|
<td>10</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>6</td>
|
||
|
<td>8</td>
|
||
|
<td>11</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<p>从表格可以看出:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
k=2
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
\mu_1=(\frac{(3+2+3)}{3}, \frac{(4+3+4)}{3})=(2.67,3.67)
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
\mu_2=(\frac{(6+7+8)}{3}, \frac{(9+10+11)}{3})=(7,10)
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
d_c(\mu_1, \mu_2)=\sqrt{(2.67-7)^2+(3.67-10)^2}=7.67391
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
avg(C_1)=(\sqrt{(3-2.67)^2+(4-3.67)^2}+\sqrt{(2-2.67)^2+(3-3.67)^2}+\sqrt{(3-2.67)^2+(4-3.67)^2})/3=0.628539
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
avg(C_2)=(\sqrt{(6-7)^2+(9-10)^2}+\sqrt{(7-7)^2+(10-10)^2}+\sqrt{(8-7)^2+(11-10)^2})/3=0.94281
|
||
|
</script></p>
|
||
|
<p>因此有:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
DBI=\frac{1}{k}\sum_{i=1}^kmax(\frac{avg(C_i)+avg(C_j)}{d_c(\mu_i,\mu_j)})=0.204765
|
||
|
</script></p>
|
||
|
<p><strong>DB指数越小就越就意味着簇内距离越小同时簇间距离越大,也就是说DB指数越小越好。</strong></p>
|
||
|
<h3 id="dunn指数">Dunn指数</h3>
|
||
|
<p><strong>Dunn指数</strong>又称DI,计算公式如下:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
DI=min_{1\leq i\leq k}\{min_{i\neq j}(\frac{d_min(C_i,C_j)}{max_{1\leq l\leq k}diam(C_l)})\}
|
||
|
</script></p>
|
||
|
<p>公式中的表达式其实很好理解,其中<script type="math/tex; ">k</script>代表聚类有多少个簇,<script type="math/tex; ">d_{min}(C_i,C_j)</script>代表第<script type="math/tex; ">i</script>个簇中的样本与第<script type="math/tex; ">j</script>个簇中的样本之间的最短距离,<script type="math/tex; ">diam(C_l)</script>代表第<script type="math/tex; ">l</script>个簇中相距最远的样本之间的距离。</p>
|
||
|
<p>还是这个例子,现在有 6 条西瓜数据<script type="math/tex; ">\{x_1,x_2,...,x_6\}</script>,这些数据已经聚类成了 2 个簇。</p>
|
||
|
<table>
|
||
|
<thead>
|
||
|
<tr>
|
||
|
<th>编号</th>
|
||
|
<th>体积</th>
|
||
|
<th>重量</th>
|
||
|
<th>簇</th>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody>
|
||
|
<tr>
|
||
|
<td>1</td>
|
||
|
<td>3</td>
|
||
|
<td>4</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>2</td>
|
||
|
<td>6</td>
|
||
|
<td>9</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>3</td>
|
||
|
<td>2</td>
|
||
|
<td>3</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>4</td>
|
||
|
<td>3</td>
|
||
|
<td>4</td>
|
||
|
<td>1</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>5</td>
|
||
|
<td>7</td>
|
||
|
<td>10</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td>6</td>
|
||
|
<td>8</td>
|
||
|
<td>11</td>
|
||
|
<td>2</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<p>从表格可以看出:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
k=2
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
d_{min}(C_1,C_2)=\sqrt{(3-6)^2+(4-9)^2}=5.831
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
diam(C_1)=\sqrt{(3-2)^2+(4-2)^2}=1.414
|
||
|
</script></p>
|
||
|
<p><script type="math/tex; ">
|
||
|
diam(C_2)=\sqrt{(6-8)^2+(9-11)^2}=2.828
|
||
|
</script></p>
|
||
|
<p>因此有:</p>
|
||
|
<p><script type="math/tex; ">
|
||
|
DI=min_{1\leq i\leq k}\{min_{i\neq j}(\frac{d_min(C_i,C_j)}{max_{1\leq l\leq k}diam(C_l)})\}=2.061553
|
||
|
</script></p>
|
||
|
<p><strong>Dunn指数越大意味着簇内距离越小同时簇间距离越大,也就是说Dunn指数越大越好。</strong></p>
|
||
|
|
||
|
|
||
|
</section>
|
||
|
|
||
|
</div>
|
||
|
<div class="search-results">
|
||
|
<div class="has-results">
|
||
|
|
||
|
<h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
|
||
|
<ul class="search-results-list"></ul>
|
||
|
|
||
|
</div>
|
||
|
<div class="no-results">
|
||
|
|
||
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
|
||
|
<a href="regression_metrics.html" class="navigation navigation-prev " aria-label="Previous page: 回归性能评估指标">
|
||
|
<i class="fa fa-angle-left"></i>
|
||
|
</a>
|
||
|
|
||
|
|
||
|
<a href="sklearn.html" class="navigation navigation-next " aria-label="Next page: 使用sklearn进行机器学习">
|
||
|
<i class="fa fa-angle-right"></i>
|
||
|
</a>
|
||
|
|
||
|
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<script>
|
||
|
var gitbook = gitbook || [];
|
||
|
gitbook.push(function() {
|
||
|
gitbook.page.hasChanged({"page":{"title":"聚类性能评估指标","level":"1.4.3","depth":2,"next":{"title":"使用sklearn进行机器学习","level":"1.5","depth":1,"path":"sklearn.md","ref":"sklearn.md","articles":[]},"previous":{"title":"回归性能评估指标","level":"1.4.2","depth":2,"path":"regression_metrics.md","ref":"regression_metrics.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["mathjax"],"pluginsConfig":{"mathjax":{"forceSVG":false,"version":"2.6-latest"},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"cluster_metrics.md","mtime":"2019-07-04T07:52:21.990Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-05T01:10:51.626Z"},"basePath":".","book":{"language":""}});
|
||
|
});
|
||
|
</script>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook.js"></script>
|
||
|
<script src="gitbook/theme.js"></script>
|
||
|
|
||
|
|
||
|
<script src="https://cdn.mathjax.org/mathjax/2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-mathjax/plugin.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-search/search-engine.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-search/search.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-sharing/buttons.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
<script src="gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
|
||
|
|
||
|
|
||
|
|
||
|
</body>
|
||
|
</html>
|
||
|
|