This repository has been archived by the owner on Mar 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathexample.php
68 lines (56 loc) · 1.95 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
use Regression\ExponentialRegression;
use Regression\LinearRegression;
use Regression\LogarithmicRegression;
use Regression\PowerRegression;
use Regression\RegressionFactory;
use Regression\RegressionModel;
require __DIR__ . '/src/autoload.php';
require __DIR__ . '/vendor/autoload.php';
$testData = [[1, 129], [2, 384], [3, 396], [4, 579], [5, 495], [6, 843], [7, 936], [8, 431], [9, 431], [10, 600], [11, 512], [12, 314], [13, 432], [14, 489], [15, 327], [16, 492], [17, 551], [18, 544], [19, 643], [20, 535]];
/**
* Calculate linear regression call calculate()
*/
$linear = new LinearRegression();
$linear->setSourceSequence($testData);
$linear->calculate();
/** @var RegressionModel $regressionModel */
$regressionModel = $linear->getRegressionModel();
/**
* Calculate with Fabric method
*/
/** @var RegressionModel $regressionModel */
$regressionModel = RegressionFactory::linear($testData);
//var_dump($regressionModel);
/**
* Calculate Exponential regression call calculate()
*/
$exponential = new ExponentialRegression();
$exponential->setSourceSequence($testData);
$exponential->calculate();
/**
* And with Fabric method
*/
$regressionModel = $exponential->getRegressionModel();
//var_dump($regressionModel);
/**
* Calculate logarithmic regression call calculate()
*/
$logarithmic = new LogarithmicRegression();
$logarithmic->setSourceSequence($testData);
$logarithmic->calculate();
/** @var RegressionModel $regressionModel */
$regressionModel = $logarithmic->getRegressionModel();
$regressionModel = RegressionFactory::logarithmic($testData);
var_dump($regressionModel);
/**
* Calculate power regression call calculate()
*/
$powerReg = new PowerRegression();
$powerReg->setSourceSequence($testData);
$powerReg->calculate();
/** @var RegressionModel $regressionModel */
$regressionModel = $powerReg->getRegressionModel();
$regressionModel = RegressionFactory::power($testData);
//var_dump($regressionModel);
//var_dump(RegressionFactory::Power($testData));