I'm very new to machine learning and I've stumbled upon the following problem. Considering an official NYC Taxi fare amount prediction tutorial, let's say I'd like to predict another real value, e.g. TripTime
. I've modified my code as follows:
public class TripFarePrediction // this class is used to store prediction result
{
[ColumnName("Score")]
public float FareAmount { get; set; }
[ColumnName("Score2")]
public float TripTime { get; set; }
}
private static ITransformer Train(MLContext mlContext, string trainDataPath)
{
IDataView dataView = _textLoader.Read(trainDataPath);
var pipelineForTripTime = mlContext.Transforms.CopyColumns("Label", "TripTime")
.Append(mlContext.Transforms.Categorical.OneHotEncoding("VendorId"))
.Append(mlContext.Transforms.Categorical.OneHotEncoding("RateCode"))
.Append(mlContext.Transforms.Categorical.OneHotEncoding("PaymentType"))
.Append(mlContext.Transforms.Concatenate("Features", "VendorId", "RateCode", "PassengerCount", "TripDistance", "PaymentType"))
.Append(mlContext.Regression.Trainers.FastTree());
var pipelineForFareAmount = mlContext.Transforms.CopyColumns("Label", "FareAmount")
.Append(mlContext.Transforms.Categorical.OneHotEncoding("VendorId"))
.Append(mlContext.Transforms.Categorical.OneHotEncoding("RateCode"))
.Append(mlContext.Transforms.Categorical.OneHotEncoding("PaymentType"))
.Append(mlContext.Transforms.Concatenate("Features", "VendorId", "RateCode", "PassengerCount", "TripDistance", "PaymentType"))
.Append(mlContext.Regression.Trainers.FastTree());
var model = pipelineForTripTime.Append(pipelineForFareAmount).Fit(dataView);
SaveModelAsFile(mlContext, model);
return model;
}
The first value (FareAmount
) is predicted 'correctly' (value is other than zero), but the second one (TripTime
) is zero. My question is how do I predict two or more labels at once or at least using the same model? Is this even possible? I'm using .NET Core 2.2 and ML.NET 0.10.0 to accomplish this task. Thank you in advance for any help.