diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c80050..81ca897 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,11 @@ CHANGELOG This changelog references the relevant changes done in PHP-ML library. -* 0.2.0 (in progress) +* 0.2.0 (in plan) + * feature [Dataset] - FileDataset - load dataset from files (folders as targets) + * feature [Metric] - ClassificationReport - report about trained classifier + +* 0.1.1 (2016-07-12) * feature [Cross Validation] Stratified Random Split - equal distribution for targets in split * feature [General] Documentation - add missing pages and fix links diff --git a/README.md b/README.md index 24c1d53..9602e4d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ composer require php-ai/php-ml * [DBSCAN](http://php-ml.readthedocs.io/en/latest/machine-learning/clustering/dbscan/) * Metric * [Accuracy](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/accuracy/) + * [Confusion Matrix](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/confusion-matrix/) * Workflow * [Pipeline](http://php-ml.readthedocs.io/en/latest/machine-learning/workflow/pipeline) * Cross Validation diff --git a/docs/index.md b/docs/index.md index e1cde6e..2d5589f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -48,6 +48,7 @@ composer require php-ai/php-ml * [DBSCAN](machine-learning/clustering/dbscan/) * Metric * [Accuracy](machine-learning/metric/accuracy/) + * [Confusion Matrix](machine-learning/metric/confusion-matrix/) * Workflow * [Pipeline](machine-learning/workflow/pipeline) * Cross Validation diff --git a/docs/machine-learning/metric/confusion-matrix.md b/docs/machine-learning/metric/confusion-matrix.md new file mode 100644 index 0000000..b07443a --- /dev/null +++ b/docs/machine-learning/metric/confusion-matrix.md @@ -0,0 +1,44 @@ +# Confusion Matrix + +Class for compute confusion matrix to evaluate the accuracy of a classification. + +### Example (all targets) + +Compute ConfusionMatrix for all targets. + +``` +use Phpml\Metric\ConfusionMatrix; + +$actualTargets = [2, 0, 2, 2, 0, 1]; +$predictedTargets = [0, 0, 2, 2, 0, 2]; + +$confusionMatrix = ConfusionMatrix::compute($actualTargets, $predictedTargets) + +/* +$confusionMatrix = [ + [2, 0, 0], + [0, 0, 1], + [1, 0, 2], +]; +*/ +``` + +### Example (chosen targets) + +Compute ConfusionMatrix for chosen targets. + +``` +use Phpml\Metric\ConfusionMatrix; + +$actualTargets = ['cat', 'ant', 'cat', 'cat', 'ant', 'bird']; +$predictedTargets = ['ant', 'ant', 'cat', 'cat', 'ant', 'cat']; + +$confusionMatrix = ConfusionMatrix::compute($actualTargets, $predictedTargets, ['ant', 'bird']) + +/* +$confusionMatrix = [ + [2, 0], + [0, 0], +]; +*/ +``` diff --git a/mkdocs.yml b/mkdocs.yml index 4c9fbf6..71ad898 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -14,6 +14,7 @@ pages: - DBSCAN: machine-learning/clustering/dbscan.md - Metric: - Accuracy: machine-learning/metric/accuracy.md + - Confusion Matrix: machine-learning/metric/confusion-matrix.md - Workflow: - Pipeline: machine-learning/workflow/pipeline.md - Cross Validation: