Advertisement
Guest User

Untitled

a guest
May 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 KB | None | 0 0
  1.     Dictionary<double, List<bool?>>[] scores = new Dictionary<double, List<bool?>>[neuralNetworks.Length];
  2.     for (int i = 0; i < scores.Length; i++)
  3.         scores[i] = new Dictionary<double, List<bool?>>();
  4.    
  5.     /*
  6.         for (int j = 0; j < neuralNetworks.Length; j++)
  7.         {
  8.             trimmedOutputs[i] = GetOutputScore(scores[i], outputs[i]) >= threshould
  9.                 ? outputs[i]
  10.                 : 0.0;
  11.         }
  12.     */
  13.    
  14.     private double GetScore(Dictionary<double, List<bool?>> score, double output)
  15.     {
  16.         double outputKey = Math.Round(output, 1);
  17.         if (!score.ContainsKey(outputKey))
  18.             return 1.0;
  19.         bool[] statistics = score[outputKey].Where(stats => stats != null).Cast<bool>().ToArray();
  20.         if (statistics.Length == 0)
  21.             return 1.0;
  22.         return (double)statistics.Where(stats => stats).Count() / statistics.Length;
  23.     }
  24.    
  25.     private void AddScore(Dictionary<double, List<bool?>> score, double output, double exactOutput)
  26.     {
  27.         double outputKey = Math.Round(output, 1);
  28.         bool isCorrectOutput = output >= 0.0 && exactOutput >= 0.0
  29.             || output <= 0.0 && exactOutput <= 0.0;
  30.         bool handled = false;
  31.        
  32.         foreach (double key in score.Keys)
  33.         {
  34.             if (key == outputKey)
  35.             {
  36.                 score[key].Insert(0, isCorrectOutput);
  37.                 handled = true;
  38.             }
  39.             else
  40.                 score[key].Insert(0, null);
  41.            
  42.             if (score[key].Count > 600)
  43.                 score[key] = score[key].Take(600).ToList();
  44.         }
  45.        
  46.         if (!handled)
  47.         {
  48.             score[outputKey] = new List<bool?>();
  49.             score[outputKey].Insert(0, null);
  50.         }
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement