2017-01-30 1 views
0

나는 스파크의 홍채 데이터에 간단한 랜덤 포리스트 모델을 구축 중이며 정확성 측정 방법이 필요했습니다.SparkR의 측정 정확도

내가 너무 간단한 열 일치하는 옵션을 생각

그러나이 작동하지 않았다

코드 :

library("SparkR") 

sc = sparkR.session("local[*]") 

iris_data <- as.DataFrame(iris) 

train <- sample(iris_data, withReplacement=FALSE, fraction=0.5, seed=42) 
test <- except(iris_data, train) 


model_rf <- spark.randomForest(train, Species ~., "classification", numTrees = 10) 

summary(model_rf) 

문제 :

predictions <- predict(model_rf, test) 

total_rows <- NROW(test) 

predictions$correct <- (test$Species == test$prediction) 

accuracy <- correct/total_rows 

print(accuracy) 

오류 :

Error in column(callJMethod([email protected], "col", c)) : 

P.S : 불꽃을 실행할 데이터 벽돌을 사용 은 어느

답변

0

그래서 내가 그것을 어떻게하고,

total_rows <- NROW(test) 

predictions$result <- ifelse((predictions$Species == predictions$prediction), 
           "TRUE", "FALSE") 

correct <- NROW(predictions[predictions$result == "TRUE",]) 

accuracy <- correct/total_rows 

cat(accuracy, "%") 
로컬로 실행 상관하지 않습니다