请在建立模型和检查准确性时查找附加的错误。我正在使用H2o软件包。 我已经创建模型为h2o模型。我想在测试和验证数据中应用模型。我在使用h中的h2o.confusionMatrix函数时出现“下标越界”错误
我的R代码里面是: -
library(mlbench)
library(h2o)
h2o.init(nthreads = -1)
data("BreastCancer")
#Adjusting data types
data<-BreastCancer[,-1] #remove the ID column
#converting all columns to numeric type
data[,c(1:ncol(data))]<-sapply(data[,c(1:ncol(data))],as.numeric)
#convert class column to factor type
data[,'Class']<-as.factor(data[,'Class'])
#converting in the h2o format
splitsample<-sample(1:3,size=nrow(data),prob=c(0.6,0.2,0.2),replace=TRUE)
train_h2o<-as.h2o(data[splitsample==1,])
val_h2o<- as.h2o(data[splitsample==2,])
test_h2o<-as.h2o(data[splitsample==3,])
model<- h2o.deeplearning(x=1:9,# column number for predictors
y=10, #column number for label
#data in H2o format
training_frame = train_h2o,
#or 'Tanh'
# TanhWithDropout means Tanh function with regularization
activation = "TanhWithDropout",
#% of inputs dropout
# It is used to drop bad or curropted or noise data
input_dropout_ratio = 0.2,
#balanced the two class
balance_classes = TRUE,
#two hidden layers of 10 units
hidden = c(10,10),
#% for nodes dropout
# dropout probability for hidden layers
hidden_dropout_ratios = c(0.3,0.3),
#max no. of epochs
# Times of iterate data
epochs = 10,
seed=0)
h2o.confusionMatrix(model)
#validation confusion matrix
h2o.confusionMatrix(model,newdata=val_h2o)
我的错误是:
错误在res $ model_metrics [1L]:下标越界
的请人帮助我深入学习。我非常感谢你。
我有错误的代码: -
h2o.confusionMatrix(模型,newdata = val_h2o)
Error in res$model_metrics[[1L]] : subscript out of bounds
请发布一个完全可重现的例子(包括数据,或使用像虹膜这样的内置数据集,以及所有的代码)。 –
@ErinLeDell我更新了我的文章,请帮助我。谢谢。 –