Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transforming h2o model into non-h2o one

Tags:

r

h2o

I know that there is possibility to export/import h2o model, that was previously trained.

My question is - is there a way to transform h2o model to a non-h2o one (that just works in plain R)?

I mean that I don't want to launch the h2o environment (JVM) since I know that predicting on trained model is simply multiplying matrices, applying activation function etc.

Of course it would be possible to extract weights manually etc., but I want to know if there is any better way to do it.

I do not see any previous posts on SA about this problem.

like image 744
Andrzej Pisarek Avatar asked Aug 29 '16 21:08

Andrzej Pisarek


People also ask

What is H2O modeling?

H2O is a Java-based software for data modeling and general computing. The H2O software is many things, but the primary purpose of H2O is as a distributed (many machines), parallel (many CPUs), in memory (several hundred GBs Xmx) processing engine.

What is pojo and mojo?

About POJOs and MOJOsH2O allows you to convert the models you have built to either a Plain Old Java Object (POJO) or a Model ObJect, Optimized (MOJO). H2O-generated MOJO and POJO models are intended to be easily embeddable in any Java environment.

What is AutoML H2O?

H2O's AutoML can be used for automating the machine learning workflow, which includes automatic training and tuning of many models within a user-specified time-limit. H2O offers a number of model explainability methods that apply to AutoML objects (groups of models), as well as individual models (e.g. leader model).

What is a Mojo file?

A MOJO (Model Object, Optimized) is an alternative to H2O's POJO. As with POJOs, H2O allows you to convert models that you build to MOJOs, which can then be deployed for scoring in real time.


1 Answers

No.

Remember that R is just the client, sending API calls: the algorithms (those matrix multiplications, etc.) are all implemented in Java.

What they do offer is a POJO, which is what you are asking for, but in Java. (POJO stands for Plain Old Java Object.) If you call h2o.download_pojo() on one of your models you will see it is quite straightforward. It may even be possible to write a script to convert it to R code? (Though it might be better, if you were going to go to that trouble, to convert it to C++ code, and then use Rcpp!)

Your other option is to export the weights and biases, in the case of deep learning, implement your own activation function, and use them directly.

But, personally, I've never found the Java side to be a bottleneck, either from the point of view of dev ops (install is easy) or computation (the Java code is well optimized).

like image 64
Darren Cook Avatar answered Oct 22 '22 08:10

Darren Cook