用于Python的TotoML SDK
totoml的Python项目详细描述
TotoML Python SDK
这个库是Toto-ML的一个SDK
此库提供以下关键组件:
Model Controller:模型控制器是模型的包装器。它提供:
- restapi来触发训练、评分和预测
- 基于事件的访问(培训、评分、预测)
如何使用它
在你的主python文件中(例如。应用程序),导入ModelController
和ControllerConfig
类,创建一个Flask应用程序,实例化您的模型(在本例中是ERCBOD()
),并将其传递给ModelController构造函数。在
from totoml.controller import ModelController
from totoml.config import ControllerConfig
app = Flask(__name__)
model_controller = ModelController(ERCBOD(), app, ControllerConfig(enable_batch_predictions_events=False, enable_single_prediction_events=False))
为了让模型控制器工作,您必须向它提供您的模型(在示例ERBOCD()
):这里称为模型委托。
ModelDelegate
是由SDK(delegate.ModelDelegate
)提供的^{str1}$抽象类。你的模型必须实现它的方法。
这些方法是:
get_name()
This method has to return the name of the model. This is very important because the name of the model is used for everything in TotoML (internal folders, registry, file storage, etc..), so the name has to be unique.
get_model_type()
Not very used for now. Should return the type of model: sklearn, tf, etc..
Has to be an instance of ModelType
predict()
andpredict_batch()
These methods perform predictions.
score()
This method scores the current champion model: it has to recalculate the metrics for the model and return them
train()
This method performs the training of the model and returns the trained model and all the associated files.
It's important to note that also any file containing training data or built features should be returned, so that Toto ML can grant the persistence of those files and make sure there is lineage.
- 项目
标签: