azureml-workshop-2019
azureml-workshop-2019 copied to clipboard
[Paper-Cut:UI] Model Deployment from UI doesn't help on how to consume the model
Once the model is deployed into AML compute, the UI doesn't help much on how to consume it and try the service. It simply provides an URI, but a user who just deployed it won't be able to try it unless he invests time on researching docs from scratch.
This is a clear paper-cut because it is blocking the path for a fast getting started experience.
This is the only info provided so far for consumption:
That "Consume" page section should help on sample code on the following areas and showing client code for Python apps, .NET apps, Java apps, Node-JS apps, etc.:
- End-user app consuming the model service end-point (web app, etc.)
- How to load the service object from the URI
- How to consume it with sample data and code similar to the following:
import json
import pandas as pd
# the sample below contains the data for an employee that is not an attrition risk
sample = pd.DataFrame(data=[{'Age': 41, 'BusinessTravel': 'Travel_Rarely', 'DailyRate': 1102, 'Department': 'Sales', 'DistanceFromHome': 1, 'Education': 2, 'EducationField': 'Life Sciences', 'EnvironmentSatisfaction': 2, 'Gender': 'Female', 'HourlyRate': 94, 'JobInvolvement': 3, 'JobLevel': 2, 'JobRole': 'Sales Executive', 'JobSatisfaction': 4, 'MaritalStatus': 'Single', 'MonthlyIncome': 5993, 'MonthlyRate': 19479, 'NumCompaniesWorked': 8, 'OverTime': 'No', 'PercentSalaryHike': 11, 'PerformanceRating': 3, 'RelationshipSatisfaction': 1, 'StockOptionLevel': 0, 'TotalWorkingYears': 8, 'TrainingTimesLastYear': 0, 'WorkLifeBalance': 1, 'YearsAtCompany': 6, 'YearsInCurrentRole': 4, 'YearsSinceLastPromotion': 0, 'YearsWithCurrManager': 5}])
# converts the sample to JSON string
sample = pd.DataFrame.to_json(sample)
# deserializes sample to a python object
sample = json.loads(sample)
# serializes sample to JSON formatted string as expected by the scoring script
sample = json.dumps({"data":sample})
prediction = service.run(sample)
print(prediction)
filed a bug: https://msdata.visualstudio.com/Vienna/_workitems/edit/583745