C# ML.Net数组数据输入
我很难通过使用Microsoft.ML输入每日销售数据来预测每月销售C# ML.Net数组数据输入,c#,machine-learning,prediction,ml.net,C#,Machine Learning,Prediction,Ml.net,我很难通过使用Microsoft.ML输入每日销售数据来预测每月销售 class Data { [Column(ordinal: "0", name: "Label")] public float PredictedProfit; [Column(ordinal: "Month")] public int Month; [Column(ordinal:
class Data
{
[Column(ordinal: "0", name: "Label")]
public float PredictedProfit;
[Column(ordinal: "Month")]
public int Month;
[Column(ordinal: "DayOfMonth")]
public int DayOfMonth;
[Column(ordinal: "Sales")]
public double[] Sales;
[Column(ordinal: "MonthlyProfit")]
public double MonthlyProfit;
}
...........................
MLContext mlContext = new MLContext(seed: 0);
List<VData> listData;
VData row=new VData();
.....
fill row
.....
listData.Add(row);
var trainData = mlContext.CreateStreamingDataView<VData>(listData);
var pipeline = mlContext.Transforms.CopyColumns("Label", "MonthlyProfit");
pipeline.Append(mlContext.Transforms.Concatenate("Features", "MonthlyProfit", "Sales", "Month", "DayOfMonth");
pipeline.Append(mlContext.Regression.Trainers.FastTree());
var model = pipeline.Fit(trainData);
var dataView = mlContext.CreateStreamingDataView<VData>(listData);
var predictions = model.Transform(dataView);
var metrics = mlContext.Regression.Evaluate(predictions, "Label", "MonthlyProfit");
metrics值始终为零,并且ML.NET中没有不可变的预测数据管道:对pipeline.Append的调用返回新的更新管道,但不更改原始管道 修改代码以执行以下操作:
var pipeline = mlContext.Transforms.CopyColumns("Label", "MonthlyProfit");
pipeline = pipeline.Append(mlContext.Transforms.Concatenate("Features", "MonthlyProfit", "Sales", "Month", "DayOfMonth");
pipeline = pipeline.Append(mlContext.Regression.Trainers.FastTree());
此外,您正在使用的[Column]属性没有任何效果。要更改标签列的名称,可以使用[ColumnNameLabel]。所有其他属性都是完全不必要的。哪个版本的ml.net?创建trainData时,listData的内容是什么或至少是其中的一部分?我使用的是1.0版