public void TrainAndValidate() { var clusterSizes = new int[] { 10, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 2000 }; CSVWriter csvWriter = new CSVWriter(@"..\..\testdata\validations.csv", ";"); Console.WriteLine("Writing validation results to validations.csv"); foreach (var driver in drivers) { var currentTrips = trips.Where(t => t.DriverId.Equals(driver)); for (int i = 1; i < currentTrips.Count() - 1; i++) { List<TripSummary> trainingSet = new List<TripSummary>(); List<TripSummary> validationSet = new List<TripSummary>(); int j = 0; foreach (var trip in currentTrips) { if (j++<i) { trainingSet.Add(trip); } else { validationSet.Add(trip); } } foreach (var clusterSize in clusterSizes) { RoutePrediction routePrediction = new RoutePrediction(clusterSize); RoutePredictionValidationResult result = routePrediction.TrainAndValidate(trainingSet, validationSet); csvWriter.WriteRow(driver, clusterSize, trainingSet.Count(), validationSet.Count(), result.Validations); } } } Console.WriteLine("done"); }
public void TrainAndValidate() { var clusterSizes = new int[] { 10, 100, 150, 200, 250, 300, 400, 500, 750, 1000, 2000 }; CSVWriter csvWriter = new CSVWriter(@"..\..\testdata\validations.csv", ";"); Console.WriteLine("Writing validation results to validations.csv"); foreach (var driver in drivers) { var currentTrips = trips.Where(t => t.DriverId.Equals(driver)); for (int i = 1; i < currentTrips.Count() - 1; i++) { List <TripSummary> trainingSet = new List <TripSummary>(); List <TripSummary> validationSet = new List <TripSummary>(); int j = 0; foreach (var trip in currentTrips) { if (j++ < i) { trainingSet.Add(trip); } else { validationSet.Add(trip); } } foreach (var clusterSize in clusterSizes) { RoutePrediction routePrediction = new RoutePrediction(clusterSize); RoutePredictionValidationResult result = routePrediction.TrainAndValidate(trainingSet, validationSet); csvWriter.WriteRow(driver, clusterSize, trainingSet.Count(), validationSet.Count(), result.Validations); } } } Console.WriteLine("done"); }