Azure机器学习工作室Web服务API无法从R(http2框架层)加载结果

时间:2019-03-13 00:40:23

标签: r azure api shiny

我正在通过在azure ML中训练模型来做机器学习解决方案。然后,我的建议是使用Azure ML中配置的api密钥实时获取预测结果。自从我添加了这一部分以来,通过闪亮的可视化效果会不断出现错误。它正在ubuntu服务器中运行。

出现在列表中的特征是带有样本插补的模型的特征。

错误说:http2框架层。

    library("RCurl")
    library("rjson")

    # Accept SSL certificates issued by public Certificate Authorities
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))

h = basicTextGatherer()
hdr = basicHeaderGatherer()

req =  list(
  Inputs = list(
    "input1"= list(
      list(
        'CORRESPON' = "0",
        'HORA' = "13",
        'GRUPO' = "",
        'dewPoint' = "40.53",
        'precipType' = "NA",
        'DIA_Semana' = "Jueves",
        'DIA_mes' = "11",
        'Municipio' = "Almeria",
        'Total_Ambos' = "189880",
        'Comunidad' = "Andalucia",
        'Provincia' = "Almeria"
      )
    )
  ),
  GlobalParameters = setNames(fromJSON('{}'), character(0))
)

body = enc2utf8(toJSON(req))
api_key = "set-your-api-key" # Replace this with the API key for the web service
authz_hdr = paste('Bearer', api_key, sep=' ')

h$reset()
curlPerform(url = "https://ussouthcentral.services.azureml.net/workspaces/cc79cb484e71444e8f7cbe8bc07fdc94/services/5790601c0f4a482d9e8a9f566359320f/execute?api-version=2.0&format=swagger",
            httpheader=c('Content-Type' = "application/json", 'Authorization' = authz_hdr),
            postfields=body,
            writefunction = h$update,
            headerfunction = hdr$update,
            verbose = TRUE
)

headers = hdr$value()
httpStatus = headers["status"]
if (httpStatus >= 400)
{
  print(paste("The request failed with status code:", httpStatus, sep=" "))

  # Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
  print(headers)
}

print("Result:")
result = h$value()
print(fromJSON(result))
顺便说一句,

我想知道,从R进行输入时是否有任何可能的方法来添加更多输入。我试图复制一个input2(如上面出现的input1)并传递矢量,但是没有尝试得到任何结果。

0 个答案:

没有答案