我在使用R绘制聚类时遇到了一些问题。 我使用Kmeans作为压缩数据集的方法。 我的数据集已经标记为10个类,所以我已经知道每个数据点属于哪个类。是否可以可视化每个数据点在每个群集中的排序方式。这样我就可以在每个集群中对类分布做出某种形式的结论。
我尝试使用表格
var include = (function() {
var exports = {}
var test = function(url) {
var result = [];
$.ajax(url).then(function(data) {
result.length = 0;//remove existing items from the array
result.push.apply(result, data.form.records);//copy the items from the records to the result array instead of assigning a new value
console.log(result) // displays correctly Array [Object,Object]
});
return result;
}
exports.test = test;
return exports
})();
输出
table(data$labels[kmeans_output$clusterr==1])
我认为是集群1的类分布。
是否可以为所有群集可视化?
答案 0 :(得分:1)
使用iris
作为示例的示例不是reproducible。
这是你在找什么?
km <- kmeans(iris[, 1:2], 3)
plot(iris[, 1:2], col=km$cluster)
table(iris$Species, km$cluster)