MCordingley\Regression\Predictor\Logistic::predict PHP Метод

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

public predict ( array $features ) : float
$features array
Результат float
    public function predict(array $features) : float
    {
        return 1.0 / (1.0 + exp(-array_sum(array_map(function ($coefficient, $feature) {
            return $coefficient * $feature;
        }, $this->coefficients, $features))));
    }

Usage Example

Пример #1
0
 public function testPredict()
 {
     $predictor = new Logistic([-3.98997907333, 0.2264425786179, 0.80403754928, -0.67544292796369, -1.340203916468, -1.5514636769182]);
     static::assertEquals(0.308, round($predictor->predict([1, 2, 3.39, 0, 0, 0]), 3));
 }