protected function runTraining(array $samples, array $targets)
    {
        // The cost function is the sum of squares
        $callback = function ($weights, $sample, $target) {
            $this->weights = $weights;

            $prediction = $this->outputClass($sample);
            $gradient = $prediction - $target;
            $error = $gradient**2;

            return [$error, $gradient];
        };

        $this->runGradientDescent($samples, $targets, $callback);
    }
protected function runTraining(array $samples, array $targets)
    {
        // The cost function is the sum of squares
        $callback = function ($weights, $sample, $target) {
            $this->weights = $weights;

            $prediction = $this->outputClass($sample);
            $gradient = $prediction - $target;
            $error = $gradient**2;

            return [$error, $gradient];
        };

        $this->runGradientDescent($samples, $targets, $callback);
    }
protected function runTraining ( array $ samples , array $ targets ) { // The cost function is the sum of squares $ callback = function ( $ weights , $ sample , $ target ) { $ this -> weights = $ weights ; $ prediction = $ this -> outputClass ( $ sample ) ; $ gradient = $ prediction - $ target ; $ error = $ gradient ** 2 ; return [ $ error , $ gradient ] ; } ; $ this -> runGradientDescent ( $ samples , $ targets , $ callback ) ; }
Trains the perceptron model with Stochastic Gradient Descent optimization
to get the correct set of weights

@param array $samples
@param array $targets
Trains the perceptron model with Stochastic Gradient Descent optimization to get the correct set of weights