Prediction Service

Prediction service

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.

PredictionService.delete_service_by_id('service_id')

Sample code:

PredictionService.delete_service_by_id('fd4c51b0-f9e1-49eb-810d-ec607aa8561e')

Download models

Use this code block to download the model.

PredictionService.download_model('model_name')

Sample code:

PredictionService.download_model('rf_model')

Example output:

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
)

Last updated