当我使用dl_model.show()时,它显示了所有信息,但没有显示模型的准确性,并且显示了验证数据的性能,它也没有显示AUC。当我运行此命令时,出现此错误
print('AUC', dl_model.auc(valid = False))
KeyError Traceback (most recent call last)
<ipython-input-655-a4a2f0946c88> in <module>()
----> 1 print('AUC', dl_model.auc())
~\Anaconda3\lib\site-packages\h2o\model\model_base.py in auc(self, train, valid, xval)
682 tm = ModelBase._get_metrics(self, train, valid, xval)
683 m = {}
--> 684 for k, v in viewitems(tm): m[k] = None if v is None else v.auc()
685 return list(m.values())[0] if len(m) == 1 else m
686
~\Anaconda3\lib\site-packages\h2o\model\metrics_base.py in auc(self)
165 def auc(self):
166 """The AUC for this set of metrics."""
--> 167 return self._metric_json['AUC']
168
169 def pr_auc(self):
KeyError: 'auc'
谢谢
答案 0 :(得分:1)
通常,如果您没有看到AUC度量标准,那是因为H2O-Algo不能解决二进制分类问题。
如果您想要多项式问题的准确性,请使用[max_hit_ratio_k][1]
并查看k=1
。
如果您想大致了解多项式的度量,请检查documentation中可用的内容,例如混淆矩阵和mean_per_class_error
都可用。
请在下面找到一个示例:目标是使hit_ratio k = 1(请参阅最后几行)
import h2o
from h2o.estimators.glm import H2OGeneralizedLinearEstimator
h2o.init()
# import the iris dataset:
# this dataset is used to classify the type of iris plant
# the original dataset can be found at https://archive.ics.uci.edu/ml/datasets/Iris
iris = h2o.import_file("http://h2o-public-test-data.s3.amazonaws.com/smalldata/iris/iris_wheader.csv")
# convert response column to a factor
iris['class'] = iris['class'].asfactor()
# set the predictor names and the response column name
predictors = iris.columns[:-1]
response = 'class'
# split into train and validation sets
train, valid = iris.split_frame(ratios = [.8])
# try using the `link` parameter:
# Initialize and train a GLM
iris_glm = H2OGeneralizedLinearEstimator(family = 'multinomial', link = 'family_default')
iris_glm.train(x = predictors, y = response, training_frame = train, validation_frame = valid)
pd = iris_glm.hit_ratio_table().as_data_frame()
pd.loc[(0,'hit_ratio')]