[英]Hyperparameter tuning using neuralnet method in R
I'm using Wisconsin Breast Cancer Dataset for classification problem: diagnosis of malignant or benign tumors.我正在使用威斯康星州乳腺癌数据集来解决分类问题:恶性或良性肿瘤的诊断。 The dataset has 33 features, all features are numerical besides diagnosis (factor).
该数据集有 33 个特征,除诊断(因子)外,所有特征都是数字的。 I'm trying to build DNN model and tune hyperparameters of neuralnet method in train function , but when I ran the model I get an error: "Error: wrong model type for classification" .
I'm trying to build DNN model and tune hyperparameters of neuralnet method in train function , but when I ran the model I get an error: "Error: wrong model type for classification" . What should I do in this case?
在这种情况下我该怎么办?
set.seed(1)
library(neuralnet)
grid <- expand.grid(layer1=c(1:20), layer2=c(1:20), layer3=c(1:20))
DNN <- train(diagnosis ~., data = train.df, method = "neuralnet", linear.output = FALSE,
tuneGrid = grid, metric = "Kappa", trControl=train_control,
maxit = 500, allowParallel = TRUE )
pred <- predict(DNN, newdata = valid.df)
confusionMatrix(pred, valid.df$diagnosis)
The neuralnet
method used in caret, can only be used for regression modelling, not classification. caret 中使用的
neuralnet
方法,只能用于回归建模,不能用于分类。 You need to select a different model.您需要 select 不同的 model。 You can check which models can be used for classification with caret here .
您可以在此处使用插入符号检查哪些模型可用于分类。
For neuralnets and classification you can use mxnet
and nnet
methods.对于神经网络和分类,您可以使用
mxnet
和nnet
方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.