【发布时间】:2019-03-28 07:43:20
【问题描述】:
使用 h2o python API 训练一些模型,对如何正确实现 API 的某些部分有点困惑。具体来说,在实际使用模型的predict() 方法时,应该忽略训练数据集中的哪些列以及模型如何在数据集中查找实际的预测器特征。还有应该如何处理权重列(当实际的预测数据集没有真正的权重时)
这里的代码细节(我认为)并不重要,但基本的训练逻辑看起来像
drf_dx = h2o.h2o.H2ORandomForestEstimator(
# denoting update version name by epoch timestamp
model_id='drf_dx_v'+str(version)+'t'+str(int(time.time())),
response_column='dx_outcome',
ignored_columns=[
'ucl_id', 'patient_id', 'account_id', 'tar_id', 'charge_line', 'ML_data_begin',
'procedure_outcome', 'provider_outcome',
'weight'
],
weights_column='weight',
ntrees=64,
nbins=32,
balance_classes=True,
binomial_double_trees=True)
.
.
.
drf_dx.train(x=X_train, y=Y_train,
training_frame=train_u, validation_frame=val_u,
max_runtime_secs=max_train_time_hrs*60*60)
(注意被忽略的列)和预测逻辑看起来像
preds = model.predict(X)
其中 X 是一些 (h2o) 数据框,其列比 X_train 中的列多(或少),用于训练模型(包括一些用于后处理探索的列(在 Jupyter 笔记本中))。例如。 X_train 列可能看起来像
<columns to ignore (as seen in the code)> <columns to use a features for training> <outcome label>
X 列可能看起来像
<columns to ignore (as seen in the code)> <EVEN MORE COLUMNS TO IGNORE> <columns to use a features for training>
我的问题是:这会在进行预测时混淆模型吗? IE。模型是通过 column name 将列用作特征(在这种情况下,我认为不同的数据框宽度不会成为问题)还是通过 column position (在这种情况下,向每个样本添加更多数据列会改变位置并成为问题)还是其他?由于模型构造函数的 ignored_columns arg 中没有说明这些列,会发生什么情况?
** 顺便说一句:weights_column 名称是否应该在 ignored_columns 列表中?文档中的示例 (http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/weights_column.html#weights-column) 似乎将其用作预测功能,并且似乎推荐它
对于评分,所有计算的指标都会考虑观察权重(对于增益/提升、AUC、混淆矩阵、对数损失等),因此如果需要,还必须为验证集或测试集提供权重列提高/降低某些观察的权重(理想情况下在训练和测试之间保持一致)。
但这些权重值并不是实际预测中使用的数据所附带的。
【问题讨论】:
标签: h2o