Exemple #1
0
        /// <summary>
        /// This method demonstrates how to run prediction on one example at a time.
        /// </summary>
        public StockPrediction Predict(string modelPath, string date, float price, float NetBuyVolume)
        {
            // Load model
            var predictionEngine = CreatePredictionEngineAsync(modelPath);

            // Build country sample
            var countrySample = new StockPredictionData(date, price, NetBuyVolume);

            // Returns prediction
            return(predictionEngine.Predict(countrySample));
        }
        /// <summary>
        /// Predict samples using saved model
        /// </summary>
        /// <param name="outputModelPath">Model file path</param>
        /// <returns></returns>
        public void TestPrediction(string outputModelPath = "country_month_fastTreeTweedie.zip")
        {
            Console.WriteLine("*********************************");
            Console.WriteLine("Testing country forecasting model");

            // Read the model that has been previously saved by the method SaveModel
            var model = PredictionModel.ReadAsync <StockPredictionData, StockPrediction>(outputModelPath).Result;

            // Build sample data
            var dataSample = new StockPredictionData()
            {
                date = "21/8/2018",
                //price=10.23f,
                NetBuyVolume = 1000f
            };
            // Predict sample data
            var prediction = model.Predict(dataSample);

            Console.WriteLine($"date: {dataSample.date}, - Real value (US$): {dataSample.price}, Forecasting (US$): {prediction.price}");
        }