ノーコードで予測分析を実施してみました。
モデルのランキングは、RMSEがNO1は、StackEnsemble
使用したアルゴリズムです。
デプロイしてSwaggerでI/Fを確認
クライントロジックの作成
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace MLWebServiceClient
{
internal class InputData
{
[JsonProperty("data")]
internal Request[] Data;
}
// The data structure expected by the service
internal class Request
{
[JsonProperty("instant")]
// The service used by this example expects an array containing
// one or more arrays of doubles
internal int Instant;
[JsonProperty("date"), JsonConverter(typeof(CustomDateTimeConverter))]
internal DateTime Date;
[JsonProperty("season")]
internal int Season;
[JsonProperty("yr")]
internal int Year;
[JsonProperty("mnth")]
internal int Month;
[JsonProperty("weekday")]
internal int Weekday;
[JsonProperty("weathersit")]
internal int Weathersit;
[JsonProperty("temp")]
internal double Temp;
[JsonProperty("atemp")]
internal double ATemp;
[JsonProperty("hum")]
internal double Hum;
[JsonProperty("windspeed")]
internal double Windspeed;
}
class CustomDateTimeConverter : IsoDateTimeConverter
{
public CustomDateTimeConverter()
{
base.DateTimeFormat = "yyyy-MM-dd HH:mm:ss,ffffff";
}
}
class Program
{
static void Main(string[] args)
{
Health();
Score();
Console.ReadKey();
}
private static void Health()
{
// Set the scoring URI and authentication key or token
string scoringUri = "http://baeab633-xxxx-xxxx-xxxx-6b4317bfbbdf.westus.azurecontainer.io/";
HttpClient client = new HttpClient();
try
{
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(scoringUri));
request.Content = new StringContent("");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var response = client.GetAsync(new Uri(scoringUri));
Console.WriteLine(response.Result);
}
catch (Exception e)
{
Console.Out.WriteLine(e.ToString());
}
}
private static void Score()
{
// Set the scoring URI and authentication key or token
string scoringUri = "http://baeab633-xxxx-xxxx-xxxx-6b4317bfbbdf.westus.azurecontainer.io/score";
string authKey = "<your key or token>";
// Set the data to be sent to the service.
// In this case, we are sending two sets of data to be scored.
InputData payload = new InputData
{
Data = new[] {
new Request
{
Instant = 732,
Date = new DateTime(2013, 1, 1),
Season = 1,
Year = 2,
Month = 1,
Weekday = 5,
Weathersit = 2,
Temp = 0.215833,
ATemp = 0.223487,
Hum = 0.5775,
Windspeed = 0.154846,
}}
};
// Create the HTTP client
HttpClient client = new HttpClient();
// Set the auth header. Only needed if the web service requires authentication.
//client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authKey);
// Make the request
try
{
Console.WriteLine(JsonConvert.SerializeObject(payload));
var content = new StringContent(JsonConvert.SerializeObject(payload));
content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
var response = client.PostAsync(new Uri(scoringUri), content).Result;
// Display the response from the web service
Console.WriteLine(response.Content.ReadAsStringAsync().Result);
}
catch (Exception e)
{
Console.Out.WriteLine(e.ToString());
}
}
}
}
処理した結果