Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
60 | public function train(array $samples, array $labels) |
||
61 | { |
||
62 | $trainingSet = DataTransformer::trainingSet($samples, $labels); |
||
63 | file_put_contents($trainingSetFileName = $this->varPath.uniqid(), $trainingSet); |
||
64 | $modelFileName = $trainingSetFileName.'-model'; |
||
65 | |||
66 | $command = sprintf('%ssvm-train -s %s -t %s -c %s %s %s', $this->binPath, $this->type, $this->kernel, $this->cost, $trainingSetFileName, $modelFileName); |
||
67 | $output = ''; |
||
68 | exec(escapeshellcmd($command), $output); |
||
69 | |||
70 | $this->model = file_get_contents($modelFileName); |
||
71 | |||
72 | unlink($trainingSetFileName); |
||
73 | unlink($modelFileName); |
||
74 | } |
||
75 | |||
84 |