好吧,我做了更多测试...
获取源代码
https://github.com/ianbarber/php-svm/blob/master/tests/002_predict.phpt 已修改..
<?php
$svm = new svmmodel();
//$result = $svm->load(dirname(__FILE__) . '/australian.model');
$result = $svm->load('australian.model');
if($result) {
$data = array(
"1" => 1,
2 => -0.731729,
3 => -0.886786,
4 => -1,
5 => 0.230769,
"6" => -0.25,
7 => -0.783509,
8 => 1,
9 => 1,
10 => "-0.820896",
11 => -1,
13 => -0.92,
"14" => "-1"
);
$result = $svm->predict($data);
if($result > 0) {
echo "ok";
print_r($result);
} else {
echo "predict failed: $result";
}
} else {
echo "loading failed";
}
?>
通过将额外的 https://github.com/ianbarber/php-svm/blob/master/tests/australian.scale 放置在 .php 文件所在的测试文件夹中,我能够在运行后获得结果
================================
ok1
所以它可以工作