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

public add ( array $features, float $outcome ) : self
$features array
$outcome float
Результат self
Пример #1
0
 public function testBadObservationsCount()
 {
     $observations = new Observations();
     $observations->add([1, 2, 3], 4);
     static::setExpectedException('InvalidArgumentException');
     $observations->add([1, 2], 4);
 }
Пример #2
0
 /**
  * @return 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;
 }