From 3bcba4053e176cfaccc595ee2a5201709ef01192 Mon Sep 17 00:00:00 2001 From: Hiroyuki Miura Date: Mon, 29 May 2017 16:39:08 +0900 Subject: [PATCH] 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. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48b7b48..9adddb2 100644 --- a/README.md +++ b/README.md @@ -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' ```