SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
Kmeans VS kmeans++ and ykmeans
@R for Marketing Research and Analytics
2015年11月24日(火)
太田 博三
K-means
• 文法:
• kmeans(x, centers, iter.max = 10, nstart = 1,
algorithm = c("Hartigan-Wong", "Lloyd", "Forgy",
"MacQueen"))
• centers:クラスターの数, iter.max: 繰り返しの最大値,
• nstart: 初期中心を与える方法
• 引数algorithm:4種類
※centersがクラスターの数の場合、初期中心値はランダムになります。
K-means
• K-means法の手順
① 事前にクラスタ数kと繰り返し回数nを決めておく。
② step1:クラスタの中心点を、対象データの中からランダムにk
個選び出す。
③ step2:データごとに各クラスタの中心点との距離を求め、最も
近くに中心点があるクラスタに割り当てる
④ step3:クラスタごとに、割り当てられたデータの平均値を求め、
新たな中心点として採用する。
⑤ クラスタに割り当てるデータに変化がなくなる(=各クラスタの
中心点が定まる)まで、step2からstep3を繰り返す。ただし、繰
り返し数がnに達した場合はその時点で終了する。
K-meansの例
require(graphics)
# a 2-dimensional example
x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
colnames(x) <- c("x", "y")
(cl <- kmeans(x, 2))
plot(x, col = cl$cluster)
points(cl$centers, col = 1:2, pch = 8, cex = 2)
K-means++
• 文法:
• kmeanspp(data, k = 2, start = "random", iter.max = 100, nstart = 10, ...)
• Arguments
• data:an N ¥times d matrix, where N are the samples and d is the
dimension of space.
• k:number of clusters.
• start:first cluster center to start with
• iter.max:the maximum number of iterations allowed
• nstart:how many random sets should be chosen?
• ...:additional arguments passed to kmeans
K-means++
• K-means法の手順
• step1:対象データかの中から、クラスタの中心点をランダムに1
つ選び出す
• step2:それぞれのデータと選び出した中心点との距離を計算す
る
• step3:step2で求めた距離の二乗に比例した確率で、データを1
つ選び出し、クラスタの中心点として採用する
• 選び出したクラスタの中心点がk個になるまでstep2から3を繰り
返す。
K-means++
• 用例
• install.packages("LICORS")
• library(LICORS)
• set.seed(1984)
• nn <- 100
• XX <- matrix(rnorm(nn), ncol = 2)
• YY <- matrix(runif(length(XX) * 2, -1, 1), ncol = ncol(XX))
• ZZ <- rbind(XX, YY)
• cluster_ZZ <- ykmeans(ZZ,, 3:6)
• plot(ZZ, col = cluster_ZZ$cluster + 1, pch = 19)
ykmeans
• 文法:
ykmeans (x, variable.names, target.name, k.list, n)
x:データフレーム
variable.names:クラスタリングの時の使う説明変数名
target.name :クラスタ間で比較しようと思っている変数名
k.list:クラスタ数候補
n:試行回数
K-means++
• 「とりあえず100回くらい実行すれば安定するだろう」
• という仮定のもとに、100回実行して、一番多く分類され
たクラスタを採用している。
K-means++
• 用例2つ
#Examples1
• install.packages("ykmeans")
• library(ykmeans)
• data <- read.csv("data_ykmeans.csv", sep=",", header=T, row.names=1)
• data.sc <- scale(data) #データを標準化(各変量の単位が異なる場合)
• data.df <- as.data.frame(data.sc)
• ykm <- ykmeans(data.df, paste0("x", 1:10), "y", 7:15, n=500)
• #引数は、データフレーム、説明変数、比較する変数、クラスタ数候補、k-
means試行回数
• table(ykm$cluster)
• write.table(ykm$cluster, sep=",", "ykm.csv")
#Examples2
• data(actData)
• act.ykm <- ykmeans(actData, paste0("x",1:17),"y",3:6)
• table(act.ykm$cluster)

Más contenido relacionado

La actualidad más candente

Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析
Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析
Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析hnisiji
 
Kerasを用いた3次元検索エンジン@TFUG
Kerasを用いた3次元検索エンジン@TFUGKerasを用いた3次元検索エンジン@TFUG
Kerasを用いた3次元検索エンジン@TFUGOgushi Masaya
 
距離まとめられませんでした
距離まとめられませんでした距離まとめられませんでした
距離まとめられませんでしたHaruka Ozaki
 
ナップサックDPを説明してみた
ナップサックDPを説明してみたナップサックDPを説明してみた
ナップサックDPを説明してみたKoya Fukuda
 
