diff --git a/bin/libsvm/svm-predict.exe b/bin/libsvm/svm-predict.exe new file mode 100644 index 0000000..29760b0 Binary files /dev/null and b/bin/libsvm/svm-predict.exe differ diff --git a/bin/libsvm/svm-scale.exe b/bin/libsvm/svm-scale.exe new file mode 100644 index 0000000..75489ae Binary files /dev/null and b/bin/libsvm/svm-scale.exe differ diff --git a/bin/libsvm/svm-train.exe b/bin/libsvm/svm-train.exe new file mode 100644 index 0000000..23368b5 Binary files /dev/null and b/bin/libsvm/svm-train.exe differ diff --git a/src/Phpml/SupportVectorMachine/SupportVectorMachine.php b/src/Phpml/SupportVectorMachine/SupportVectorMachine.php index f14d534..a812065 100644 --- a/src/Phpml/SupportVectorMachine/SupportVectorMachine.php +++ b/src/Phpml/SupportVectorMachine/SupportVectorMachine.php @@ -69,7 +69,7 @@ class SupportVectorMachine 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); @@ -100,7 +100,7 @@ class SupportVectorMachine 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); @@ -112,4 +112,17 @@ class SupportVectorMachine return DataTransformer::results($predictions, $this->labels); } + + /** + * @return string + */ + private function getOSExtension() + { + if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { + return '.exe'; + } + + return ''; + } + }