5

randomForest と bigmemory ライブラリを使用して分類 (回帰ではない) を設定できた人はいますか? 「数式アプローチ」を使用できないことは承知しており、「x=予測子、y=応答アプローチ」に頼らなければなりません。ビッグ メモリ ライブラリは、カテゴリ値を持つ応答ベクトルを処理できないようです (私の場合、2 つのレベルがあり、どちらも文字として表されます。

bigmemoryのドキュメントによると...「データフレームには文字ベクトルが因子に変換され、次にすべての因子が数値因子レベルに変換されます」

randomForest分類をbigmemoryで動作させるための回避策はありますか?

#EXAMPLE to problem
library(randomForest)
library(bigmemory)
# Removing any extra objects from my workspace (just in case)
rm(list=ls())

#first small matrix
small.mat <- matrix(sample(0:1,5000,replace = TRUE),1000,5)
colnames(small.mat) <- paste("V",1:5,sep = "")
small.mat[,5] <- as.factor(small.mat[,5]) 
small.rf <- randomForest(V5 ~ .,data = small.mat, mtry=2, do.trace=100)
print(small.rf)
small.result <- matrix(0,1000,1)
small.result <- predict(small.rf, data=small.mat[,-5])

#now small dataframe Works!
small.mat <- matrix(sample(0:1,5000,replace = TRUE),1000,5)
colnames(small.mat) <- paste("V",1:5,sep = "")
small.data <- as.data.frame(small.mat)

small.data[,5] <- as.factor(small.data[,5]) 
small.rf <- randomForest(V5 ~ .,data = small.data, mtry=2, do.trace=100)
print(small.rf)
small.result <- matrix(0,1000,1)
small.result <- predict(small.rf, data=small.data[,-5])


#then big matrix Classification Does NOT Work :-(
#----------------****************************----
big.mat <- as.big.matrix(small.mat, type = "integer")
#Line below throws error, "cannot coerce class 'structure("big.matrix", package = "bigmemory")' into a data.frame"
big.rf <- randomForest(V5~.,data = big.mat, do.trace=10)

#Runs without error but only regression
big.rf <- randomForest(x = big.mat[,-5], y = big.mat[,5], mtry=2, do.trace=100)
print(big.rf)
big.result <- matrix(0,1000,1)
big.result <- predict(big.rf, data=big.mat[,-5])
4

1 に答える 1

1

bigrfパッケージが役立つ場合があります。現在、機能の数が制限された分類をサポートしています。

于 2013-09-10T17:26:24.093 に答える