Example #1
0
 internal Dictionary<string, double> Test_scaleProbabilitiesToInfinity(int[][] p)
 {
     Dictionary<string, double> probabilities = new Dictionary<string, double>();
     foreach (var fType in features.Keys) {
         foreach (var f in features[fType]) {
             var results = f.Test(p);
             if (!f.Trained() || results == null) continue;
             foreach (var r in results) {
                 if (!probabilities.ContainsKey(r.Key)) {
                     probabilities[r.Key] = 0;
                 }
                 double val1 = probabilisticWeight(f.SuccessRate.LabelSuccess[r.Key].LastN(), 10);
                 double newVal = probabilities[r.Key] += r.Value * val1;
                 if (double.IsNaN(newVal) || double.IsInfinity(newVal)) {
                     throw new Exception();
                 }
                 probabilities[r.Key] = newVal;
             }
         }
     }
     this.LastProbabilities = probabilities.Normalize(totalVal: null);
     return LastProbabilities;
 }
Example #2
0
 internal Dictionary<string, double> Test(int[][] p)
 {
     Dictionary<string, double> probabilities = new Dictionary<string, double>();
     double eps = 1e-8;
     foreach (var fType in features.Keys) {
         foreach (var f in features[fType]) {
             var results = f.Test(p);
             if (!f.Trained() || results == null) continue;
             if (f.CreationIndex <= 785 && !usePixelFeatures.Value) continue;
             foreach (var r in results) {
                 if (!probabilities.ContainsKey(r.Key)) {
                     probabilities[r.Key] = 0;
                 }
                 if (weighFeaturesOnSuccess) {
                     if (f.SuccessRate.LabelSuccess.ContainsKey(r.Key) && f.IsTrained) {
                         //double success = f.SuccessRate.LabelSuccess[r.Key].LastN();
                         double success = f.SuccessRate.Outcomes.Get(r.Value);
                         double error = 1 - success;
                         double alpha = .5 * Math.Log((9.0 - 9 * error) / (error + .01) + .01);
                         probabilities[r.Key] += r.Value * alpha;
                     } else {
                         probabilities[r.Key] += rand.NextDouble();
                     }
                 } else {
                     //var acc = f.SuccessRate.Outcomes.Get(r.Value);
                     //probabilities[r.Key] += r.Value * acc;
                     probabilities[r.Key] += r.Value;
                 }
             }
         }
     }
     this.LastProbabilities = probabilities.Normalize(totalVal: null);
     return LastProbabilities;
 }
Example #3
0
 internal Dictionary<string, double> Test3(int[][] p)
 {
     Dictionary<string, int> probabilities = new Dictionary<string, int>();
     foreach (var fType in features.Keys) {
         foreach (var f in features[fType]) {
             var results = f.Test(p);
             if (!f.Trained() || results == null) continue;
             string guess = results.MaxLabel();
             if (!probabilities.ContainsKey(guess)) {
                 probabilities[guess] = 0;
             }
             probabilities[guess]++;
         }
     }
     this.LastProbabilities = probabilities.Normalize();
     return LastProbabilities;
 }
Example #4
0
 internal Dictionary<string, double> Test(int[][] p)
 {
     Dictionary<string, double> probabilities = new Dictionary<string, double>();
     foreach (var f in features) {
         var results = f.Test(p);
         if (!f.Trained() || results == null) continue;
         if (f.CreationIndex <= 785 && !usePixelFeatures.Value) continue;
         foreach (var r in results) {
             if (!probabilities.ContainsKey(r.Key)) {
                 probabilities[r.Key] = 0;
             }
             probabilities[r.Key] += r.Value;
         }
     }
     this.LastProbabilities = probabilities.Normalize(totalVal:null);
     return LastProbabilities;
 }