Exemplo n.º 1
0
        static void Main(string[] args)
        {
            string currentDirectory  = System.Environment.CurrentDirectory;
            string solutionDirectory = currentDirectory.Substring(0, currentDirectory.IndexOf("ContainerPlanPrediction")) + "ContainerPlanPrediction";
            var    dataDirectory     = solutionDirectory + "\\ContainerPlanPredictionApp\\";
            var    modelDirectory    = solutionDirectory + "\\ContainerPlanPredictionML.Model\\";

            var dataFilePath = Path.Combine(dataDirectory, DATA_FILENAME);

            ModelBuilder.CreateModel(dataFilePath, modelDirectory, ModelBuilder.MODEL_KEY_ROW);
            ModelBuilder.CreateModel(dataFilePath, modelDirectory, ModelBuilder.MODEL_KEY_BAY);

            // Create single instance of sample data from first line of dataset for model input
            ModelInput sampleData = CreateSingleDataSample(dataFilePath);

            ConsumeModel.Initialise(@"C:\Projects\ContainerPlanPrediction\ContainerPlanPredictionML.Model\");

            // Make a single prediction on the sample data and print results
            ModelOutput rowPredictionResult = ConsumeModel.CurrentModel.PredictRow(sampleData);

            ModelOutput bayPredictionResult = ConsumeModel.CurrentModel.PredictBay(sampleData);

            Console.WriteLine("Using model to make single prediction -- Comparing actual Row with predicted Row from sample data...\n\n");
            Console.WriteLine($"Scenario: {sampleData.Scenario}");
            Console.WriteLine($"RouteNumber: {sampleData.RouteNumber}");
            Console.WriteLine($"ContainerType: {sampleData.ContainerType}");
            Console.WriteLine($"ContainerSize: {sampleData.ContainerSize}");
            Console.WriteLine($"ContainerContentType: {sampleData.ContainerContentType}");
            Console.WriteLine($"\n\nActual Row: {sampleData.Row} \nPredicted Row value {rowPredictionResult.Prediction} \nPredicted Row scores: [{String.Join(",", rowPredictionResult.Score)}]\n\n");
            Console.WriteLine($"\n\nActual Bay: {sampleData.Bay} \nPredicted Bay value {bayPredictionResult.Prediction} \nPredicted Bay scores: [{String.Join(",", bayPredictionResult.Score)}]\n\n");
            Console.WriteLine("=============== End of process, hit any key to finish ===============");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public ShippingRoutePredictionService()
        {
            string currentDirectory = System.Environment.CurrentDirectory;
            var    modelDirectory   = currentDirectory.Substring(0, currentDirectory.LastIndexOf("\\")) + "\\ContainerPlanPredictionML.Model\\";

            ConsumeModel.Initialise(modelDirectory);
            ConsumeModel = ConsumeModel.CurrentModel;
        }