示例#1
0
        public void FindAll()
        {
            Console.WriteLine();
            Console.WriteLine();
            int errorCount = 0;

            foreach (var item in TrainingSet)
            {
                double       min    = double.MaxValue;
                WeatherModel origin = null;
                double       diff   = 0;
                foreach (var elem in DataSet)
                {
                    diff = WeatherModel.ToNormal(item, elem);
                    if (diff < min)
                    {
                        min    = diff;
                        origin = elem;
                    }
                }
                if (origin == null)
                {
                    continue;
                }
                if (origin.RRR == 0 && item.RRR != 0 || origin.RRR != 0 && item.RRR == 0)
                {
                    errorCount++;
                }
                Console.SetCursorPosition(0, Console.CursorTop - 2);
                Console.WriteLine($"ErrorCount {errorCount} of total {TrainingSet.Count}");
                Console.WriteLine($"Prediction precision {(int)((1 - (float)errorCount / TrainingSet.Count) * 100)}" + "%");
            }
        }
示例#2
0
 public static double ToNormal(WeatherModel item1, WeatherModel item2)
 {
     return
         (Math.Pow(item1.T - item2.T, 2) +
          Math.Pow(item1.Po - item2.Po, 2) +
          Math.Pow(item1.P - item2.P, 2) +
          Math.Pow(item1.Pa - item2.Pa, 2) +
          Math.Pow(item1.U - item2.U, 2) +
          Math.Pow(item1.Ef - item2.Ef, 2) +
          Math.Pow(item1.Td - item2.Td, 2) +
          Math.Pow(item1.RRR - item2.RRR, 2));
 }
示例#3
0
        private WeatherModel findMin(WeatherModel item, ref List <WeatherModel> dataSet)
        {
            double       min    = double.MaxValue;
            WeatherModel origin = null;

            foreach (var elem in dataSet)
            {
                var diff = WeatherModel.ToNormal(item, elem);
                if (diff < min)
                {
                    min    = diff;
                    origin = elem;
                }
            }
            return(origin);
        }