Skip to content

Commit

Permalink
add windows libsvm binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed May 7, 2016
1 parent 7b5b641 commit 95bfc89
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Binary file added bin/libsvm/svm-predict.exe
Binary file not shown.
Binary file added bin/libsvm/svm-scale.exe
Binary file not shown.
Binary file added bin/libsvm/svm-train.exe
Binary file not shown.
17 changes: 15 additions & 2 deletions src/Phpml/SupportVectorMachine/SupportVectorMachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function train(array $samples, array $labels)
file_put_contents($trainingSetFileName = $this->varPath.uniqid(), $trainingSet);
$modelFileName = $trainingSetFileName.'-model';

$command = sprintf('%ssvm-train -s %s -t %s -c %s %s %s', $this->binPath, $this->type, $this->kernel, $this->cost, $trainingSetFileName, $modelFileName);
$command = sprintf('%ssvm-train%s -s %s -t %s -c %s %s %s', $this->binPath, $this->getOSExtension(), $this->type, $this->kernel, $this->cost, $trainingSetFileName, $modelFileName);
$output = '';
exec(escapeshellcmd($command), $output);

Expand Down Expand Up @@ -100,7 +100,7 @@ public function predict(array $samples)
file_put_contents($modelFileName, $this->model);
$outputFileName = $testSetFileName.'-output';

$command = sprintf('%ssvm-predict %s %s %s', $this->binPath, $testSetFileName, $modelFileName, $outputFileName);
$command = sprintf('%ssvm-predict%s %s %s %s', $this->binPath, $this->getOSExtension(), $testSetFileName, $modelFileName, $outputFileName);
$output = '';
exec(escapeshellcmd($command), $output);

Expand All @@ -112,4 +112,17 @@ public function predict(array $samples)

return DataTransformer::results($predictions, $this->labels);
}

/**
* @return string
*/
private function getOSExtension()
{
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
return '.exe';
}

return '';
}

}

0 comments on commit 95bfc89

Please sign in to comment.