On Saturday, June 6, 2015 at 9:51:58 AM UTC-7, Tanay Chowdhury wrote:
> I've got a h2o object by running gp=h2o.predict(gbm) in python.
> My question is how to convert that in to a python object say list or pandas data frame.
Tanay, in this case, "gp" is an H2OFrame object. To convert it to a python list simply do:
gp_as_list = h2o.as_list(gp, use_pandas=False)
gp_as_list[0] # this corresponds to the header of the H2OFrame. if gbm is a binary classifier, then gp[0] should produce output that looks like this: ['predict', 'p0', 'p1'] , where the 'predict' column possesses the predicted classes, and 'p0' and 'p1' columns possess the class probabilities that were computed.
gp_as_list[1] # this corresponds to the first row of the H2OFrame and possesses the class prediction and associated probabilities of the first observation. It might look something like ['0', '0.8046859208563315', '0.19531407914366855']
If you want convert 'gp' to a pandas data frame, do:
gp_as_pandas = h2o.as_list(gp) # pandas data frame is the default