PHP code example of mykolavuy / forecast

1. Go to this page and download the library: Download mykolavuy/forecast library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mykolavuy / forecast example snippets


use MykolaVuy\Forecast\ForecastService;

$data = [
    1 => 10,
    2 => null,
    3 => 30,
    4 => null,
    5 => 50,
    6 => null,
];

$service = new ForecastService();

// Linear regression forecast
$result = $service->forecast($data, method: 'linear');

// Power regression with interpolation only
$interpolated = $service->forecast($data, method: 'power', interpolateOnly: true);

// 🔹 Static call (no instance needed)
$static = ForecastService::predict($data, method: 'exponential');