gpt4 book ai didi

r - train.default(x, y, weights = w, ...) : final tuning parameters could not be determined 中的错误

转载 作者:行者123 更新时间:2023-12-04 10:13:01 25 4
gpt4 key购买 nike

我是机器学习的新手,正在尝试 forest cover prediction competition on Kaggle ,但我很早就挂了。运行以下代码时出现以下错误。

Error in train.default(x, y, weights = w, ...) : final tuning parameters could not be determinedIn addition: There were 50 or more warnings (use warnings() to see the first 50)
# Load the libraries
library(ggplot2); library(caret); library(AppliedPredictiveModeling)
library(pROC)
library(Amelia)

set.seed(1234)

# Load the forest cover dataset from the csv file
rawdata <- read.csv("train.csv",stringsAsFactors = F)
#this data won't be used in model evaluation. It will only be used for the submission.
test <- read.csv("test.csv",stringsAsFactors = F)

########################
### DATA PREPARATION ###
########################

#create a training and test set for building and evaluating the model
samples <- createDataPartition(rawdata$Cover_Type, p = 0.5,list = FALSE)
data.train <- rawdata[samples, ]
data.test <- rawdata[-samples, ]

model1 <- train(as.factor(Cover_Type) ~ Elevation + Aspect + Slope + Horizontal_Distance_To_Hydrology,
data = data.train,
method = "rf", prox = "TRUE")

最佳答案

以下应该工作:

model1 <- train(as.factor(Cover_Type) ~ Elevation + Aspect + Slope + Horizontal_Distance_To_Hydrology,
data = data.train,
method = "rf", tuneGrid = data.frame(mtry = 3))

指定 tuneGrid 总是更好参数,它是一个具有可能调整值的数据帧。看 ?randomForest?train想要查询更多的信息。 rf只有一个调整参数 mtry ,它控制为每棵树选择的特征数量。

您也可以运行 modelLookup获取每个模型的调整参数列表
> modelLookup("rf")
# model parameter label forReg forClass probModel
#1 rf mtry #Randomly Selected Predictors TRUE TRUE TRUE

关于r - train.default(x, y, weights = w, ...) : final tuning parameters could not be determined 中的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27683749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com