Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require_once __DIR__ . '/vendor/autoload.php';
- use Phpml\Classification\KNearestNeighbors;
- $samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
- $labels = ['a', 'a', 'a', 'b', 'b', 'b'];
- $classifier = new KNearestNeighbors();
- $classifier->train($samples, $labels);
- $classifier->predict([3, 2]);
- // return 'b'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement