MCordingley\Regression\Observations::getObservation PHP Метод

getObservation() публичный Метод

public getObservation ( integer $index ) : Observation
$index integer
Результат Observation
    public function getObservation(int $index) : Observation
    {
        return $this->observations[$index];
    }

Usage Example

Пример #1
0
 /**
  * @param Observations $observations
  * @param array $coefficients
  * @return array
  */
 protected function calculateGradient(Observations $observations, array $coefficients) : array
 {
     $gradient = array_fill(0, count($observations->getObservation(0)->getFeatures()), 0.0);
     $batchElementIndices = (array) array_rand(range(0, count($observations) - 1), $this->batchSize);
     foreach ($batchElementIndices as $index) {
         $observation = $observations->getObservation($index);
         $observationGradient = $this->gradient->gradient($coefficients, $observation->getFeatures(), $observation->getOutcome());
         foreach ($observationGradient as $i => $observationSlope) {
             $gradient[$i] += $observationSlope / $this->batchSize;
         }
     }
     return $gradient;
 }
All Usage Examples Of MCordingley\Regression\Observations::getObservation