Reputation: 439
I'm trying to access the results of some H2O models using python.
I specifically want the cross-validation results. I'm able to get r2 and mae using the code below. I'd ideally like the standard deviation scores too.
I can see the data using .cross_validation_metrics_summary
, but can't work out how to return the specific values (e.g. cross validation sd)
import h2o
h2o.init()
def get_model_det(current_model):
r2_score = current_model.r2(xval = "TRUE")
mae_score = current_model.mae(xval = "True")
varimp = current_model.varimp()
print(current_model.cross_validation_metrics_summary)
print(r2_score, mae_score)
current_model = h2o.get_model("XGBoost_2_AutoML_20200513_153924")
get_model_det(current_model)
Upvotes: 1
Views: 218
Reputation: 930
If you would like to call out the specific values from cross_validation_metrics_summary
, you can use the following:
current_model.cross_validation_metrics_summary().as_data_frame()[['', 'sd']]
The last part [['', 'sd']]
will call the two columns of interest. ''
is the name of each score (e.g. accuracy, auc) and 'sd'
would give their corresponding standard deviations.
Outputs a table:
+-------+----------+--------------+
| index | '' | sd |
+-------+----------+--------------+
| 0 | accuracy | 0.0048520584 |
| 1 | auc | 0.011593064 |
| 2 | aucpr | 0.011920754 |
| ... | ... | ... |
+-------+----------+--------------+
Upvotes: 1