Exemplo n.º 1
0
        private PerceptronTrainerStepPrediction TrainStepPredict()
        {
            State = PerceptronTrainerState.Training;
            PerceptronTrainerStepPrediction result = new PerceptronTrainerStepPrediction();

            PerceptronTrainerDatapoint CurrentDatapoint = Datapoints[CurrentTrainStep];

            if (CurrentDatapoint.IsPositive)
            {
                result.DataPoint           = CurrentDatapoint.Datapoint;
                result.isPositiveDatapoint = true;
                if (BiasedLearning)
                {
                    return(PredictPositiveBiased(result));
                }
                else
                {
                    return(PredictPositive(result));
                }
            }
            else
            {
                result.DataPoint           = CurrentDatapoint.Datapoint;
                result.isPositiveDatapoint = false;

                if (BiasedLearning)
                {
                    return(PredictNegativeBiased(result));
                }
                else
                {
                    return(PredictNegative(result));
                }
            }
        }
Exemplo n.º 2
0
        private PerceptronTrainerStepPrediction PredictNegative(PerceptronTrainerStepPrediction result)
        {
            if ((result.DataPoint * Perceptron.W) > 0)
            {
                result.Error           = true;
                result.CurrentWeight   = CurrentWeight;
                result.Correction      = result.DataPoint * LearningRate * -1;
                result.ResultingWeight = result.CurrentWeight + result.Correction;

                return(result);
            }
            else
            {
                result.Error = false;
                return(result);
            }
        }
Exemplo n.º 3
0
        private PerceptronTrainerStepPrediction PredictPositiveBiased(PerceptronTrainerStepPrediction result)
        {
            if ((result.DataPoint * this.Perceptron.W + this.Perceptron.Bias) <= 0)
            {
                result.Error           = true;
                result.CurrentWeight   = CurrentWeight;
                result.Correction      = result.DataPoint * LearningRate;
                result.ResultingWeight = result.CurrentWeight + result.Correction;
                result.CurrentBias     = CurrentBias;
                result.ResultingBias   = CurrentBias + LearningRate;

                return(result);
            }
            else
            {
                result.Error = false;
                return(result);
            }
        }