クラシックな機械学習の入門 4. 学習データと予測性能
クラシックな機械学習の入門  4.   学習データと予測性能クラシックな機械学習の入門  4.   学習データと予測性能
クラシックな機械学習の入門 4. 学習データと予測性能Hiroshi Nakagawa
 
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)Nguyen Tuan
 
線形識別モデル
線形識別モデル線形識別モデル
線形識別モデル貴之 八木
 
ユークリッド距離以外の距離で教師無しクラスタリング
ユークリッド距離以外の距離で教師無しクラスタリングユークリッド距離以外の距離で教師無しクラスタリング
ユークリッド距離以外の距離で教師無しクラスタリングMaruyama Tetsutaro
 
はじめてのパターン認識輪読会 10章後半
はじめてのパターン認識輪読会 10章後半はじめてのパターン認識輪読会 10章後半
はじめてのパターン認識輪読会 10章後半koba cky
 
はじめてのパターン認識 第6章 後半
はじめてのパターン認識 第6章 後半はじめてのパターン認識 第6章 後半
はじめてのパターン認識 第6章 後半Prunus 1350
 
03_深層学習
03_深層学習03_深層学習
03_深層学習CHIHIROGO
 
Stochastic Gradient MCMC
Stochastic Gradient MCMCStochastic Gradient MCMC
Stochastic Gradient MCMCKenta Oono
 
Clustering _ishii_2014__ch10
Clustering  _ishii_2014__ch10Clustering  _ishii_2014__ch10
Clustering _ishii_2014__ch10Kota Mori
 
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)PATTERN RECOGNITION AND MACHINE LEARNING (1.1)
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)Yuma Yoshimoto
 
WUPC2nd A問題
WUPC2nd A問題WUPC2nd A問題
WUPC2nd A問題Dai Hamada
 
機械学習による統計的実験計画(ベイズ最適化を中心に)
機械学習による統計的実験計画(ベイズ最適化を中心に)機械学習による統計的実験計画(ベイズ最適化を中心に)
機械学習による統計的実験計画(ベイズ最適化を中心に)Kota Matsui
 
04.第四章用Matlab求偏导数
04.第四章用Matlab求偏导数04.第四章用Matlab求偏导数
04.第四章用Matlab求偏导数Xin Zheng
 
パターン認識 04 混合正規分布
パターン認識 04 混合正規分布パターン認識 04 混合正規分布
パターン認識 04 混合正規分布sleipnir002
 

La actualidad más candente (20)

Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析
Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析
Tokyo r#10 Rによるデータサイエンス 第五章:クラスター分析
 
Kerasを用いた3次元検索エンジン@TFUG
Kerasを用いた3次元検索エンジン@TFUGKerasを用いた3次元検索エンジン@TFUG
Kerasを用いた3次元検索エンジン@TFUG
 
距離まとめられませんでした
距離まとめられませんでした距離まとめられませんでした
距離まとめられませんでした
 
ナップサックDPを説明してみた
ナップサックDPを説明してみたナップサックDPを説明してみた
ナップサックDPを説明してみた
 
クラシックな機械学習の入門 4. 学習データと予測性能
クラシックな機械学習の入門  4.   学習データと予測性能クラシックな機械学習の入門  4.   学習データと予測性能
クラシックな機械学習の入門 4. 学習データと予測性能
 
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)
最近傍探索と直積量子化(Nearest neighbor search and Product Quantization)
 
ガウス積分
ガウス積分ガウス積分
ガウス積分
 
ガウス積分の問題
ガウス積分の問題ガウス積分の問題
ガウス積分の問題
 
線形識別モデル
線形識別モデル線形識別モデル
線形識別モデル
 
ユークリッド距離以外の距離で教師無しクラスタリング
ユークリッド距離以外の距離で教師無しクラスタリングユークリッド距離以外の距離で教師無しクラスタリング
ユークリッド距離以外の距離で教師無しクラスタリング
 
はじめてのパターン認識輪読会 10章後半
はじめてのパターン認識輪読会 10章後半はじめてのパターン認識輪読会 10章後半
はじめてのパターン認識輪読会 10章後半
 
はじめてのパターン認識 第6章 後半
はじめてのパターン認識 第6章 後半はじめてのパターン認識 第6章 後半
はじめてのパターン認識 第6章 後半
 
03_深層学習
03_深層学習03_深層学習
03_深層学習
 
Stochastic Gradient MCMC
Stochastic Gradient MCMCStochastic Gradient MCMC
Stochastic Gradient MCMC
 
