Use this code block to create a prediction service. The model created after executing a flow will be exposed as an API and is used to make predictions on the latest dataset.
prediction_service = PredictionService.create_service(
name=service_name,
description="testing purposes",
model_name=model_name, #this is exposing the model that you have created before
service_obj_path="prediction_services/model.py",
env_id=None,
data_source_ids=None
)
prediction_service.id
Fetching all models
Use this code block to fetch all the models created under the tenant.
PredictionService.get_all_models()
['modelname', 'outputModelName', 'rf_model']
Deleting a prediction service
Use this code block to delete the existing prediction service.
INFO:Model file downloaded successfully! to /home/jovyan/sample_projects/example_ml_pipeline/artifacts-meta.json
INFO:Model file downloaded successfully! to /home/jovyan/sample_projects/example_ml_pipeline/cols_list.pkl
INFO:Model file downloaded successfully! to /home/jovyan/sample_projects/example_ml_pipeline/model.pkl
INFO:Model file downloaded successfully! to /home/jovyan/sample_projects/example_ml_pipeline/random_forest.pkl
Deleting a model
Use this code block to delete a model. You can only delete a model after deleting the associated recipes.
PredictionService.delete_model('model_name')
Sample code:
PredictionService.delete_model('rf_model')
Updating the prediction service details
Use this code block to update the prediction service details.
PredictionService.update_service(
service_id='d1661aec-1867-4122-bda9-78f996bff0f0',
name=service_name,
description="testing purposes1",
model_name=model_name, #this is exposing the model that you have created before
env_id=None,
data_source_ids=None
)