public int PredictionEnTransformXor(Foreseer foreseer) { IntField orig = this.Clone(); foreseer.Initialize(orig); int wrongPredictions = 0; int p = 0; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++, p++) { int predicted = foreseer.Foresee(orig, x, y); Data[p] = orig.Data[p] ^ predicted; if (Data[p] != 0) { wrongPredictions++; } foreseer.Learn(orig, x, y, orig.Data[p], predicted); } } return(wrongPredictions); }
public override void Learn(IntField image, int x, int y, int actual, int predicted) { _fallback.Learn(image, x, y, actual, predicted); foreach (var area in _curAreas) { ColorFrequencies cf; if (!_history.TryGetValue(area, out cf)) { _history.Add(area, cf = new ColorFrequencies()); } cf.Learn(actual); } }
public override void Learn(IntField image, int x, int y, int actual, int predicted) { if (_curArea == null) { _fallback.Learn(image, x, y, actual, predicted); return; } if (!_history.ContainsKey(_curArea)) { _history.Add(_curArea, new ColorFrequencies()); } _history[_curArea].Learn(actual); }
public void PredictionDeTransformXor(Foreseer foreseer) { IntField diff = this.Clone(); foreseer.Initialize(this); int p = 0; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++, p++) { int predicted = foreseer.Foresee(this, x, y); Data[p] = diff.Data[p] ^ predicted; foreseer.Learn(this, x, y, this.Data[p], predicted); } } }
public void Prediction(Foreseer foreseer) { IntField orig = this.Clone(); foreseer.Initialize(orig); int p = 0; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++, p++) { int predicted = foreseer.Foresee(orig, x, y); Data[p] = predicted; foreseer.Learn(orig, x, y, orig.Data[p], predicted); } } }
public void PredictionEnTransformDiff(Foreseer foreseer, int modulus) { IntField orig = this.Clone(); foreseer.Initialize(orig); int p = 0; for (int y = 0; y < Height; y++) { for (int x = 0; x < Width; x++, p++) { int predicted = foreseer.Foresee(orig, x, y); Data[p] = orig.Data[p] - predicted; if (Data[p] < 0) { Data[p] += modulus; } foreseer.Learn(orig, x, y, orig.Data[p], predicted); } } }
public override void Learn(IntField image, int x, int y, int actual, int predicted) { if (_curArea == null) { _fallback.Learn(image, x, y, actual, predicted); return; } if (!_history.ContainsKey(_curArea)) { _history.Add(_curArea, new outcomes()); } if (actual == _curMostFreqSymbol) { _history[_curArea].MostFrequent++; } else { _history[_curArea].Other++; } }