Clustering _ishii_2014__ch10
Clustering  _ishii_2014__ch10Clustering  _ishii_2014__ch10
Clustering _ishii_2014__ch10
 
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)PATTERN RECOGNITION AND MACHINE LEARNING (1.1)
PATTERN RECOGNITION AND MACHINE LEARNING (1.1)
 
WUPC2nd A問題
WUPC2nd A問題WUPC2nd A問題
WUPC2nd A問題
 
機械学習による統計的実験計画(ベイズ最適化を中心に)
機械学習による統計的実験計画(ベイズ最適化を中心に)機械学習による統計的実験計画(ベイズ最適化を中心に)
機械学習による統計的実験計画(ベイズ最適化を中心に)
 
04.第四章用Matlab求偏导数
04.第四章用Matlab求偏导数04.第四章用Matlab求偏导数
04.第四章用Matlab求偏导数
 
パターン認識 04 混合正規分布
パターン認識 04 混合正規分布パターン認識 04 混合正規分布
パターン認識 04 混合正規分布
 

Similar a Kmeans vs kmeanspp_20151124

Improving Coreference Resolution by Learning Entity-Level Distributed Represe...
Improving Coreference Resolution by Learning Entity-Level Distributed Represe...Improving Coreference Resolution by Learning Entity-Level Distributed Represe...
Improving Coreference Resolution by Learning Entity-Level Distributed Represe...Yuichiroh Matsubayashi
 
クラスタリングについて
クラスタリングについてクラスタリングについて
クラスタリングについてArien Kakkowara
 
第七回統計学勉強会@東大駒場
第七回統計学勉強会@東大駒場第七回統計学勉強会@東大駒場
第七回統計学勉強会@東大駒場Daisuke Yoneoka
 

Similar a Kmeans vs kmeanspp_20151124 (6)

MMDs 7.3 - 7.4
MMDs 7.3 - 7.4MMDs 7.3 - 7.4
MMDs 7.3 - 7.4
 
Improving Coreference Resolution by Learning Entity-Level Distributed Represe...
Improving Coreference Resolution by Learning Entity-Level Distributed Represe...Improving Coreference Resolution by Learning Entity-Level Distributed Represe...
Improving Coreference Resolution by Learning Entity-Level Distributed Represe...
 
PRML s1
PRML s1PRML s1
PRML s1
 
クラスタリングについて
クラスタリングについてクラスタリングについて
クラスタリングについて
 
第七回統計学勉強会@東大駒場
第七回統計学勉強会@東大駒場第七回統計学勉強会@東大駒場
第七回統計学勉強会@東大駒場
 
Python Project (2)
Python Project (2)Python Project (2)
Python Project (2)
 

Más de 博三 太田

モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...博三 太田
 
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」博三 太田
 
slide_LT_Chatgpt部_太田_20231118.pdf
slide_LT_Chatgpt部_太田_20231118.pdfslide_LT_Chatgpt部_太田_20231118.pdf
slide_LT_Chatgpt部_太田_20231118.pdf博三 太田
 
LT_Visual_Entailment_GPT-4V_20231021.pdf
LT_Visual_Entailment_GPT-4V_20231021.pdfLT_Visual_Entailment_GPT-4V_20231021.pdf
LT_Visual_Entailment_GPT-4V_20231021.pdf博三 太田
 
LanguChain_summarization_LT_20230415.pdf
LanguChain_summarization_LT_20230415.pdfLanguChain_summarization_LT_20230415.pdf
LanguChain_summarization_LT_20230415.pdf博三 太田
 
image_video_instagram_202212.pdf
image_video_instagram_202212.pdfimage_video_instagram_202212.pdf
image_video_instagram_202212.pdf博三 太田
 
EC_intro_ota_202212.pdf
EC_intro_ota_202212.pdfEC_intro_ota_202212.pdf
EC_intro_ota_202212.pdf博三 太田
 
EC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdfEC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdf博三 太田
 
EC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdfEC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdf博三 太田
 
Python nlp handson_20220225_v5
Python nlp handson_20220225_v5Python nlp handson_20220225_v5
Python nlp handson_20220225_v5博三 太田
 
LT_hannari python45th_20220121_2355
LT_hannari python45th_20220121_2355LT_hannari python45th_20220121_2355
LT_hannari python45th_20220121_2355博三 太田
 
Logics 18th ota_20211201
Logics 18th ota_20211201Logics 18th ota_20211201
Logics 18th ota_20211201博三 太田
 
Jsai2021 winter ppt_ota_20211127
Jsai2021 winter ppt_ota_20211127Jsai2021 winter ppt_ota_20211127
Jsai2021 winter ppt_ota_20211127博三 太田
 
2021年度 人工知能学会全国大会 第35回
2021年度 人工知能学会全国大会 第35回2021年度 人工知能学会全国大会 第35回
2021年度 人工知能学会全国大会 第35回博三 太田
 
Lt conehito 20210225_ota
Lt conehito 20210225_otaLt conehito 20210225_ota
Lt conehito 20210225_ota博三 太田
 
Seattle consultion 20200822
Seattle consultion 20200822Seattle consultion 20200822
Seattle consultion 20200822博三 太田
 
Syumai lt_mokumoku__20200807_ota
Syumai  lt_mokumoku__20200807_otaSyumai  lt_mokumoku__20200807_ota
Syumai lt_mokumoku__20200807_ota博三 太田
 
Lt syumai moku_mokukai_20200613
Lt syumai moku_mokukai_20200613Lt syumai moku_mokukai_20200613
Lt syumai moku_mokukai_20200613博三 太田
 
Online python data_analysis19th_20200516
Online python data_analysis19th_20200516Online python data_analysis19th_20200516
Online python data_analysis19th_20200516博三 太田
 
本当に言いたい事をくみ取って応答する対話システムの構築に向けて - 昨年(2019年度)の取り組み -
本当に言いたい事をくみ取って応答する対話システムの構築に向けて- 昨年(2019年度)の取り組み -本当に言いたい事をくみ取って応答する対話システムの構築に向けて- 昨年(2019年度)の取り組み -
本当に言いたい事をくみ取って応答する対話システムの構築に向けて - 昨年(2019年度)の取り組み -博三 太田
 

Más de 博三 太田 (20)

モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察  ~Text-to-MusicとText-To-ImageかつImage-to-Music...
モーダル間の変換後の一致性とジャンル表を用いた解釈可能性の考察 ~Text-to-MusicとText-To-ImageかつImage-to-Music...
 
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」
「Fooocus(Stable DiffusionXL)で アニメ画像生成の仕方」
 
slide_LT_Chatgpt部_太田_20231118.pdf
slide_LT_Chatgpt部_太田_20231118.pdfslide_LT_Chatgpt部_太田_20231118.pdf
slide_LT_Chatgpt部_太田_20231118.pdf
 
LT_Visual_Entailment_GPT-4V_20231021.pdf
LT_Visual_Entailment_GPT-4V_20231021.pdfLT_Visual_Entailment_GPT-4V_20231021.pdf
LT_Visual_Entailment_GPT-4V_20231021.pdf
 
LanguChain_summarization_LT_20230415.pdf
LanguChain_summarization_LT_20230415.pdfLanguChain_summarization_LT_20230415.pdf
LanguChain_summarization_LT_20230415.pdf
 
image_video_instagram_202212.pdf
image_video_instagram_202212.pdfimage_video_instagram_202212.pdf
image_video_instagram_202212.pdf
 
EC_intro_ota_202212.pdf
EC_intro_ota_202212.pdfEC_intro_ota_202212.pdf
EC_intro_ota_202212.pdf
 
EC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdfEC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdf
 
EC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdfEC_attribute_exstraction_20221122.pdf
EC_attribute_exstraction_20221122.pdf
 
Python nlp handson_20220225_v5
Python nlp handson_20220225_v5Python nlp handson_20220225_v5
Python nlp handson_20220225_v5
 
LT_hannari python45th_20220121_2355
LT_hannari python45th_20220121_2355LT_hannari python45th_20220121_2355
LT_hannari python45th_20220121_2355
 
Logics 18th ota_20211201
Logics 18th ota_20211201Logics 18th ota_20211201
Logics 18th ota_20211201
 
Jsai2021 winter ppt_ota_20211127
Jsai2021 winter ppt_ota_20211127Jsai2021 winter ppt_ota_20211127
Jsai2021 winter ppt_ota_20211127
 
2021年度 人工知能学会全国大会 第35回
2021年度 人工知能学会全国大会 第35回2021年度 人工知能学会全国大会 第35回
2021年度 人工知能学会全国大会 第35回
 
Lt conehito 20210225_ota
Lt conehito 20210225_otaLt conehito 20210225_ota
Lt conehito 20210225_ota
 
Seattle consultion 20200822
Seattle consultion 20200822Seattle consultion 20200822
Seattle consultion 20200822
 
Syumai lt_mokumoku__20200807_ota
Syumai  lt_mokumoku__20200807_otaSyumai  lt_mokumoku__20200807_ota
Syumai lt_mokumoku__20200807_ota
 
