私はR5でRWekaパッケージを使って、 "M5P"を使ってM5 'ツリーをデータセットに収めています。次に、生成されたツリーを「パーティー」ツリーに変換して、可変のインポートにアクセスできるようにします。私が午前問題は、私は次のエラーを取得せずに動作するように機能as.party
を得るように見えることができないということです。"RWeka"意思決定ツリーをRの "パーティ"ツリーに変換するにはどうすればよいですか?
"Error: all(sapply(split, head, 1) %in% c("<=", ">")) is not TRUE"
この私がforループ内の関数を適用する場合にのみに発生するエラーが、forループ私は5倍交差検証を実行しているので必要です。
n <- nrow(data)
k <- 5
indCV <- sample(rep(1:k,each=ceiling(n/k)), n)
for(i in 1:k){
#Training data is for all the observations where indCV is not equal to i
training_data <- data.frame(x[-which(indCV==i),])
training_response <- y[-which(indCV==i)]
#Test the data on the fifth of the data where the observation indices are equal to i
test_data <- x[which(indCV==i),]
test_response <- y[which(indCV==i)]
#Fit a pruned model to the training data
fit <- M5P(training_response~., data=training_data, control=Weka_control(N=TRUE))
#Convert to party
p <- as.party(fit)
}
[RでCostSensitiveClassifierツリーをプロットするにはどうすればよいですか?](https://stackoverflow.com/questions/24420191/how-do-you-plot-a-costsensitiveclassifier-tree-in-r) –