module mlapp.mlpost_rest
¶
Short summary¶
module lightmlrestapi.mlapp.mlpost_rest
Machine Learning Post request
Classes¶
class |
truncated documentation |
---|---|
Implements a simple REST API which handles a post request, no authentification is required. The model ingests … |
Static Methods¶
staticmethod |
truncated documentation |
---|---|
numpy.array cannot be converted into json. We change the type into a list. |
Methods¶
method |
truncated documentation |
---|---|
Checks the sequence load + predict returns something with the given observations. |
|
Documentation¶
Machine Learning Post request
- class lightmlrestapi.mlapp.mlpost_rest.MachineLearningPost(load_function, predict_function, secret=None, folder='.', log_features=True, log_prediction=True, load_params=None, ccall='single', version=None)¶
Bases:
BaseLogging
Implements a simple REST API which handles a post request, no authentification is required. The model ingests a vector X and outputs another one or a number Y. An basic example of an application is given by
dummy_application
.- Parameters:
predict_function – predict function
load_function – load function
secret – see
BaseLogging
folder – see
BaseLogging
log_features – log the features
log_prediction – log the prediction
load_params – given to the loading function
ccall – see below
version – API REST version
Some models can only computes predictions for a sequence of observations, not just one. Parameter ccall defines what the prediction function can ingest. * single: only one observation * multi: only multiple ones * both: the function determines what it must do
- __init__(load_function, predict_function, secret=None, folder='.', log_features=True, log_prediction=True, load_params=None, ccall='single', version=None)¶
- Parameters:
predict_function – predict function
load_function – load function
secret – see
BaseLogging
folder – see
BaseLogging
log_features – log the features
log_prediction – log the prediction
load_params – given to the loading function
ccall – see below
version – API REST version
Some models can only computes predictions for a sequence of observations, not just one. Parameter ccall defines what the prediction function can ingest. * single: only one observation * multi: only multiple ones * both: the function determines what it must do
- _call_convention = {'both': 2, 'multi': 1, 'single': 0}¶
- _load()¶
- _predict_single(obj, features)¶
- check_single(features)¶
Checks the sequence load + predict returns something with the given observations.
- static data2json(data)¶
numpy.array cannot be converted into json. We change the type into a list.
- on_post(req, resp)¶
- Parameters:
req – request
resp –
…