Skip to content

Commit 658f013

Browse files
authored
Update TaxiFare to ML.NET v1.0.0 (#872)
1 parent 0cf6ed0 commit 658f013

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

machine-learning/tutorials/TaxiFarePrediction/Program.cs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static void Main(string[] args)
3131
// </Snippet14>
3232

3333
// <Snippet20>
34-
TestSinglePrediction(mlContext);
34+
TestSinglePrediction(mlContext, model);
3535
// </Snippet20>
3636
}
3737

@@ -66,7 +66,6 @@ public static ITransformer Train(MLContext mlContext, string dataPath)
6666
Console.WriteLine("=============== End of training ===============");
6767
Console.WriteLine();
6868
// <Snippet12>
69-
SaveModelAsFile(mlContext, dataView.Schema, model);
7069
return model;
7170
// </Snippet12>
7271
}
@@ -98,17 +97,12 @@ private static void Evaluate(MLContext mlContext, ITransformer model)
9897

9998
}
10099

101-
private static void TestSinglePrediction(MLContext mlContext)
100+
private static void TestSinglePrediction(MLContext mlContext, ITransformer model)
102101
{
103-
//load the model
104-
// <Snippet21>
105-
ITransformer loadedModel = mlContext.Model.Load(_modelPath, out var modelInputSchema);
106-
// </Snippet21>
107-
108102
//Prediction test
109103
// Create prediction function and make prediction.
110104
// <Snippet22>
111-
var predictionFunction = mlContext.Model.CreatePredictionEngine<TaxiTrip, TaxiTripFarePrediction>(loadedModel);
105+
var predictionFunction = mlContext.Model.CreatePredictionEngine<TaxiTrip, TaxiTripFarePrediction>(model);
112106
// </Snippet22>
113107
//Sample:
114108
//vendor_id,rate_code,passenger_count,trip_time_in_secs,trip_distance,payment_type,fare_amount
@@ -134,14 +128,5 @@ private static void TestSinglePrediction(MLContext mlContext)
134128
Console.WriteLine($"**********************************************************************");
135129
// </Snippet25>
136130
}
137-
138-
private static void SaveModelAsFile(MLContext mlContext,DataViewSchema dataViewSchema, ITransformer model)
139-
{
140-
// <Snippet13>
141-
mlContext.Model.Save(model, dataViewSchema, _modelPath);
142-
// </Snippet13>
143-
144-
Console.WriteLine("The model is saved to {0}", _modelPath);
145-
}
146131
}
147132
}

machine-learning/tutorials/TaxiFarePrediction/TaxiFarePrediction.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
<TargetFramework>netcoreapp2.2</TargetFramework>
66
</PropertyGroup>
77

88
<PropertyGroup>
99
<LangVersion>7.1</LangVersion>
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.ML" Version="1.0.0-preview" />
14-
<PackageReference Include="Microsoft.ML.FastTree" Version="1.0.0-preview" />
13+
<PackageReference Include="Microsoft.ML" Version="1.0.0" />
14+
<PackageReference Include="Microsoft.ML.FastTree" Version="1.0.0" />
1515
</ItemGroup>
1616

1717
<ItemGroup>

0 commit comments

Comments
 (0)