'How can I use a ML model trained with Google Vertex AI with scikit learn?

I have a problem with Vertex AI. I have trained a model using the API for Vertex AI in Python. After the training, I want to retrieve the model and use it as a model obtained with a scikit-learn regressor. In particular, I have to use the library "lime" which has a method to find explanations for a particular prediction.

This is the code for finding the model with Vertex AI API.

model = dag.run(
    dataset=my_dataset,
    target_column="t",
    training_fraction_split=0.6,
    validation_fraction_split=0.2,
    test_fraction_split=0.2,
    budget_milli_node_hours=1000,
    model_display_name="model_"+TIMESTAMP,
    disable_early_stopping=False,
)

And this is the function I have to use: https://lime-ml.readthedocs.io/en/latest/lime.html#module-lime.lime_tabular

As you can see it requires the training data and then in the part of the explain_instance function, it requires the prediction function of the model.

I know that I can obtain the model in this way:

model = aiplatform.Model("path to my model")

But how I can obtain the prediction function from the model trained with AutoML? Thank you!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source