|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Klass Traningsdata. |
|
5
|
|
|
* @author Niklas Dougherty |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
declare(strict_types=1); |
|
9
|
|
|
|
|
10
|
|
|
namespace Tips\Moduler\FANNGenerera; |
|
11
|
|
|
|
|
12
|
|
|
use Tips\Moduler\FANN; |
|
13
|
|
|
use Tips\Egenskaper\Varden; |
|
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Klass Traningsdata. |
|
17
|
|
|
*/ |
|
18
|
|
|
class Traningsdata { |
|
19
|
|
|
use Varden; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* 3 odds + 3 streck in. |
|
23
|
|
|
* 1 tecken eller halvgardering ut. |
|
24
|
|
|
*/ |
|
25
|
|
|
protected int $neuroner_in = 6; |
|
26
|
|
|
protected int $neuroner_ut = 1; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @var array<int, array<int, float[]>> $oddssannolikheter |
|
30
|
|
|
*/ |
|
31
|
|
|
public array $oddssannolikheter; |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @var array<int, array<int, float[]>> $strecksannolikheter |
|
35
|
|
|
*/ |
|
36
|
|
|
public array $strecksannolikheter; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var string[] $tipsrader |
|
40
|
|
|
*/ |
|
41
|
|
|
public array $tipsrader; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Tom konstruktor tills vidare. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct(public FANN $fann) { |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Generera träningsdata. |
|
51
|
|
|
*/ |
|
52
|
|
|
protected function generera_träningsdata(): void { |
|
53
|
|
|
$this->oddssannolikheter = []; |
|
54
|
|
|
$this->strecksannolikheter = []; |
|
55
|
|
|
$this->tipsrader = []; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Hämta prediktionsdata. |
|
59
|
|
|
*/ |
|
60
|
|
|
$oddsprediktioner = $this->fann->odds->prediktionsdata('odds'); |
|
61
|
|
|
$streckprediktioner = $this->fann->odds->prediktionsdata('streck'); |
|
62
|
|
|
|
|
63
|
|
|
foreach ($this->fann->odds->tipsdata($this->u13_min, $this->u13_max) as $omgång => $tipsrad_012) { |
|
64
|
|
|
if (isset($oddsprediktioner[$omgång], $streckprediktioner[$omgång])) { |
|
65
|
|
|
$this->oddssannolikheter[] = odds_till_sannolikheter($oddsprediktioner[$omgång]); |
|
66
|
|
|
$this->strecksannolikheter[] = streck_till_sannolikheter($streckprediktioner[$omgång]); |
|
67
|
|
|
$this->tipsrader[] = $tipsrad_012; |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Lämna 10 senaste omgångar för kontroll av resultatet. |
|
73
|
|
|
*/ |
|
74
|
|
|
if ($antal = count($this->oddssannolikheter) > 40) { |
|
75
|
|
|
$this->oddssannolikheter = array_slice($this->oddssannolikheter, 0, $andel = $antal - 10); |
|
76
|
|
|
$this->strecksannolikheter = array_slice($this->strecksannolikheter, 0, $andel); |
|
77
|
|
|
$this->tipsrader = array_slice($this->tipsrader, 0, $andel); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
$this->träningsdata(); |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Själva genereringen. |
|
85
|
|
|
*/ |
|
86
|
|
|
private function träningsdata(): void { |
|
87
|
|
|
/** |
|
88
|
|
|
* Slumpa tipsraderna. |
|
89
|
|
|
*/ |
|
90
|
|
|
$nycklar = array_keys($this->tipsrader); |
|
91
|
|
|
shuffle($nycklar); |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* En neuron per match. |
|
95
|
|
|
*/ |
|
96
|
|
|
$antal_neuroner = MATCHANTAL * count($nycklar); |
|
|
|
|
|
|
97
|
|
|
$träningsdata = "$antal_neuroner {$this->neuroner_in} {$this->neuroner_ut}\n"; |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Generera träningsdata. |
|
101
|
|
|
*/ |
|
102
|
|
|
foreach ($nycklar as $omgång) { |
|
103
|
|
|
foreach (str_split($this->tipsrader[$omgång]) as $index => $tecken) { |
|
104
|
|
|
$odds = $this->oddssannolikheter[$omgång][$index]; |
|
105
|
|
|
$streck = $this->strecksannolikheter[$omgång][$index]; |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* Symmetri -1, 0, 1 snarare än 0, 1, 2. |
|
109
|
|
|
*/ |
|
110
|
|
|
$tecken = intval($tecken) - 1; |
|
111
|
|
|
$träningsdata .= "{$odds[0]} {$streck[0]} {$odds[1]} {$streck[1]} {$odds[2]} {$streck[2]}\n$tecken\n"; |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
|
|
/** |
|
116
|
|
|
* Spara och logga. |
|
117
|
|
|
*/ |
|
118
|
|
|
$this->fann->logg = date("Y-m-d H:i") . "<br>" . |
|
119
|
|
|
match (file_put_contents($this->fann->indatafil, $träningsdata) !== false) { |
|
120
|
|
|
true => "Sparade fil.<br>", |
|
121
|
|
|
false => "Kunde inte spara fil.<br>" |
|
122
|
|
|
}; |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths