Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
TokyoR#60 クラスタ分析におけるクラスタ数の決め方
Search
bob3bob3
January 12, 2022
Programming
510
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
TokyoR#60 クラスタ分析におけるクラスタ数の決め方
クラスタ分析におけるクラスタ数の決め方。
2017年4月。
bob3bob3
January 12, 2022
More Decks by bob3bob3
See All by bob3bob3
RとLLMで自然言語処理
bob3bob3
3
1.1k
RでPSM分析
bob3bob3
1
560
Rでコンジョイント分析 2024年版
bob3bob3
0
2.9k
『改訂新版前処理大全』の話と Apache Parquet の話 #TokyoR
bob3bob3
0
1.5k
R言語の環境構築と基礎 Tokyo.R 112
bob3bob3
0
670
『データ可視化学入門』をPythonからRに翻訳した話(増強版)
bob3bob3
0
630
『データ可視化学入門』を PythonからRに翻訳した話
bob3bob3
1
690
qeMLパッケージの紹介
bob3bob3
0
3k
「国と音楽」 ~spotifyrを用いて~ #muana
bob3bob3
2
700
Other Decks in Programming
See All in Programming
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
300
Verilogで学ぶCPU自作入門
uyuki234
8
4.1k
Web Framework Benchmark Battle 2026, Any%
a_matsuda
2
2.5k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
280
re:Inventに行く前に知っておきたい現地参加のノウハウ
nokomoro3
0
440
Next.js: The final boss of Web Performance
guaca
0
280
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
170
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
15
8.5k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
180
Event is what happens
moro
2
860
JIS keyboard support in Omarchy
lef237
0
130
Featured
See All Featured
Producing Creativity
orderedlist
PRO
348
41k
brightonSEO & MeasureFest 2025 - Winning Strategies for Black Friday CRO & PPC - Christian Goodrich
cargoodrich
3
870
The World Runs on Bad Software
bkeepers
PRO
72
12k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
43k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
630
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.5k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
440
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
710
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
890
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Between Models and Reality
mayunak
4
500
Transcript
クラスタ分析における クラスタ数の決め方 @bob3bob3 Tokyo.R #60
クラスタ分析におけるクラスタ数の決め方 • クラスタ分析を行う際、クラスタ数をいくつにするべきかという のは非常に悩ましい問題。 • 目的や分野によっても考え方が異なるでしょう。 • 原則として、分析者が意思を持って決めるべき、というのが結 論ではある。 •
ただ、それを支援する、より適切と思われるクラスタ数を示唆 してくれる指標(cluster index)がいくつかRで提供されている。
パッケージと関数 • 今回は3つのパッケージと関数をご紹介。 ◦ {cclust} パッケージの clusterIndex() ◦ {vegan} パッケージの
cascadeKM() ◦ {clusterSim} パッケージの cluster.Sim()
{cclust}パッケージのclustIndex() • clustIndex() は cclust() でクラスタリングした結果に対して指標値を返す。 • 15種の指標を返すが、calinski(疑似F統計量)がおすすめ。 library(cclust) DAT
<- as.matrix(iris[,-5]) MAX <- 10 res <- data.frame(matrix(0,MAX,15)) for (i in 2:MAX){ clust <- cclust(DAT, i) temp <- clustIndex(clust, DAT) if(i==2) colnames(res) <- names(temp) res[i,] <- temp } plot(res$calinski, type="b")
{vegan} パッケージの cascadeKM() • cascadeKM() は calinski に基づいて最適と考えられるクラスタリング結果を返す。 library(vegan) #
試行するクラスタ数の最小数と最大数を与える # デフォルトは calinski だが ssi も使える res <- cascadeKM(iris[,-5], 2, 10) best <- plot(res) best$x[,best$best.grps]
{clusterSim} パッケージの cluster.Sim() • cluster.Sim()は複数の標準化手法、距離、クラスタリング手法を組み合わせて最 適なクラスタリングを探索する。引数の指定が独特なのでヘルプからたどれる clusterSim_details.pdf を見ながら設定すること。 library(clusterSim) cluster.Sim(iris[,-5],
p=1, min=2, max=10, "G1", outputHtml="results.iris") # これで3,312通りのクラスタリングが試される。 # 非力なマシンでは非常に時間がかかるので注意。
最後に • クラスタの数は分析者が意思を持って決めるべきという結論 は変わらないのですが、これらの指標を使うことで検討にかか る負担を大きく減らし、考察に時間を使うことができます。 • また、GIGOなのは変わらないので、これらの指標を使っても 元データがダメだとどうにもなりません。本当の肝はどんな データをクラスタリングに利用するかという部分ですが、その 話はまたこんど。