ML.NET

编程入门 行业动态 更新时间:2024-10-28 00:22:12
本文介绍了ML.NET - 动态构建管道链的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

使用从?

问候,

宇通

Using code taken from this example.

This code works:

var pipeline = mlContext.Transforms.CopyColumns(outputColumnName: "Label", inputColumnName: "FareAmount") .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "VendorIdEncoded", inputColumnName: "VendorId")) .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "RateCodeEncoded", inputColumnName: "RateCode")) .Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "PaymentTypeEncoded", inputColumnName: "PaymentType")) .Append(mlContext.Transforms.Concatenate("Features", "VendorIdEncoded", "RateCodeEncoded", "PassengerCount", "TripTime", "TripDistance", "PaymentTypeEncoded")) .Append(mlContext.Regression.Trainers.FastTree());

But I would like to Append dynamically at runtime like so:

var pipeline = mlContext.Transforms.CopyColumns(outputColumnName: "Label", inputColumnName: "FareAmount"); pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "VendorIdEncoded", inputColumnName: "VendorId")); pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "RateCodeEncoded", inputColumnName: "RateCode")); pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "PaymentTypeEncoded", inputColumnName: "PaymentType")); pipeline.Append(mlContext.Transforms.Concatenate("Features", "VendorIdEncoded", "RateCodeEncoded", "PassengerCount", "TripTime", "TripDistance", "PaymentTypeEncoded")); pipeline.Append(mlContext.Regression.Trainers.FastTree());

None of the commands after the first have an effect. How can I dynamically chain Appends?

When trying:

var pipeline = mlContext.Transforms.CopyColumns(outputColumnName: "Label", inputColumnName: "FareAmount"); pipeline = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "VendorIdEncoded", inputColumnName: "VendorId")); pipeline = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "RateCodeEncoded", inputColumnName: "RateCode")); pipeline = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "PaymentTypeEncoded", inputColumnName: "PaymentType")); pipeline = pipeline.Append(mlContext.Transforms.Concatenate("Features", "VendorIdEncoded", "RateCodeEncoded", "PassengerCount", "TripTime", "TripDistance", "PaymentTypeEncoded")); pipeline = pipeline.Append(mlContext.Regression.Trainers.FastTree());

I get "Cannot implicitly convert type 'Microsoft.ML.Data.EstimatorChain' to 'Microsoft.ML.Transforms.ColumnCopyingEstimator'" errors I also tried

var pipeline = mlContext.Transforms.CopyColumns(outputColumnName: "Label", inputColumnName: "FareAmount"); var pipeline2 = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "VendorIdEncoded", inputColumnName: "VendorId")); pipeline2 = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "RateCodeEncoded", inputColumnName: "RateCode")); pipeline2 = pipeline.Append(mlContext.Transforms.Categorical.OneHotEncoding(outputColumnName: "PaymentTypeEncoded", inputColumnName: "PaymentType")); var pipeline3 = pipeline2.Append(mlContext.Transforms.Concatenate("Features", "VendorIdEncoded", "RateCodeEncoded", "PassengerCount", "TripTime", "TripDistance", "PaymentTypeEncoded")); var pipeline4 = pipeline3.Append(mlContext.Regression.Trainers.FastTree()); var model = pipeline4.Fit(dataView);

But then on the last line I get an "System.ArgumentOutOfRangeException: 'Could not find input column 'VendorIdEncoded' Parameter name: inputSchema'" error

Any help would appreciated

解决方案

Hi,

Sorry, here is not the right place for ML.NET question. But I think following document should be helpful.docs.microsoft/en-us/dotnet/machine-learning/tutorials/taxi-fare

For more help about your question, could you please post it HERE?

Regards,

Yutong

更多推荐

ML.NET

本文发布于:2023-11-09 10:43:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1572166.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ML   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!