PHPML库问题

时间:2018-12-03 14:16:35

标签: php html composer-php

我一直在尝试使PHPML库工作,

我遵循的步骤:

  • 从github下载了PHPML库: https://github.com/php-ai/php-ml
  • Composer install [使用PHP 7.1] {输出}供应商文件夹大小为 大约60MB
  • 我写了以下php页面:
<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

我感谢帮助

此致

1 个答案:

答案 0 :(得分:0)

在使用名称空间(如,

)之前加载供应商文件
    <?php
    require './vendor/autoload.php';

    use Phpml\Classification\NaiveBayes;