Exemple #1
0
        public DateTime TestSinglePrediction(SingleRow rowToPredict)
        {
            ITransformer trainedModel = mlContext.Model.Load(ModelPath, out var modelInputSchema);

            var predEngine = mlContext.Model.CreatePredictionEngine <SingleRow, DatePrediction>(trainedModel);

            var resultprediction = predEngine.Predict(rowToPredict);


            return(resultprediction.GivePredictedDate(rowToPredict.first_event));
        }
Exemple #2
0
        private static List <SingleRow> readCsvFile(string csvFilePath, int check)
        {
            List <SingleRow> dataInList = new List <SingleRow>();

            Console.WriteLine("Reading .csv file");
            int          i = 0, j = 0, k = 0;
            StreamReader reader = new StreamReader(File.OpenRead(csvFilePath));

            reader.ReadLine();
            string line = reader.ReadLine();

            if (check == 0)
            {
                k = 14000000;
            }
            else if (check == 1)
            {
                k = 5800000;
            }

            while (i < k)
            {
                line = reader.ReadLine();
                if (!string.IsNullOrWhiteSpace(line))
                {
                    Console.WriteLine("Read line no." + i);
                    i++;
                    string[] values = line.Split(',');

                    if (values[8].Equals("PL") && (values[10].Equals("PL")))
                    {
                        SingleRow newRow = new SingleRow(
                            values[4], values[3], values[7],
                            values[9], values[6], values[5]
                            );
                        if (newRow.distance != 0)
                        {
                            j++;
                            dataInList.Add(newRow);
                            Console.WriteLine("Added " + j + " items");
                        }
                    }
                }
            }
            return(dataInList);
        }