我是 ML.NET 初学者,我的数据有点问题。当我把它们放在mlContext.Fit(...)中时;这是我收到的错误:Column 'Temperature' has values of I4which is not the same as earlier observed type of R4.这是我的代码:try { var mlContext = new MLContext(); var reader = mlContext.Data.CreateTextReader<TrainData>(separatorChar: ',', hasHeader: false); var trainData = _context.Datas.Last(); IDataView trainingdataView = reader.Read(Path.Combine(hostingEnvironment.WebRootPath, "data010220192341.txt")); var pipeline = mlContext.Transforms.Conversion.MapValueToKey("Delay") .Append(mlContext.Transforms.Categorical.OneHotEncoding("StationDepart")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("StationArrival")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("Day")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("Train")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("WeatherText")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("HasPrecipitation")) .Append(mlContext.Transforms.Categorical.OneHotEncoding("PrecipitationType")) .Append(mlContext.Transforms.Concatenate("Features", "StationDepart", "StationArrival", "Day", "Train", "WeatherText", "Temperature", "Humidity", "HasPrecipitation", "PrecipitationType", "Time")) .Append(mlContext.MulticlassClassification.Trainers.StochasticDualCoordinateAscent(labelColumn: "Delay", featureColumn: "Features")) .Append(mlContext.Transforms.Conversion.MapKeyToValue("PredictedTime")); var model = pipeline.Fit(trainingdataView); var prediction = model.CreatePredictionEngine<TrainData, TrainPrediction>(mlContext).Predict(
1 回答
守着一只汪
TA贡献1872条经验 获得超3个赞
问题在于时间,延迟和温度需要处于浮动状态,而不是整数。
public class TrainData { [LoadColumn(0)] public string StationDepart { get; set; } [LoadColumn(1)] public string StationArrival { get; set; } [LoadColumn(2)] public string Day { get; set; } [LoadColumn(3)] public string Train { get; set; } [LoadColumn(4)] public string WeatherText { get; set; } [LoadColumn(5)] public float Temperature { get; set; } [LoadColumn(6)] public float Humidity { get; set; } [LoadColumn(7)] public bool HasPrecipitation { get; set; } [LoadColumn(8)] public string PrecipitationType { get; set; } [LoadColumn(9)] public float Time { get; set; } [LoadColumn(10)] public float Delay { get; set; } }
- 1 回答
- 0 关注
- 67 浏览
添加回答
举报
0/150
提交
取消