module mlapp.mlpost_rest

Inheritance diagram of lightmlrestapi.mlapp.mlpost_rest

Short summary

module lightmlrestapi.mlapp.mlpost_rest

Machine Learning Post request

source on GitHub

Classes

class

truncated documentation

MachineLearningPost

Implements a simple REST API which handles a post request, no authentification is required. The model ingests …

Static Methods

staticmethod

truncated documentation

data2json

numpy.array cannot be converted into json. We change the type into a list.

Methods

method

truncated documentation

__init__

_load

_predict_single

check_single

Checks the sequence load + predict returns something with the given observations.

on_post

Documentation

Machine Learning Post request

source on GitHub

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.

source on GitHub

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

source on GitHub

__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

source on GitHub

_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.

source on GitHub

static data2json(data)

numpy.array cannot be converted into json. We change the type into a list.

source on GitHub

on_post(req, resp)
Parameters:
  • req – request

  • resp

source on GitHub