1

I have been trying to get PHPML library to work ,

steps that I followed :

  • Downloaded the PHPML Library from github : https://github.com/php-ai/php-ml
  • Composer install [ using PHP 7.1 ] {output} vendor folder size is around 60MB
  • I wrote the following php page :
<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>

the issue that I face is the following when I try to browse the page :

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

I approciate the help

Regards,

neubert
  • 15,947
  • 24
  • 120
  • 212
AhMaD AbUIeSa
  • 805
  • 1
  • 12
  • 21

1 Answers1

0

Load vendor file before using namespaces like,

    <?php
    require './vendor/autoload.php';

    use Phpml\Classification\NaiveBayes;
Venkatesh
  • 31
  • 7