K NN技术(sanket077047)

时间:2014-10-21 05:11:52

标签: implementation knn

我正在做一个使用EEG信号对压力进行分类的项目。为此,我使用kn N技术,但我不知道如何实现这项技术。请帮我解决这个问题。我使用EEG的24电极数据库和软件使用的是MATLAB。   如何在matlab中训练网络?

1 个答案:

答案 0 :(得分:1)

来自http://www.rdatamining.com/examples/kmeans-clustering的示例演示 k - 在R中进行聚类,对于 k - 值为3.聚类向量显示分类分配每行数据:

> newiris <- iris
> newiris$Species <- NULL
> (kc <- kmeans(newiris, 3)) 
K-means clustering with 3 clusters of sizes 38, 50, 62

Cluster means:
  Sepal.Length Sepal.Width Petal.Length Petal.Width
1     6.850000    3.073684     5.742105    2.071053
2     5.006000    3.428000     1.462000    0.246000
3     5.901613    2.748387     4.393548    1.433871

Clustering vector:
  [1] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
 [30] 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 1 3 3 3 3 3
 [59] 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 3 3 3 3 3 3 3 3
 [88] 3 3 3 3 3 3 3 3 3 3 3 3 3 1 3 1 1 1 1 3 1 1 1 1 1 1 3 3 1
[117] 1 1 1 3 1 3 1 3 1 1 3 3 1 1 1 1 1 3 1 1 1 1 3 1 1 1 3 1 1
[146] 1 3 1 1 3

Within cluster sum of squares by cluster:
[1] 23.87947 15.15100 39.82097

Available components:
[1] "cluster"  "centers"  "withinss" "size"

基本上,您需要弄清楚如何将数据加载到R中,然后使用要为其分配数据的群集数量对该数据运行kmeans()命令。