Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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);
                }
            }
        }
Exemplo n.º 5
0
        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);
                }
            }
        }
Exemplo n.º 6
0
        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);
                }
            }
        }
Exemplo n.º 7
0
        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++;
            }
        }