我在数据集上执行了kknn
操作。我想将操作的summary
转换为data.frame。以下是示例数据:
X <- data.frame(A=c(4,2,2,5,2,4), B=c("M","F","M","M","M","M"),
C=c(53,50,44,47,42,43))
n <- dim(X)[1]
sampleValues <- sample(1:n,size=round(n/3),replace=F,prob=rep(1/n,n))
x.train <- X[-sampleValues,]
x.test <- X[sampleValues,]
x.kknn <- kknn(B~., x.train, x.test, distance=1, kernel="triangular")
是否可以将summary(x.kknn)
存储在data.frame中?