premises:php 8.1 ,windows 64
----------------------------------
install (for beginners)
--------
after i visit https://github.com/ianbarber/php-svm
and i got from url found on page(install script)
.. http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz
and manual install it:
1.php.ini
(after the main group extension=... about 12 pieces)
...
extension=svm
...
2.I put manually inside php a folder called libsvm-3.1 then i unzip there libsvm.dll , libsvmread.mexw64 ,libsvmwrite.mexw64 , svmpredict.mexw64 , svm-predict.exe, svm-scale.exe , svm-toy.exe , svmtrain.mexw64, svm-train.exe !
running
<?php
$data = array(
array(-1, 1 => 0.43, 3 => 0.12, 9284 => 0.2),
array(1, 1 => 0.22, 5 => 0.01, 94 => 0.11),
);
$svm = new SVM();
$model = $svm->train($data);
$data = array(1 => 0.43, 3 => 0.12, 9284 => 0.2);
$result = $model->predict($data);
var_dump($result);
$model->save('model.svm');
?>
via server(apache ,php,mariadb;even custom or xampp) now i got results:
i got model.svm with the content
================================
svm_type c_svc
kernel_type rbf
gamma 0.00010771219302024989
nr_class 2
total_sv 2
rho 0
label 1 -1
nr_sv 1 1
SV
1 1:0.22 5:0.01 94:0.11
-1 1:0.43 3:0.12 9284:0.2
=================================
so i think is very cool ..for a startup.
i will look around phpt files from github to understand why in yesterday's tests i got errors with some function witch require 2 parameters and not one like in the manual