H2O MOJO wrapper - allows predictions from python without the webserver overhead.
Project description
### pyH2oMojo
#### Unofficial Python wrapper for H2o MOJO's
A lightweight python wrapper around an H2o EasyPredictModelWrapper instance
Instantiating the object will launch the bundled Jar file, and establish a port on localhost on which to communicate with.
Dictionaries or JSON strings are passed to the predictor instance over a socket, and the output is read back via the subprocess' stdout pipe.
#### Usage
```
from pyH2oMojo import H2oMojoPredictor
# pass at minimum, the filename of the MOJO, and the predictor type
predictor = H2oMojoPredictor("my_nn.zip", "multivariate", verbose=True)
print(H2oMojoPredictor.predict({"sepal_length":4.9, "sepal_width":3.0, "petal_length":1.4,"petal_width":0.2}))
>>> {"prediction":"Iris-setosa", "predictionIndex":1, "classProbabilities":[0.0, 0.944, 0.056]}
print(H2oMojoPredictor.supported_predictors())
>>> ["multivariate", "regression", "ordinal", "binomial", "autoencoder", "clustering", "dimreduction"]
# other constructor parameters include:
# x_cols=None # List of columns to be passed to predict() - by default everything is passed
# x_types=None # Dictionary of column name and types ('int', 'real', 'str') - these values will be converted before being sent to the model.
# connection_timeout=10.0 # Number of seconds to wait for the Java subprocess to start before raising a runtime error
# prediction_timeout=3.0 # Number of seconds to wait for a response from the Java subprocess before raising a runtime error
```
#### Unofficial Python wrapper for H2o MOJO's
A lightweight python wrapper around an H2o EasyPredictModelWrapper instance
Instantiating the object will launch the bundled Jar file, and establish a port on localhost on which to communicate with.
Dictionaries or JSON strings are passed to the predictor instance over a socket, and the output is read back via the subprocess' stdout pipe.
#### Usage
```
from pyH2oMojo import H2oMojoPredictor
# pass at minimum, the filename of the MOJO, and the predictor type
predictor = H2oMojoPredictor("my_nn.zip", "multivariate", verbose=True)
print(H2oMojoPredictor.predict({"sepal_length":4.9, "sepal_width":3.0, "petal_length":1.4,"petal_width":0.2}))
>>> {"prediction":"Iris-setosa", "predictionIndex":1, "classProbabilities":[0.0, 0.944, 0.056]}
print(H2oMojoPredictor.supported_predictors())
>>> ["multivariate", "regression", "ordinal", "binomial", "autoencoder", "clustering", "dimreduction"]
# other constructor parameters include:
# x_cols=None # List of columns to be passed to predict() - by default everything is passed
# x_types=None # Dictionary of column name and types ('int', 'real', 'str') - these values will be converted before being sent to the model.
# connection_timeout=10.0 # Number of seconds to wait for the Java subprocess to start before raising a runtime error
# prediction_timeout=3.0 # Number of seconds to wait for a response from the Java subprocess before raising a runtime error
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyH2oMojo-0.1.0.tar.gz
(12.8 MB
view hashes)
Built Distribution
pyH2oMojo-0.1.0-py3-none-any.whl
(12.8 MB
view hashes)
Close
Hashes for pyH2oMojo-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4963cc44c18062475db2a7e518d1342951ddb741f1bad56e5d9d725b3ed2bab9 |
|
MD5 | 28e5aa06522086967ab519d0571528bb |
|
BLAKE2b-256 | 6ddf0eb932ae56bfc54d4170e3ce5f842fb989fec5234748fa6f87ec2b79da20 |