您的訂閱是我製作影片的動力
訂閱點這裡~
若內容有誤,還請留言指正,謝謝您的指教
#影片程式碼
#延續DAY17
features <- setdiff(x = names(traindata), y = "Sepal.Length")
par(mfrow=c(1,1))
set.seed(123)
tuneRF(x = traindata[features], y = traindata$Sepal.Length,
mtryStart = 1,ntreeTry = 450)
set.seed(123)
model <- randomForest(Sepal.Length ~ Sepal.Width+Petal.Length+Petal.Width, data = traindata,
ntree = 450, mtry = 3,
do.trace = 50,na.action = na.roughfix)
future <- predict(model,testdata)
future <- as.data.frame(future)
final <- cbind(future,testdata)
library(dplyr)
final <- mutate(final,mape=abs(future-Sepal.Length)/Sepal.Length)
mean(final$mape)