2

所以我目前正在使用 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”。

4

2 回答 2

1

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

于 2016-02-22T23:54:32.737 回答
1

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

只有分数标签和概率的分数模块

于 2016-02-23T04:20:06.917 回答