2015-05-16 178 views
1

有沒有人有一個很好的文檔,在不是ASP.net的web應用程序中成功實現Azure ML studio API?我想用軌道上的ruby運行它,但我想我必須自己弄清楚。成功使用Azure機器學習API?

+0

如果我的回答可以幫助,請標記爲答案。 –

回答

2

它只是一個休息的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 service 
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)} 

req = urllib2.Request(url, body, headers) 

給你一個嘗試與郵遞員應用程序在鉻第一。設置您的標題,就像上面一樣,您的數據以json格式進入後期有效負載。 enter image description here

0

在這裏,你會發現Ruby代碼(而不是Python)

 data = { 
     'Inputs' => { 
      'input1' => [ 
      { 
       'weekday' => 1, 
       'hour' => 2, 
       'events' => 0 
      } 
      ] 
     }, 
     'GlobalParameters' => {} 
     } 
     body = data.to_json 

     url = 'https://asiasoutheast.services.azureml.net/subscriptions/[tour stuff...]execute?api-version=2.0&format=swagger' 
     api_key = '[your api key]' 
     headers = {'Content-Type': 'application/json', 'Authorization': ('Bearer '+ api_key)} 

     RestClient::Request.execute(method: :post, url: url, payload: body, headers: headers)