original_string: 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);
      }
code: 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);
      }
code_tokens: 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 ) ; }
docstring: Trains the perceptron model with Stochastic Gradient Descent optimization
  to get the correct set of weights
  
  @param array $samples
  @param array $targets
docstring_tokens: Trains the perceptron model with Stochastic Gradient Descent optimization to get the correct set of weights