From ce1653a5a768bd96d7f0c265d63419e299db05db Mon Sep 17 00:00:00 2001 From: Arkadiusz Kondas Date: Mon, 4 Apr 2016 22:25:27 +0200 Subject: [PATCH] create euclidean distance function --- src/Phpml/Classifier/Classifier.php | 3 +- src/Phpml/Classifier/KNearestNeighbors.php | 54 +++++++++++++++++++ src/Phpml/Classifier/NaiveBayes.php | 19 ++++++- .../NaiveBayes/GaussianNaiveBayes.php | 26 --------- .../Exception/InvalidArgumentException.php | 17 ++++++ src/Phpml/Metric/Distance.php | 36 +++++++++++++ 6 files changed, 127 insertions(+), 28 deletions(-) create mode 100644 src/Phpml/Classifier/KNearestNeighbors.php delete mode 100644 src/Phpml/Classifier/NaiveBayes/GaussianNaiveBayes.php create mode 100644 src/Phpml/Exception/InvalidArgumentException.php create mode 100644 src/Phpml/Metric/Distance.php diff --git a/src/Phpml/Classifier/Classifier.php b/src/Phpml/Classifier/Classifier.php index ea2bbf1..1d2362e 100644 --- a/src/Phpml/Classifier/Classifier.php +++ b/src/Phpml/Classifier/Classifier.php @@ -1,4 +1,5 @@ k = $k; + $this->features = []; + $this->labels = []; + } + + + /** + * @param array $features + * @param array $labels + */ + public function train(array $features, array $labels) + { + $this->features = $features; + $this->labels = $labels; + } + + /** + * @param mixed $feature + * @return mixed + */ + public function predict($feature) + { + + } + +} diff --git a/src/Phpml/Classifier/NaiveBayes.php b/src/Phpml/Classifier/NaiveBayes.php index 7207409..8e31eff 100644 --- a/src/Phpml/Classifier/NaiveBayes.php +++ b/src/Phpml/Classifier/NaiveBayes.php @@ -1,10 +1,27 @@