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:
Hiroyuki Miura 2017-05-29 16:39:08 +09:00 committed by Arkadiusz Kondas
parent 2d3b44f1a0
commit 3bcba4053e
1 changed files with 3 additions and 1 deletions

View File

@ -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'
```