Advertisement
sandi097

Penggunaan

Jul 14th, 2020
939
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.32 KB | None | 0 0
  1. require_once __DIR__ . '/vendor/autoload.php';
  2.  
  3. use Phpml\Classification\KNearestNeighbors;
  4.  
  5. $samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
  6. $labels = ['a', 'a', 'a', 'b', 'b', 'b'];
  7.  
  8. $classifier = new KNearestNeighbors();
  9. $classifier->train($samples, $labels);
  10.  
  11. $classifier->predict([3, 2]);
  12. // return 'b'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement