MCordingley\Regression\Tests\Algorithm\GradientDescent\GradientDescent::getLogisticObservations PHP Метод

getLogisticObservations() приватный Метод

private getLogisticObservations ( ) : Observations
Результат MCordingley\Regression\Observations
    private function getLogisticObservations()
    {
        // Data from http://statistics.ats.ucla.edu/stat/r/dae/logit.htm
        $observations = new Observations();
        $csv = fopen(__DIR__ . '/../../fixtures/logistic.csv', 'r');
        fgetcsv($csv);
        // Throw away headers.
        while ($line = fgetcsv($csv)) {
            // Split composite feature, since the school rank isn't actually an interval value.
            $rank2 = $line[3] == 2 ? 1 : 0;
            $rank3 = $line[3] == 3 ? 1 : 0;
            $rank4 = $line[3] == 4 ? 1 : 0;
            // Normalize the GRE score. This is critical to get convergence.
            $gre = $line[1] / 100;
            //                 [1, GRE,  GPA,      Rank2,  Rank3,  Rank4],  Admitted
            $observations->add([1, $gre, $line[2], $rank2, $rank3, $rank4], (double) $line[0]);
        }
        fclose($csv);
        return $observations;
    }