階層型クラスタリングの限界

Pythonで学ぶクラスタ分析

Shaumik Daityari

Business Analyst

階層型クラスタリングの速度測定

  • timeit モジュール
  • .linkage() メソッドの速度を測定
  • 乱数で生成した点を使用
  • 複数回実行して外挿
Pythonで学ぶクラスタ分析

timeit モジュールの使用

from scipy.cluster.hierarchy import linkage
import pandas as pd
import random, timeit

points = 100 df = pd.DataFrame({'x': random.sample(range(0, points), points), 'y': random.sample(range(0, points), points)})
%timeit linkage(df[['x', 'y']], method = 'ward', metric = 'euclidean')
1.02 ms ± 133 µs/ループ(7 回の実行の平均 ± 標準偏差、各 1000 ループ)
Pythonで学ぶクラスタ分析

linkage メソッドの実行時間比較

  • データ点の増加で実行時間が延びる
  • 実行時間は二乗で増加
  • 大規模データには不向き

Pythonで学ぶクラスタ分析

次は演習です

Pythonで学ぶクラスタ分析

Preparing Video For Download...