问题
In Azure ML Studio, we have the option of choosing a number of inbuilt ML models like Classification, Regression, etc. , which we can drag and drop to our workflow.
My question is, can I upload a custom ML model that I have built locally on my system in Python, and add it to the workflow?
回答1:
- Take the model.pkl file, zip it, and upload it into Azure Machine Learning Studio. Click the “New” icon in the bottom left:
- In the pane that comes up, click on dataset, and then “From Local File”:
- Select the zip file where you stored your serialized model and click the tick. You expirement should look like this:
- Put the following code to run your classification experiment:
import pandas as pd
import sys
import pickle
def azureml_main(dataframe1 = None, dataframe2 = None):
sys.path.insert(0,".\Script Bundle")
model = pickle.load(open(".\Script Bundle\model.pkl", 'rb'))
pred = model.predict(dataframe1)
return pd.DataFrame([pred[0]])
Update If you want to declare this experiment as an API you need to add web input and output to the Python script module.
回答2:
You might be able to achieve this using the "Execute Python Code" module. See here for documentation: https://docs.microsoft.com/en-us/azure/machine-learning/studio-module-reference/execute-python-script
There you can upload contents in a zip bundle file. If you include your trained model there, you might be good to go.
来源:https://stackoverflow.com/questions/57488706/deploying-custom-model-on-azure-ml-studio