【发布时间】:2015-07-19 02:38:26
【问题描述】:
我正在尝试使用 DMwR 包在 R 中实现 LOF 算法。我正在使用的数据集是来自 UCI 机器学习存储库的Wisconsin Breast Cancer dataset(对于最后一列,我已将 2 转换为“良性”,将 4 转换为“恶性”),它在我正在导入的 csv 文件中看起来像这样来自:
"Clump Thickness","Uniformity of Cell Size", "Uniformity of Cell Shape","Marginal Adhesion" ,"Single Epithelial Cell Size","Bare Nuclei" , "Bland Chromatin" ,"Normal Nucleoli" ,"Mitoses" , "Class"
5,1,1,1,2,1,3,1,1,benign
5,4,4,5,7,10,3,2,1,benign
3,1,1,1,2,2,3,1,1,benign
然后我使用这组命令
breastcancer <- read.csv("breastcancer.csv", sep = ",")
breastcancer2 <- breastcancer[,1:9]
outlierscores <- lofactor(breastcancer2, k=5)
但是,它给了我错误:
Error in scale.default(temp, x, FALSE) :
length of 'center' must equal the number of columns of 'x'
谁能帮我找出问题所在?
【问题讨论】:
-
您可以添加数据集的链接吗?
-
DMwR包非常慢。 :-( 另外,它不应该为您自动缩放数据,这会扭曲距离。 -
@Anony-Mousse 那么,错误是由于缩放造成的吗?你建议我如何解决它?
-
缩放应该不是问题,除非你有不同长度的向量或缺失值。但是最后我没有用
DMwR,太慢了。除了建议使用其他工具之外,我最终无法帮助您。 -
我可以尝试哪些其他替代方案?
标签: r data-mining outliers