I am trying to implement the LOF algorithm in R using the DMwR
package. The dataset I am using is the Wisconsin Breast Cancer dataset from UCI machine learning repository (for the last column I have converted 2 to 'benign' and 4 to 'malignant') and it looks something like this in the csv file that I am importing it from:
我正在尝试使用DMwR包在R中实现LOF算法。我正在使用的数据集是来自UCI机器学习库的威斯康星乳腺癌数据集(最后一栏我将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
Then I use these set of commands
然后我使用这些命令集
breastcancer <- read.csv("breastcancer.csv", sep = ",")
breastcancer2 <- breastcancer[,1:9]
outlierscores <- lofactor(breastcancer2, k=5)
However, it is giving me the error:
但是,它给了我错误:
Error in scale.default(temp, x, FALSE) :
length of 'center' must equal the number of columns of 'x'
Could anyone please help me in identifying the problem?
有谁可以帮我找出问题所在?
1 个解决方案
#1
lofactor() cannot calculate factor type data, please make sure your data type is numeric
lofactor()无法计算因子类型数据,请确保您的数据类型为数字
#1
lofactor() cannot calculate factor type data, please make sure your data type is numeric
lofactor()无法计算因子类型数据,请确保您的数据类型为数字