Plotting scoring history from H2O model in python

Once you build a model with H2O the scoring history can be see in the mode details or model metrics table. If validation is enabled then scoring and validation history is also visible. You can see these metrics in the FLOW UI however if you are using python shell then you may want to plot training and/or validation metrics by your self and this is what we will do next.

To get the scoring history from the model in python you can just try the following:

import pandas as pd
sh = mymodel.score_history()
sh = pd.DataFrame(sh)
print(sh.columns)

 

The results are as below:

Index([u'', u'timestamp', u'duration', u'number_of_trees', u'training_rmse',
       u'training_logloss', u'training_auc', u'training_lift',
       u'training_classification_error'],
      dtype='object')

The model’s scoring history table looks like as below:

Screen Shot 2017-04-11 at 3.43.14 PM

Next we can plot a graph between training_logloss and training_auc as below:

import matplotlib.pyplot as plt
%matplotlib inline 
# plot training logloss and auc
sh.plot(x='number_of_trees', y = ['training_auc', 'training_logloss'])

The results are as below:

Screen Shot 2017-04-11 at 3.44.32 PM

Thats is, enjoy!!

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s