使用从?
问候,
宇通
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
发布评论