mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-05 04:57:52 +00:00
Update README.md (#95)
I tried copying the sample code as it is but did not do what I assumed. Specifically, it is as follows. - It does not work without `require_once` - I can not check the output if it is `return` I modified the README.md. I think that this one is better. Because you can use it as soon as you copy it.
This commit is contained in:
parent
2d3b44f1a0
commit
3bcba4053e
@ -16,6 +16,8 @@ PHP-ML requires PHP >= 7.0.
|
||||
|
||||
Simple example of classification:
|
||||
```php
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use Phpml\Classification\KNearestNeighbors;
|
||||
|
||||
$samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
|
||||
@ -24,7 +26,7 @@ $labels = ['a', 'a', 'a', 'b', 'b', 'b'];
|
||||
$classifier = new KNearestNeighbors();
|
||||
$classifier->train($samples, $labels);
|
||||
|
||||
$classifier->predict([3, 2]);
|
||||
echo $classifier->predict([3, 2]);
|
||||
// return 'b'
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user