original_string: protected function runGradientDescent(array $samples, array $targets, \Closure $gradientFunc, bool $isBatch = false)
      {
          $class = $isBatch ? GD::class : StochasticGD::class;
  
          if (empty($this->optimizer)) {
              $this->optimizer = (new $class($this->featureCount))
                  ->setLearningRate($this->learningRate)
                  ->setMaxIterations($this->maxIterations)
                  ->setChangeThreshold(1e-6)
                  ->setEarlyStop($this->enableEarlyStop);
          }
  
          $this->weights = $this->optimizer->runOptimization($samples, $targets, $gradientFunc);
          $this->costValues = $this->optimizer->getCostValues();
      }
code: protected function runGradientDescent(array $samples, array $targets, \Closure $gradientFunc, bool $isBatch = false)
      {
          $class = $isBatch ? GD::class : StochasticGD::class;
  
          if (empty($this->optimizer)) {
              $this->optimizer = (new $class($this->featureCount))
                  ->setLearningRate($this->learningRate)
                  ->setMaxIterations($this->maxIterations)
                  ->setChangeThreshold(1e-6)
                  ->setEarlyStop($this->enableEarlyStop);
          }
  
          $this->weights = $this->optimizer->runOptimization($samples, $targets, $gradientFunc);
          $this->costValues = $this->optimizer->getCostValues();
      }
code_tokens: protected function runGradientDescent ( array $ samples , array $ targets , \ Closure $ gradientFunc , bool $ isBatch = false ) { $ class = $ isBatch ? GD :: class : StochasticGD :: class ; if ( empty ( $ this -> optimizer ) ) { $ this -> optimizer = ( new $ class ( $ this -> featureCount ) ) -> setLearningRate ( $ this -> learningRate ) -> setMaxIterations ( $ this -> maxIterations ) -> setChangeThreshold ( 1e-6 ) -> setEarlyStop ( $ this -> enableEarlyStop ) ; } $ this -> weights = $ this -> optimizer -> runOptimization ( $ samples , $ targets , $ gradientFunc ) ; $ this -> costValues = $ this -> optimizer -> getCostValues ( ) ; }
docstring: Executes a Gradient Descent algorithm for
  the given cost function
  
  @param array    $samples
  @param array    $targets
  @param \Closure $gradientFunc
  @param bool     $isBatch
docstring_tokens: Executes a Gradient Descent algorithm for the given cost function