add docs for ConfusionMatrix

This commit is contained in:
Arkadiusz Kondas 2016-07-12 00:11:18 +02:00
parent bb35d045ba
commit ba8927459c
5 changed files with 52 additions and 1 deletions

View File

@ -3,7 +3,11 @@ CHANGELOG
This changelog references the relevant changes done in PHP-ML library. 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 [Cross Validation] Stratified Random Split - equal distribution for targets in split
* feature [General] Documentation - add missing pages and fix links * feature [General] Documentation - add missing pages and fix links

View File

@ -48,6 +48,7 @@ composer require php-ai/php-ml
* [DBSCAN](http://php-ml.readthedocs.io/en/latest/machine-learning/clustering/dbscan/) * [DBSCAN](http://php-ml.readthedocs.io/en/latest/machine-learning/clustering/dbscan/)
* Metric * Metric
* [Accuracy](http://php-ml.readthedocs.io/en/latest/machine-learning/metric/accuracy/) * [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 * Workflow
* [Pipeline](http://php-ml.readthedocs.io/en/latest/machine-learning/workflow/pipeline) * [Pipeline](http://php-ml.readthedocs.io/en/latest/machine-learning/workflow/pipeline)
* Cross Validation * Cross Validation

View File

@ -48,6 +48,7 @@ composer require php-ai/php-ml
* [DBSCAN](machine-learning/clustering/dbscan/) * [DBSCAN](machine-learning/clustering/dbscan/)
* Metric * Metric
* [Accuracy](machine-learning/metric/accuracy/) * [Accuracy](machine-learning/metric/accuracy/)
* [Confusion Matrix](machine-learning/metric/confusion-matrix/)
* Workflow * Workflow
* [Pipeline](machine-learning/workflow/pipeline) * [Pipeline](machine-learning/workflow/pipeline)
* Cross Validation * Cross Validation

View File

@ -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],
];
*/
```

View File

@ -14,6 +14,7 @@ pages:
- DBSCAN: machine-learning/clustering/dbscan.md - DBSCAN: machine-learning/clustering/dbscan.md
- Metric: - Metric:
- Accuracy: machine-learning/metric/accuracy.md - Accuracy: machine-learning/metric/accuracy.md
- Confusion Matrix: machine-learning/metric/confusion-matrix.md
- Workflow: - Workflow:
- Pipeline: machine-learning/workflow/pipeline.md - Pipeline: machine-learning/workflow/pipeline.md
- Cross Validation: - Cross Validation: