2017-01-31 2 views
0

Plotクラスタを可視化した後にデータをサブセット化する最も簡単な方法は何ですか?

ここで私はデータの2つのクラスターを識別できると感じます。クラスタを視覚的に識別した後、このデータをサブセット化する最も効果的な方法は何ですか?このデータには、馬力= 49での休憩が便利ですが、すべてのデータがこのようなクリーンであるとは限りません。

+1

を実証するmtcarsデータを使用するつもりです。しかし、どのようなクラスタリング手法でも、データを見るだけでかなり良い結果が得られます。 '?kmeans'を参照してください。 –

+0

クラスタIDを特定するためにhbeanのkmeansを実行してみてください。 – Dave2e

答えて

0

kmeansまたはhclustを使用してデータをクラスタ化できます。次に、クラスタIDを抽出し、結果を視覚化して、自分の前提と比較します。私はあなたがおそらくcrossvalidatedでこの質問をする方がいいでしょう

# For reproducibility 
set.seed(42) 

# Perform kmeans clustering, 3 groups 
kclusters <- kmeans(mtcars[,c(1,4)], 3) 

# Bind together the original data and the clusterID 
plot_data <- cbind(mtcars, kclusters$cluster) 

# Plot the results and check your own assumptions. 
ggplot(plot_data, aes(x = hp, y = mpg)) + 
    geom_point(aes(color = factor(kclusters$cluster))) 

enter image description here

関連する問題