Skip to content

Instantly share code, notes, and snippets.

@soonraah
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save soonraah/2e78b9ca13295139cdb8 to your computer and use it in GitHub Desktop.
Save soonraah/2e78b9ca13295139cdb8 to your computer and use it in GitHub Desktop.
skmeans パッケージによるコサイン距離ベースの k-means 実行
library(slam)
library(skmeans)
# CSV からデータの読み込み
x <- read.csv("data.csv")
# skmeans で扱えるデータ構造(simple triplet matrix)に変換
s <- as.simple_triplet_matrix(x)
# k-means 実行
result <- skmeans(s, k=5)
# 結果の表示
result$cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment