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.

684 lines
46 KiB

<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>以距离为尺-AGNES · 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-katex/katex.min.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="metrics.html" />
<link rel="prev" href="kMeans.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 active" 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 " 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="chapter " data-level="1.6" >
<span>
综合实战案例
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.1" >
<span>
泰坦尼克生还预测
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.1.1" data-path="titanic/introduction.html">
<a href="titanic/introduction.html">
简介
</a>
</li>
<li class="chapter " data-level="1.6.1.2" data-path="titanic/EDA.html">
<a href="titanic/EDA.html">
探索性数据分析(EDA)
</a>
</li>
<li class="chapter " data-level="1.6.1.3" data-path="titanic/feature engerning.html">
<a href="titanic/feature engerning.html">
特征工程
</a>
</li>
<li class="chapter " data-level="1.6.1.4" data-path="titanic/fit and predict.html">
<a href="titanic/fit and predict.html">
构建模型进行预测
</a>
</li>
<li class="chapter " data-level="1.6.1.5" data-path="titanic/tuning.html">
<a href="titanic/tuning.html">
调参
</a>
</li>
</ul>
</li>
<li class="chapter " data-level="1.6.2" >
<span>
使用强化学习玩乒乓球游戏
</span>
<ul class="articles">
<li class="chapter " data-level="1.6.2.1" data-path="pingpong/what is reinforce learning.html">
<a href="pingpong/what is reinforce learning.html">
什么是强化学习
</a>
</li>
<li class="chapter " data-level="1.6.2.2" data-path="pingpong/Policy Gradient.html">
<a href="pingpong/Policy Gradient.html">
Policy Gradient原理
</a>
</li>
<li class="chapter " data-level="1.6.2.3" data-path="pingpong/coding.html">
<a href="pingpong/coding.html">
使用Policy Gradient玩乒乓球游戏
</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="chapter " data-level="1.7" data-path="recommand.html">
<a href="recommand.html">
实训推荐
</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="." >以距离为尺-AGNES</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="&#x4EE5;&#x8DDD;&#x79BB;&#x4E3A;&#x5C3A;-agnes&#x7B97;&#x6CD5;">&#x4EE5;&#x8DDD;&#x79BB;&#x4E3A;&#x5C3A;-AGNES&#x7B97;&#x6CD5;</h1>
<p>AGNES &#x7B97;&#x6CD5;&#x662F;&#x4E00;&#x79CD;&#x805A;&#x7C7B;&#x7B97;&#x6CD5;&#xFF0C;&#x6700;&#x521D;&#x5C06;&#x6BCF;&#x4E2A;&#x5BF9;&#x8C61;&#x4F5C;&#x4E3A;&#x4E00;&#x4E2A;&#x7C07;&#xFF0C;&#x7136;&#x540E;&#x8FD9;&#x4E9B;&#x7C07;&#x6839;&#x636E;&#x67D0;&#x4E9B;&#x8DDD;&#x79BB;&#x51C6;&#x5219;&#x88AB;&#x4E00;&#x6B65;&#x6B65;&#x5730;&#x5408;&#x5E76;&#x3002;&#x4E24;&#x4E2A;&#x7C07;&#x95F4;&#x7684;&#x76F8;&#x4F3C;&#x5EA6;&#x6709;&#x591A;&#x79CD;&#x4E0D;&#x540C;&#x7684;&#x8BA1;&#x7B97;&#x65B9;&#x6CD5;&#x3002;&#x805A;&#x7C7B;&#x7684;&#x5408;&#x5E76;&#x8FC7;&#x7A0B;&#x53CD;&#x590D;&#x8FDB;&#x884C;&#x76F4;&#x5230;&#x6240;&#x6709;&#x7684;&#x5BF9;&#x8C61;&#x6700;&#x7EC8;&#x6EE1;&#x8DB3;&#x7C07;&#x6570;&#x76EE;&#x3002;&#x6240;&#x4EE5;&#x7406;&#x89E3; AGNES &#x7B97;&#x6CD5;&#x524D;&#x9700;&#x8981;&#x5148;&#x7406;&#x89E3;&#x4E00;&#x4E9B;&#x8DDD;&#x79BB;&#x51C6;&#x5219;&#x3002;</p>
<h1 id="&#x8DDD;&#x79BB;&#x51C6;&#x5219;">&#x8DDD;&#x79BB;&#x51C6;&#x5219;</h1>
<h2 id="&#x4E3A;&#x4EC0;&#x4E48;&#x9700;&#x8981;&#x8DDD;&#x79BB;">&#x4E3A;&#x4EC0;&#x4E48;&#x9700;&#x8981;&#x8DDD;&#x79BB;</h2>
<p>AGNES &#x7B97;&#x6CD5;&#x662F;&#x4E00;&#x79CD;&#x81EA;&#x5E95;&#x5411;&#x4E0A;&#x805A;&#x5408;&#x7684;&#x5C42;&#x6B21;&#x805A;&#x7C7B;&#x7B97;&#x6CD5;&#xFF0C;&#x5B83;&#x5148;&#x4F1A;&#x5C06;&#x6570;&#x636E;&#x96C6;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x6837;&#x672C;&#x770B;&#x4F5C;&#x4E00;&#x4E2A;&#x521D;&#x59CB;&#x7C07;&#xFF0C;&#x7136;&#x540E;&#x5728;&#x7B97;&#x6CD5;&#x8FD0;&#x884C;&#x7684;&#x6BCF;&#x4E00;&#x6B65;&#x4E2D;&#x627E;&#x51FA;&#x8DDD;&#x79BB;&#x6700;&#x8FD1;&#x7684;&#x4E24;&#x4E2A;&#x7C07;&#x8FDB;&#x884C;&#x5408;&#x5E76;&#xFF0C;&#x76F4;&#x81F3;&#x8FBE;&#x5230;&#x9884;&#x8BBE;&#x7684;&#x7C07;&#x7684;&#x6570;&#x91CF;&#x3002;&#x6240;&#x4EE5;AGNES&#x7B97;&#x6CD5;&#x9700;&#x8981;&#x4E0D;&#x65AD;&#x7684;&#x8BA1;&#x7B97;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#xFF0C;&#x8FD9;&#x4E5F;&#x7B26;&#x5408;&#x805A;&#x7C7B;&#x7684;&#x6838;&#x5FC3;&#x601D;&#x60F3;&#xFF08;&#x7269;&#x4EE5;&#x7C7B;&#x805A;&#xFF0C;&#x4EBA;&#x4EE5;&#x7FA4;&#x5206;&#xFF09;&#xFF0C;&#x56E0;&#x6B64;&#x600E;&#x6837;&#x5EA6;&#x91CF;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#x6210;&#x4E3A;&#x4E86;&#x5173;&#x952E;&#x3002;</p>
<h2 id="&#x8DDD;&#x79BB;&#x7684;&#x8BA1;&#x7B97;">&#x8DDD;&#x79BB;&#x7684;&#x8BA1;&#x7B97;</h2>
<p>&#x8861;&#x91CF;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x8DDD;&#x79BB;&#x901A;&#x5E38;&#x5206;&#x4E3A;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x3001;&#x6700;&#x5927;&#x8DDD;&#x79BB;&#x548C;&#x5E73;&#x5747;&#x8DDD;&#x79BB;&#x3002;&#x5728; AGNES &#x7B97;&#x6CD5;&#x4E2D;&#x53EF;&#x6839;&#x636E;&#x5177;&#x4F53;&#x4E1A;&#x52A1;&#x9009;&#x62E9;&#x5176;&#x4E2D;&#x4E00;&#x79CD;&#x8DDD;&#x79BB;&#x4F5C;&#x4E3A;&#x5EA6;&#x91CF;&#x6807;&#x51C6;&#x3002;</p>
<h3 id="&#x6700;&#x5C0F;&#x8DDD;&#x79BB;">&#x6700;&#x5C0F;&#x8DDD;&#x79BB;</h3>
<p>&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x8DDD;&#x79BB;&#x6700;&#x8FD1;&#x7684;&#x4E24;&#x4E2A;&#x6837;&#x672C;&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x8DDD;&#x79BB;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x56FE;&#x4E2D;&#x5706;&#x5708;&#x548C;&#x83F1;&#x5F62;&#x5206;&#x522B;&#x4EE3;&#x8868;&#x4E24;&#x4E2A;&#x7C07;&#xFF0C;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x79BB;&#x5F97;&#x6700;&#x8FD1;&#x7684;&#x6837;&#x672C;&#x7684;<strong>&#x6B27;&#x5F0F;&#x8DDD;&#x79BB;</strong>&#x4E3A; 3.3 &#xFF0C;&#x5219;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x4E3A; 3.3&#x3002;</p>
<p><img src="img/59.jpg" alt=""></p>
<p>&#x5047;&#x8BBE;&#x7ED9;&#x5B9A;&#x7C07;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">C_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.83333em;vertical-align:-0.15em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#x4E0E;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">C_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.969438em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#xFF0C;&#x5219;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x4E3A;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>d</mi><mrow><mi>m</mi><mi>i</mi><mi>n</mi></mrow></msub><mo>=</mo><mi>m</mi><mi>i</mi><msub><mi>n</mi><mrow><mi>x</mi><mo>&#x2208;</mo><mi>i</mi><mo separator="true">,</mo><mi>z</mi><mo>&#x2208;</mo><mi>j</mi></mrow></msub><mi>d</mi><mi>i</mi><mi>s</mi><mi>t</mi><mo>(</mo><mi>x</mi><mo separator="true">,</mo><mi>z</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">d_{min}=min_{x\in i,z\in j}dist(x,z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.036108em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">d</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">m</span><span class="mord mathit mtight">i</span><span class="mord mathit mtight">n</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">=</span><span class="mord mathit">m</span><span class="mord mathit">i</span><span class="mord"><span class="mord mathit">n</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">x</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight">i</span><span class="mpunct mtight">,</span><span class="mord mathit mtight" style="margin-right:0.04398em;">z</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathit">d</span><span class="mord mathit">i</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mopen">(</span><span class="mord mathit">x</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span></p>
<h3 id="&#x6700;&#x5927;&#x8DDD;&#x79BB;">&#x6700;&#x5927;&#x8DDD;&#x79BB;</h3>
<p>&#x6700;&#x5927;&#x8DDD;&#x79BB;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x8DDD;&#x79BB;&#x6700;&#x8FDC;&#x7684;&#x4E24;&#x4E2A;&#x6837;&#x672C;&#x6240;&#x5BF9;&#x5E94;&#x7684;&#x8DDD;&#x79BB;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x56FE;&#x4E2D;&#x5706;&#x5708;&#x548C;&#x83F1;&#x5F62;&#x5206;&#x522B;&#x4EE3;&#x8868;&#x4E24;&#x4E2A;&#x7C07;&#xFF0C;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x79BB;&#x5F97;&#x6700;&#x8FDC;&#x7684;&#x6837;&#x672C;&#x7684;<strong>&#x6B27;&#x5F0F;&#x8DDD;&#x79BB;</strong>&#x4E3A; 23.3 &#xFF0C;&#x5219;&#x6700;&#x5927;&#x8DDD;&#x79BB;&#x4E3A; 23.3 &#x3002;</p>
<p><img src="img/60.jpg" alt=""></p>
<p>&#x5047;&#x8BBE;&#x7ED9;&#x5B9A;&#x7C07;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">C_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.83333em;vertical-align:-0.15em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#x4E0E;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">C_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.969438em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#xFF0C;&#x5219;&#x6700;&#x5927;&#x8DDD;&#x79BB;&#x4E3A;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>d</mi><mrow><mi>m</mi><mi>i</mi><mi>n</mi></mrow></msub><mo>=</mo><mi>m</mi><mi>a</mi><msub><mi>x</mi><mrow><mi>x</mi><mo>&#x2208;</mo><mi>i</mi><mo separator="true">,</mo><mi>z</mi><mo>&#x2208;</mo><mi>j</mi></mrow></msub><mi>d</mi><mi>i</mi><mi>s</mi><mi>t</mi><mo>(</mo><mi>x</mi><mo separator="true">,</mo><mi>z</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">d_{min}=max_{x\in i,z\in j}dist(x,z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.036108em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">d</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">m</span><span class="mord mathit mtight">i</span><span class="mord mathit mtight">n</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">=</span><span class="mord mathit">m</span><span class="mord mathit">a</span><span class="mord"><span class="mord mathit">x</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">x</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight">i</span><span class="mpunct mtight">,</span><span class="mord mathit mtight" style="margin-right:0.04398em;">z</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathit">d</span><span class="mord mathit">i</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mopen">(</span><span class="mord mathit">x</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span></p>
<h3 id="&#x5E73;&#x5747;&#x8DDD;&#x79BB;">&#x5E73;&#x5747;&#x8DDD;&#x79BB;</h3>
<p>&#x5E73;&#x5747;&#x8DDD;&#x79BB;&#x63CF;&#x8FF0;&#x7684;&#x662F;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x6837;&#x672C;&#x7684;&#x5E73;&#x5747;&#x8DDD;&#x79BB;&#x3002;&#x4F8B;&#x5982;&#x4E0B;&#x56FE;&#x4E2D;&#x5706;&#x5708;&#x548C;&#x83F1;&#x5F62;&#x5206;&#x522B;&#x4EE3;&#x8868;&#x4E24;&#x4E2A;&#x7C07;&#xFF0C;&#x8BA1;&#x7B97;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x6240;&#x6709;&#x6837;&#x672C;&#x4E4B;&#x95F4;&#x7684;&#x6B27;&#x5F0F;&#x8DDD;&#x79BB;&#x5E76;&#x6C42;&#x5176;&#x5E73;&#x5747;&#x503C;&#x3002;</p>
<p><img src="img/61.jpg" alt=""></p>
<p>&#x5047;&#x8BBE;&#x7ED9;&#x5B9A;&#x7C07;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>i</mi></msub></mrow><annotation encoding="application/x-tex">C_i</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.83333em;vertical-align:-0.15em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#x4E0E;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>C</mi><mi>j</mi></msub></mrow><annotation encoding="application/x-tex">C_j</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.969438em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span></span></span></span>&#xFF0C;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi mathvariant="normal">&#x2223;</mi><msub><mi>C</mi><mi>i</mi></msub><mi mathvariant="normal">&#x2223;</mi><mo separator="true">,</mo><mi mathvariant="normal">&#x2223;</mi><msub><mi>C</mi><mi>j</mi></msub><mi mathvariant="normal">&#x2223;</mi></mrow><annotation encoding="application/x-tex">|C_i|,|C_j|</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.75em;"></span><span class="strut bottom" style="height:1.036108em;vertical-align:-0.286108em;"></span><span class="base textstyle uncramped"><span class="mord mathrm">&#x2223;</span><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm">&#x2223;</span><span class="mpunct">,</span><span class="mord mathrm">&#x2223;</span><span class="mord"><span class="mord mathit" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm">&#x2223;</span></span></span></span>&#x5206;&#x522B;&#x8868;&#x793A;&#x7C07; i &#x4E0E;&#x7C07; j &#x4E2D;&#x6837;&#x672C;&#x7684;&#x6570;&#x91CF;&#xFF0C;&#x5219;&#x5E73;&#x5747;&#x8DDD;&#x79BB;&#x4E3A;&#xFF1A;<span class="katex"><span class="katex-mathml"><math><semantics><mrow><msub><mi>d</mi><mrow><mi>m</mi><mi>i</mi><mi>n</mi></mrow></msub><mo>=</mo><mfrac><mrow><mn>1</mn></mrow><mrow><mi mathvariant="normal">&#x2223;</mi><msub><mi>C</mi><mi>i</mi></msub><mi mathvariant="normal">&#x2223;</mi><mi mathvariant="normal">&#x2223;</mi><msub><mi>C</mi><mi>j</mi></msub><mi mathvariant="normal">&#x2223;</mi></mrow></mfrac><msub><mo>&#x2211;</mo><mrow><mi>x</mi><mo>&#x2208;</mo><mi>i</mi></mrow></msub><msub><mo>&#x2211;</mo><mrow><mi>z</mi><mo>&#x2208;</mo><mi>j</mi></mrow></msub><mi>d</mi><mi>i</mi><mi>s</mi><mi>t</mi><mo>(</mo><mi>x</mi><mo separator="true">,</mo><mi>z</mi><mo>)</mo></mrow><annotation encoding="application/x-tex">d_{min}=\frac{1}{|C_i||C_j|}\sum_{x\in i}\sum_{z\in j}dist(x, z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height:0.845108em;"></span><span class="strut bottom" style="height:1.3874279999999999em;vertical-align:-0.5423199999999999em;"></span><span class="base textstyle uncramped"><span class="mord"><span class="mord mathit">d</span><span class="msupsub"><span class="vlist"><span style="top:0.15em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">m</span><span class="mord mathit mtight">i</span><span class="mord mathit mtight">n</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mrel">=</span><span class="mord reset-textstyle textstyle uncramped"><span class="mopen sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span><span class="mfrac"><span class="vlist"><span style="top:0.3449999999999999em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathrm mtight">&#x2223;</span><span class="mord mtight"><span class="mord mathit mtight" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.143em;margin-right:0.07142857142857144em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-scriptstyle scriptscriptstyle cramped mtight"><span class="mord mathit mtight">i</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm mtight">&#x2223;</span><span class="mord mathrm mtight">&#x2223;</span><span class="mord mtight"><span class="mord mathit mtight" style="margin-right:0.07153em;">C</span><span class="msupsub"><span class="vlist"><span style="top:0.14300000000000002em;margin-right:0.07142857142857144em;margin-left:-0.07153em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-scriptstyle scriptscriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathrm mtight">&#x2223;</span></span></span></span><span style="top:-0.22999999999999998em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle textstyle uncramped frac-line"></span></span><span style="top:-0.394em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle uncramped mtight"><span class="mord scriptstyle uncramped mtight"><span class="mord mathrm mtight">1</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span><span class="mclose sizing reset-size5 size5 reset-textstyle textstyle uncramped nulldelimiter"></span></span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight">x</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight">i</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mop"><span class="mop op-symbol small-op" style="top:-0.0000050000000000050004em;">&#x2211;</span><span class="msupsub"><span class="vlist"><span style="top:0.30001em;margin-right:0.05em;margin-left:0em;"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span><span class="reset-textstyle scriptstyle cramped mtight"><span class="mord scriptstyle cramped mtight"><span class="mord mathit mtight" style="margin-right:0.04398em;">z</span><span class="mrel mtight">&#x2208;</span><span class="mord mathit mtight" style="margin-right:0.05724em;">j</span></span></span></span><span class="baseline-fix"><span class="fontsize-ensurer reset-size5 size5"><span style="font-size:0em;">&#x200B;</span></span>&#x200B;</span></span></span></span><span class="mord mathit">d</span><span class="mord mathit">i</span><span class="mord mathit">s</span><span class="mord mathit">t</span><span class="mopen">(</span><span class="mord mathit">x</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right:0.04398em;">z</span><span class="mclose">)</span></span></span></span></p>
<h1 id="agnes-&#x7B97;&#x6CD5;&#x6D41;&#x7A0B;">AGNES &#x7B97;&#x6CD5;&#x6D41;&#x7A0B;</h1>
<p>AGNES &#x7B97;&#x6CD5;&#x662F;&#x4E00;&#x79CD;&#x81EA;&#x5E95;&#x5411;&#x4E0A;&#x805A;&#x5408;&#x7684;&#x5C42;&#x6B21;&#x805A;&#x7C7B;&#x7B97;&#x6CD5;&#xFF0C;&#x5B83;&#x5148;&#x4F1A;&#x5C06;&#x6570;&#x636E;&#x96C6;&#x4E2D;&#x7684;&#x6BCF;&#x4E2A;&#x6837;&#x672C;&#x770B;&#x4F5C;&#x4E00;&#x4E2A;<strong>&#x521D;&#x59CB;&#x7C07;</strong>&#xFF0C;&#x7136;&#x540E;&#x5728;&#x7B97;&#x6CD5;&#x8FD0;&#x884C;&#x7684;&#x6BCF;&#x4E00;&#x6B65;&#x4E2D;&#x627E;&#x51FA;&#x8DDD;&#x79BB;&#x6700;&#x8FD1;&#x7684;&#x4E24;&#x4E2A;&#x7C07;&#x8FDB;&#x884C;&#x5408;&#x5E76;&#xFF0C;&#x76F4;&#x81F3;&#x8FBE;&#x5230;&#x9884;&#x8BBE;&#x7684;&#x7C07;&#x7684;&#x6570;&#x91CF;&#x3002;</p>
<p>&#x4E3E;&#x4E2A;&#x4F8B;&#x5B50;&#xFF0C;&#x73B0;&#x5728;&#x5148;&#x8981;&#x5C06;&#x897F;&#x74DC;&#x6570;&#x636E;&#x805A;&#x6210;&#x4E24;&#x7C7B;&#xFF0C;&#x6570;&#x636E;&#x5982;&#x4E0B;&#x8868;&#x6240;&#x793A;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>&#x7F16;&#x53F7;</th>
<th>&#x4F53;&#x79EF;</th>
<th>&#x91CD;&#x91CF;</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1.2</td>
<td>2.3</td>
</tr>
<tr>
<td>2</td>
<td>3.6</td>
<td>7.1</td>
</tr>
<tr>
<td>3</td>
<td>1.1</td>
<td>2.2</td>
</tr>
<tr>
<td>4</td>
<td>3.5</td>
<td>6.9</td>
</tr>
<tr>
<td>5</td>
<td>1.5</td>
<td>2.5</td>
</tr>
</tbody>
</table>
<p>&#x4E00;&#x5F00;&#x59CB;&#xFF0C;&#x6BCF;&#x4E2A;&#x6837;&#x672C;&#x90FD;&#x770B;&#x6210;&#x662F;&#x4E00;&#x4E2A;&#x7C07;( 1 &#x53F7;&#x6837;&#x672C;&#x770B;&#x6210;&#x662F; 1 &#x53F7;&#x7C07;&#xFF0C; 2 &#x53F7;&#x6837;&#x672C;&#x770B;&#x6210;&#x662F; 2 &#x53F7;&#x7C07;&#xFF0C;...&#xFF0C; 5 &#x53F7;&#x6837;&#x672C;&#x770B;&#x6210;&#x662F; 5 &#x53F7;&#x7C07;)&#xFF0C;&#x5047;&#x8BBE;&#x7C07;&#x7684;&#x96C6;&#x5408;&#x4E3A; C=[[1], [2], [3], [4], [5]] &#x3002;</p>
<p>&#x5047;&#x8BBE;&#x4F7F;&#x7528;&#x7C07;&#x95F4;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6765;&#x5EA6;&#x91CF;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x8FDC;&#x8FD1;&#xFF0C;&#x4ECE;&#x8868;&#x4E2D;&#x53EF;&#x4EE5;&#x770B;&#x51FA; 1 &#x53F7;&#x7C07;&#x4E0E; 3 &#x53F7;&#x7C07;&#x7684;&#x7C07;&#x95F4;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#x3002;&#x56E0;&#x6B64;&#x9700;&#x8981;&#x5C06; 1 &#x53F7;&#x7C07;&#x548C; 3 &#x53F7;&#x7C07;&#x5408;&#x5E76;&#xFF0C;&#x90A3;&#x4E48;&#x6B64;&#x65F6;&#x7C07;&#x7684;&#x96C6;&#x5408; C=[[1, 3], [2], [4], [5]]&#x3002;</p>
<p>&#x7136;&#x540E;&#x7EE7;&#x7EED;&#x770B;&#x8FD9; 4 &#x4E2A;&#x7C07;&#x4E2D;&#x54EA;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#xFF0C;&#x6211;&#x4EEC;&#x53D1;&#x73B0; 2 &#x53F7;&#x7C07;&#x4E0E; 4 &#x53F7;&#x7C07;&#x7684;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x8981;&#x8FDB;&#x884C;&#x5408;&#x5E76;&#xFF0C;&#x5408;&#x5E76;&#x4E4B;&#x540E; C=[[1, 3], [2, 4], [5]]&#x3002;</p>
<p>&#x7136;&#x540E;&#x7EE7;&#x7EED;&#x770B;&#x8FD9; 3 &#x4E2A;&#x7C07;&#x4E2D;&#x54EA;&#x4E24;&#x4E2A;&#x7C07;&#x4E4B;&#x95F4;&#x7684;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#xFF0C;&#x6211;&#x4EEC;&#x53D1;&#x73B0; 5 &#x53F7;&#x7C07;&#x4E0E; [1, 3] &#x7C07;&#x7684;&#x6700;&#x5C0F;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#xFF0C;&#x56E0;&#x6B64;&#x6211;&#x4EEC;&#x8981;&#x8FDB;&#x884C;&#x5408;&#x5E76;&#xFF0C;&#x5408;&#x5E76;&#x4E4B;&#x540E; C=[[1, 3, 5], [2, 4]]&#x3002;</p>
<p>&#x8FD9;&#x4E2A;&#x65F6;&#x5019; C &#x4E2D;&#x53EA;&#x6709;&#x4E24;&#x4E2A;&#x7C07;&#x4E86;&#xFF0C;&#x8FBE;&#x5230;&#x4E86;&#x6211;&#x4EEC;&#x7684;&#x9884;&#x671F;&#x76EE;&#x6807;&#xFF08;&#x60F3;&#x8981;&#x805A;&#x6210;&#x4E24;&#x7C7B;&#xFF09;&#xFF0C;&#x6240;&#x4EE5;&#x7B97;&#x6CD5;&#x505C;&#x6B62;&#x3002;&#x7B97;&#x6CD5;&#x505C;&#x6B62;&#x540E;&#x4F1A;&#x53D1;&#x73B0;&#xFF0C;&#x6211;&#x4EEC;&#x5DF2;&#x7ECF;&#x5C06; 5 &#x4E2A;&#x897F;&#x74DC;&#xFF0C;&#x805A;&#x6210;&#x4E86;&#x4E24;&#x7C7B;&#xFF0C;&#x4E00;&#x7C7B;&#x662F;&#x5C0F;&#x897F;&#x74DC;&#xFF0C;&#x53E6;&#x4E00;&#x7C7B;&#x662F;&#x5927;&#x897F;&#x74DC;&#x3002;</p>
<p>&#x5982;&#x679C;&#x5C06;&#x6574;&#x4E2A;&#x805A;&#x7C7B;&#x8FC7;&#x7A0B;&#x4E2D;&#x7684;&#x5408;&#x5E76;&#xFF0C;&#x4E0E;&#x5408;&#x5E76;&#x7684;&#x6B21;&#x5E8F;&#x53EF;&#x89C6;&#x5316;&#x51FA;&#x6765;&#xFF0C;&#x5C31;&#x80FD;&#x770B;&#x51FA;&#x4E3A;&#x4EC0;&#x4E48;&#x8BF4; AGNES &#x662F;&#x81EA;&#x5E95;&#x5411;&#x4E0A;&#x7684;&#x5C42;&#x6B21;&#x805A;&#x7C7B;&#x7B97;&#x6CD5;&#x4E86;&#x3002;</p>
<p><img src="img/62.jpg" alt=""></p>
<p>&#x6240;&#x4EE5; AGNES &#x4F2A;&#x4EE3;&#x7801;&#x5982;&#x4E0B;&#xFF1A;</p>
<pre><code class="lang-python"><span class="hljs-comment">#&#x5047;&#x8BBE;&#x6570;&#x636E;&#x96C6;&#x4E3A;D&#xFF0C;&#x60F3;&#x8981;&#x805A;&#x6210;&#x7684;&#x7C07;&#x7684;&#x6570;&#x91CF;&#x4E3A;k</span>
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">AGNES</span><span class="hljs-params">(D, k)</span>:</span>
<span class="hljs-comment">#C&#x4E3A;&#x805A;&#x7C7B;&#x7ED3;&#x679C;</span>
C = []
<span class="hljs-comment">#&#x5C06;&#x6BCF;&#x4E2A;&#x6837;&#x672C;&#x770B;&#x6210;&#x4E00;&#x4E2A;&#x7C07;</span>
<span class="hljs-keyword">for</span> d <span class="hljs-keyword">in</span> D:
C.append(d)
<span class="hljs-comment">#C&#x4E2D;&#x7C07;&#x7684;&#x6570;&#x91CF;</span>
q=len(C)
<span class="hljs-keyword">while</span> q &gt; k:
&#x5BFB;&#x627E;&#x8DDD;&#x79BB;&#x6700;&#x5C0F;&#x7684;&#x4E24;&#x4E2A;&#x7C07;a&#x548C;b
&#x5C06;a&#x548C;b&#x5408;&#x5E76;&#xFF0C;&#x5E76;&#x4FEE;&#x6539;C
q = len(C)
<span class="hljs-keyword">return</span> C
</code></pre>
</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="kMeans.html" class="navigation navigation-prev " aria-label="Previous page: 物以类聚人以群分-kMeans">
<i class="fa fa-angle-left"></i>
</a>
<a href="metrics.html" class="navigation navigation-next " aria-label="Next page: 模型评估指标">
<i class="fa fa-angle-right"></i>
</a>
</div>
<script>
var gitbook = gitbook || [];
gitbook.push(function() {
gitbook.page.hasChanged({"page":{"title":"以距离为尺-AGNES","level":"1.3.7","depth":2,"next":{"title":"模型评估指标","level":"1.4","depth":1,"path":"metrics.md","ref":"metrics.md","articles":[{"title":"分类性能评估指标","level":"1.4.1","depth":2,"path":"classification_metrics.md","ref":"classification_metrics.md","articles":[]},{"title":"回归性能评估指标","level":"1.4.2","depth":2,"path":"regression_metrics.md","ref":"regression_metrics.md","articles":[]},{"title":"聚类性能评估指标","level":"1.4.3","depth":2,"path":"cluster_metrics.md","ref":"cluster_metrics.md","articles":[]}]},"previous":{"title":"物以类聚人以群分-kMeans","level":"1.3.6","depth":2,"path":"kMeans.md","ref":"kMeans.md","articles":[]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":["katex"],"pluginsConfig":{"katex":{},"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":"AGNES.md","mtime":"2019-07-04T06:39:28.790Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-07-06T07:31:21.537Z"},"basePath":".","book":{"language":""}});
});
</script>
</div>
<script src="gitbook/gitbook.js"></script>
<script src="gitbook/theme.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>