c# - ML.NET Timeseries ForecastBySsa hoirzon: 7 如何知道未来多少时间是第一个预测?
问题描述
我用于我的预测预测时间序列 mlContext.Forecasting.ForecastBySSA。
现在我想知道下一个预测是从什么时候开始的。
当我使用:
var forecastingPipeline = mlContext.Forecasting.ForecastBySsa(
outputColumnName: "ForecastedFillLevel",
inputColumnName: "FillLevel",
windowSize: 7,
seriesLength: 30,
trainSize: 100,
horizon: 7,
confidenceLevel: 0.95f,
confidenceLowerBoundColumn: "LowerBoundFillLevel",
confidenceUpperBoundColumn: "UpperBoundFillLevel");
它将在未来预测 7 个值,但我想知道预测基于哪个 DateTime。
在我的数据集中,一天中的数据差异与一天中 4-10 个数据行的差异。
现在我使用这段代码。
static void Forecast(IDataView testData, int horizon, TimeSeriesPredictionEngine<ModelInput, ModelOutput> forecaster, MLContext mlContext)
{
ModelOutput forecast = forecaster.Predict();
IEnumerable<string> forecastOutput =
mlContext.Data.CreateEnumerable<ModelInput>(testData, reuseRowObject: false)
.Take(horizon)
.Select((ModelInput Message, int index) =>
{
string rentalDate = Message.DateTime.ToShortDateString();
//float actualRentals = rental.FillLevel;
float lowerEstimate = Math.Max(0, forecast.LowerBoundFillLevel[index]);
float estimate = forecast.ForecastedFillLevel[index];
float upperEstimate = forecast.UpperBoundFillLevel[index];
return $"Date: {rentalDate}\n" +
// $"Actual Rentals: {actualRentals}\n" +
$"Lower Estimate: {lowerEstimate}\n" +
$"Forecast: {estimate}\n" +
$"Upper Estimate: {upperEstimate}\n";
});
// Output predictions
Console.WriteLine("Rental Forecast");
Console.WriteLine("---------------------");
foreach (var prediction in forecastOutput)
{
Console.WriteLine(prediction);
}
}
但是打印出来的 DateTime 是我数据集中的前 7 个日期时间值。预测值很好,并且基于最后的数据行。
所以我的问题是如何为预测打印正确的 DateTime 值
解决方案
推荐阅读
- android - 在 Android Studio 3.2 上找不到 R.java
- javascript - 如果 setState 之前发生过,React 不会触发 onClick
- ruby-on-rails - 记录仅节省 20% 的时间
- jquery - Vanilla Materialize -- AM 选项在 IE 中不可用
- typescript - 如何配置 Webstorm 以使用 Mocha 为全新的 Vue 项目运行 *.spec.ts
- php - SERVER 上的 cURL 调用返回状态码 0
- java - 无法从 Twilio 请求中提取正文
- apache-spark - 基于流的应用程序中的受控/手动错误/恢复处理
- python - 为什么列表的(深)副本比原始列表消耗更多内存?
- bash - macOS launchd 可以运行 bash 脚本吗?