Lt syumai moku_mokukai_20200613
Lt syumai moku_mokukai_20200613Lt syumai moku_mokukai_20200613
Lt syumai moku_mokukai_20200613
 
Online python data_analysis19th_20200516
Online python data_analysis19th_20200516Online python data_analysis19th_20200516
Online python data_analysis19th_20200516
 
本当に言いたい事をくみ取って応答する対話システムの構築に向けて - 昨年(2019年度)の取り組み -
本当に言いたい事をくみ取って応答する対話システムの構築に向けて- 昨年(2019年度)の取り組み -本当に言いたい事をくみ取って応答する対話システムの構築に向けて- 昨年(2019年度)の取り組み -
本当に言いたい事をくみ取って応答する対話システムの構築に向けて - 昨年(2019年度)の取り組み -
 

Kmeans vs kmeanspp_20151124

  • 1. Kmeans VS kmeans++ and ykmeans @R for Marketing Research and Analytics 2015年11月24日(火) 太田 博三
  • 2. K-means • 文法: • kmeans(x, centers, iter.max = 10, nstart = 1, algorithm = c("Hartigan-Wong", "Lloyd", "Forgy", "MacQueen")) • centers:クラスターの数, iter.max: 繰り返しの最大値, • nstart: 初期中心を与える方法 • 引数algorithm:4種類 ※centersがクラスターの数の場合、初期中心値はランダムになります。
  • 3. K-means • K-means法の手順 ① 事前にクラスタ数kと繰り返し回数nを決めておく。 ② step1:クラスタの中心点を、対象データの中からランダムにk 個選び出す。 ③ step2:データごとに各クラスタの中心点との距離を求め、最も 近くに中心点があるクラスタに割り当てる ④ step3:クラスタごとに、割り当てられたデータの平均値を求め、 新たな中心点として採用する。 ⑤ クラスタに割り当てるデータに変化がなくなる(=各クラスタの 中心点が定まる)まで、step2からstep3を繰り返す。ただし、繰 り返し数がnに達した場合はその時点で終了する。
  • 4. K-meansの例 require(graphics) # a 2-dimensional example x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2), matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2)) colnames(x) <- c("x", "y") (cl <- kmeans(x, 2)) plot(x, col = cl$cluster) points(cl$centers, col = 1:2, pch = 8, cex = 2)
  • 5. K-means++ • 文法: • kmeanspp(data, k = 2, start = "random", iter.max = 100, nstart = 10, ...) • Arguments • data:an N ¥times d matrix, where N are the samples and d is the dimension of space. • k:number of clusters. • start:first cluster center to start with • iter.max:the maximum number of iterations allowed • nstart:how many random sets should be chosen? • ...:additional arguments passed to kmeans
  • 6. K-means++ • K-means法の手順 • step1:対象データかの中から、クラスタの中心点をランダムに1 つ選び出す • step2:それぞれのデータと選び出した中心点との距離を計算す る • step3:step2で求めた距離の二乗に比例した確率で、データを1 つ選び出し、クラスタの中心点として採用する • 選び出したクラスタの中心点がk個になるまでstep2から3を繰り 返す。
  • 7. K-means++ • 用例 • install.packages("LICORS") • library(LICORS) • set.seed(1984) • nn <- 100 • XX <- matrix(rnorm(nn), ncol = 2) • YY <- matrix(runif(length(XX) * 2, -1, 1), ncol = ncol(XX)) • ZZ <- rbind(XX, YY) • cluster_ZZ <- ykmeans(ZZ,, 3:6) • plot(ZZ, col = cluster_ZZ$cluster + 1, pch = 19)
  • 8. ykmeans • 文法: ykmeans (x, variable.names, target.name, k.list, n) x:データフレーム variable.names:クラスタリングの時の使う説明変数名 target.name :クラスタ間で比較しようと思っている変数名 k.list:クラスタ数候補 n:試行回数
  • 10. K-means++ • 用例2つ #Examples1 • install.packages("ykmeans") • library(ykmeans) • data <- read.csv("data_ykmeans.csv", sep=",", header=T, row.names=1) • data.sc <- scale(data) #データを標準化(各変量の単位が異なる場合) • data.df <- as.data.frame(data.sc) • ykm <- ykmeans(data.df, paste0("x", 1:10), "y", 7:15, n=500) • #引数は、データフレーム、説明変数、比較する変数、クラスタ数候補、k- means試行回数 • table(ykm$cluster) • write.table(ykm$cluster, sep=",", "ykm.csv") #Examples2 • data(actData) • act.ykm <- ykmeans(actData, paste0("x",1:17),"y",3:6) • table(act.ykm$cluster)