ploomber.OnlineModel¶
- class ploomber.OnlineModel(module)¶
A subclass of
ploomber.OnlineDAGto provider a simpler interface for online DAGs whose terminal task callsmodel.predict.OnlineModelis initialized with a module following a standard structure. Looks for apipeline-features.yamlin the module’s root directory (e.g.src/my_module/pipeline-features.yaml), amodel.picklein the module’s root directory. The terminal task is executed with amodelparameter which contains the load model and callsmodel.predict. The last task inpipeline-features.yamlshould be namedfeatures.See here for a complete example: https://github.com/ploomber/projects/blob/master/templates/ml-online/src/ml_online/infer.py
- Parameters:
module – A module following a standard structure
Examples
>>> import my_module >>> model = OnlineModel(my_module) >>> model.predict(x=some_input)
Methods
Must return the location of a partial dag (str or pathlib.Path)
init_dag_from_partial(partial)Initialize partial returned by get_partial()
predict(**kwargs)Returns the output of
model.predict(upstream['features'])Must return a dictionary with parameters passed to
terminal_taskterminal_task(upstream, model)Las function to execute.
- get_partial()¶
Must return the location of a partial dag (str or pathlib.Path)
- classmethod init_dag_from_partial(partial)¶
Initialize partial returned by get_partial()
- predict(**kwargs)¶
Returns the output of
model.predict(upstream['features'])
- terminal_params()¶
Must return a dictionary with parameters passed to
terminal_task
- static terminal_task(upstream, model)¶
Las function to execute. The
upstreamparameter contains the output of all tasks that have no downstream dependencies