【问题标题】:How to get the Prediction Score in a HttpResponseMessage provided by a Azure ML Web Service?如何获取 Azure ML Web 服务提供的 HttpResponseMessage 中的预测分数?
【发布时间】:2016-02-22 20:11:57
【问题描述】:

所以我目前正在使用 Azure 机器学习实验。我能够创建一个模型并将其作为 Web 服务发布。我还能够使用创建 Web 服务时生成的 API 文档中提供的 C# 中的示例请求/响应代码获得响应。

我的问题是,Web 服务提供的响应包含许多信息(一长串信息),包括我的 C# 应用程序唯一需要的预测分数。唯一想到的是使用字符串操作方法来提取我想要的信息。但我认为还有比这更好的方法。我是 HTTP 请求/响应的新手,所以请详细说明答案和解释。

这是我的代码:

HttpResponseMessage response = await client.PostAsJsonAsync("", scoreRequest);

if (response.IsSuccessStatusCode)
{
    string result = await response.Content.ReadAsStringAsync();
    Console.WriteLine("Result: {0}", result);
}

else
{
    Console.WriteLine(string.Format("The request failed with status code: {0}", response.StatusCode));

    // Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
    Console.WriteLine(response.Headers.ToString());

    string responseContent = await response.Content.ReadAsStringAsync();
    Console.WriteLine(responseContent);
}

这是响应消息:

{"Results":{"output1":{"type":"table","value":{"ColumnNames":["clump_thickness","size_uniformity","shape_uniformity","marginal_adhesion","epithelial_size","bare_nucleoli","bland_chromatin","normal_nucleoli","mitoses","Scored Labels","Scored Probabilities"],"ColumnTypes":["Int32","Int32","Int32","Int32","Int32","Nullable`1","Int32","Int32","Int32","Double","Double"],"Values":[["10","10","4","8","1","8","3","10","1","1","0.979712069034576"],["10","10","4","8","1","8","3","10","1","1","0.979712069034576"]]}}}}

我只想要“Values”中的值:[[...]],在这种情况下,第 9 个索引或“1”。

【问题讨论】:

    标签: c# cortana-intelligence azure-machine-learning-studio


    【解决方案1】:

    您需要在 AML 实验中使用项目列。目前,您有一个连接到 Web 服务输出的模块。在您的web service output 之前使用project columns 模块来选择您想要发送到我们的输出的列。

    【讨论】:

    • 哦,是的,这个想法在我脑海中闪现。谢谢!这解决了我的问题。
    【解决方案2】:

    此外,您可以取消选中分数模块的“附加列”属性,如下所示。这将只生成标签和概率列

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-24
      • 1970-01-01
      • 1970-01-01
      • 2018-01-30
      • 1970-01-01
      • 2019-02-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多