我一直在尝试使PHPML库工作,
我遵循的步骤:
<html> <head> <title>Test</title> </head> <body> <h1>Testing</h1> <table width = 100% > <tr> <?php use Phpml\Classification\NaiveBayes; require './vendor/autoload.php'; $samples = [[176, 70], [180, 80], [161, 45], [163, 47], [186, 86], [165, 49]]; $labels = ['a', 'b', 'a', 'b', 'a', 'b']; $classifier = new NaiveBayes(); $classifier->train($samples, $labels); print_r($classifier->predict([[172,40]])); ?> </tr> </table> </body> </html>
当我尝试浏览页面时,我面临的问题如下:
Testing
Fatal error: Uncaught Error: Class 'Phpml\Classification\NaiveBayes' not found in /home4/ab12960/reviewsclassification.com/test.php:17 Stack trace: #0 {main} thrown in /home4/ab12960/reviewsclassification.com/test.php on line 17
我感谢帮助
此致
答案 0 :(得分:0)
在使用名称空间(如,
)之前加载供应商文件 <?php
require './vendor/autoload.php';
use Phpml\Classification\NaiveBayes;