@@ -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}
0 commit comments