有没有人有关于在非ASP.net的Web应用程序中成功实现Azure ML工作室API的良好文档?我想用Ruby on Rails来运行它,但我猜我得自己摸索了。
回答:
这只是一个REST API调用。看看这个…
data = { "Inputs": { "input1": { "ColumnNames": ["YearBuild", "City", "State", "HomeType", "TaxAssesmentYear", "LotSize", "HomeSize", "NumBedrooms"], "Values": [ [ "0", "Anchorage", "AK ", "Apartment", "0", "0", "0", "0" ], [ "0", "Anchorage", "AK ", "Apartment", "0", "0", "0", "0" ], ] }, }, "GlobalParameters": {}}body = str.encode(json.dumps(data))url = 'https://ussouthcentral.services.azureml.net/workspaces/45aeb4d8283d4be6ae211592f5366af5/services/07ffeeb6fcb84f16bc62cdcf67fd95b3/execute?api-version=2.0&details=true'api_key = 'abc123' # Replace this with the API key for the web serviceheaders = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}req = urllib2.Request(url, body, headers)
可以先用Chrome的Postman应用尝试一下。设置你的头信息,就像上面一样,你的数据以JSON格式放入POST负载中。