2022-02-27 06:06:47 -05:00
|
|
|
|
|
|
|
[![Arduino CI](https://github.com/RobTillaart/GST/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
|
|
|
[![Arduino-lint](https://github.com/RobTillaart/GST/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GST/actions/workflows/arduino-lint.yml)
|
|
|
|
[![JSON check](https://github.com/RobTillaart/GST/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GST/actions/workflows/jsoncheck.yml)
|
2023-11-02 10:59:23 -04:00
|
|
|
[![GitHub issues](https://img.shields.io/github/issues/RobTillaart/GST.svg)](https://github.com/RobTillaart/GST/issues)
|
|
|
|
|
2022-02-27 06:06:47 -05:00
|
|
|
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GST/blob/master/LICENSE)
|
|
|
|
[![GitHub release](https://img.shields.io/github/release/RobTillaart/GST.svg?maxAge=3600)](https://github.com/RobTillaart/GST/releases)
|
2023-11-02 10:59:23 -04:00
|
|
|
[![PlatformIO Registry](https://badges.registry.platformio.org/packages/robtillaart/library/GST.svg)](https://registry.platformio.org/libraries/robtillaart/GST)
|
2022-02-27 06:06:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
# GST
|
|
|
|
|
|
|
|
Arduino library for Gold Standard Test metrics.
|
|
|
|
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
Note: **experimental**
|
|
|
|
|
|
|
|
The GST library is an implementation of the **Gold Standard Test**.
|
2022-02-27 06:06:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
#### Links
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
These sites describe the functions in more detail.
|
|
|
|
|
2022-02-27 06:06:47 -05:00
|
|
|
- https://en.wikipedia.org/wiki/Sensitivity_and_specificity
|
|
|
|
- https://en.wikipedia.org/wiki/Confusion_matrix
|
|
|
|
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
#### Related
|
|
|
|
|
|
|
|
- https://github.com/RobTillaart/Correlation
|
|
|
|
- https://github.com/RobTillaart/GST - Golden standard test metrics
|
2023-11-02 10:59:23 -04:00
|
|
|
- https://github.com/RobTillaart/Histogram
|
2023-01-26 14:26:23 -05:00
|
|
|
- https://github.com/RobTillaart/RunningAngle
|
|
|
|
- https://github.com/RobTillaart/RunningAverage
|
|
|
|
- https://github.com/RobTillaart/RunningMedian
|
|
|
|
- https://github.com/RobTillaart/statHelpers - combinations & permutations
|
|
|
|
- https://github.com/RobTillaart/Statistic
|
|
|
|
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
#### Performance
|
|
|
|
|
|
|
|
The math functions are from pretty straightforward to rather complex.
|
|
|
|
|
|
|
|
It is possible to optimize functions with intermediate values if needed.
|
|
|
|
However the right way to optimize depends on the way the library is used.
|
|
|
|
|
|
|
|
|
2022-02-27 06:06:47 -05:00
|
|
|
## Interface
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
```cpp
|
|
|
|
#include "GST.h"
|
|
|
|
```
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
See .h file for all functions. Many function exist in a long descriptive name and an acronym version. Here only the long names are given.
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
For the definitions please check - https://en.wikipedia.org/wiki/Sensitivity_and_specificity or
|
2022-06-08 08:39:43 -04:00
|
|
|
https://en.wikipedia.org/wiki/Confusion_matrix
|
|
|
|
|
|
|
|
|
|
|
|
### Input functions
|
|
|
|
|
|
|
|
These four numbers should all be set before output functions make sense.
|
|
|
|
The parameter **value** is typical absolute value measured or counted.
|
|
|
|
If the parameter is omitted, the default 0 will be used to reset the value.
|
|
|
|
|
|
|
|
- **void setTruePositive(float value = 0)** set the internal TP value.
|
|
|
|
- **void setTrueNegative(float value = 0)** set the internal TN value.
|
|
|
|
- **void setFalsePositive(float value = 0)** set the internal FP value.
|
|
|
|
- **void setFalseNegative(float value = 0)** set the internal FN value.
|
|
|
|
- **void clearAll()** reset all the above to 0.
|
|
|
|
|
|
|
|
In tests one often want to increase / change the numbers.
|
|
|
|
This can be done with the **addTruePositive()** etc functions.
|
|
|
|
After every addition all output functions can be called.
|
|
|
|
|
|
|
|
- **float addTruePositive(float value)** increases the internal TP value.
|
|
|
|
Use a negative value to decrease.
|
|
|
|
Returns the new value of TP.
|
|
|
|
- **float addTrueNegative(float value)** increases the internal TN value.
|
|
|
|
Use a negative value to decrease.
|
|
|
|
Returns the new value of TN.
|
|
|
|
- **float addFalsePositive(float value)** increases the internal FP value.
|
|
|
|
Use a negative value to decrease.
|
|
|
|
Returns the new value of FP.
|
|
|
|
- **float addFalseNegative(float value)** increases the internal FN value.
|
|
|
|
Use a negative value to decrease.
|
|
|
|
Returns the new value of FN.
|
|
|
|
|
|
|
|
|
|
|
|
### Output functions I
|
|
|
|
|
|
|
|
Basic output
|
|
|
|
|
|
|
|
- **float getTruePositive()** returns internal TP.
|
|
|
|
- **float getTrueNegative()** returns internal TN.
|
|
|
|
- **float getFalsePositive()** returns internal FP.
|
|
|
|
- **float getFalseNegative()** returns internal FN.
|
|
|
|
|
|
|
|
|
|
|
|
- **float getTotal()** returns total of four numbers.
|
|
|
|
- **float getActualPositive()**
|
|
|
|
- **float getActualNegative()**
|
|
|
|
- **float getTestedPositive()**
|
|
|
|
- **float getTestedNegative()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float sensitivity()** equals truePositiveRate().
|
|
|
|
- **float specificity()** equals trueNegativeRate()
|
|
|
|
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
**Rate** functions can be multiplied by 100.0 to get percentage.
|
|
|
|
|
|
|
|
- **float truePositiveRate()** returns value between 0.0 and 1.0
|
|
|
|
- **float trueNegativeRate()** returns value between 0.0 and 1.0
|
|
|
|
- **float falseNegativeRate()** returns value between 0.0 and 1.0
|
|
|
|
- **float falsePositiveRate()** returns value between 0.0 and 1.0
|
2022-06-08 08:39:43 -04:00
|
|
|
|
|
|
|
|
|
|
|
### Output functions II
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
These output functions are the more 'complex' functions.
|
2022-06-08 08:39:43 -04:00
|
|
|
Read the Wikipedia pages for their uses.
|
|
|
|
|
|
|
|
- **float positivePredictiveValue()**
|
|
|
|
- **float negativePredictiveValue()**
|
|
|
|
- **float falseDiscoveryRate()**
|
|
|
|
- **float falseOmissionRate()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float positiveLikelihoodRatio()**
|
|
|
|
- **float negativeLikelihoodRatio()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float prevalenceThreshold()**
|
|
|
|
- **float threatScore()**
|
|
|
|
- **float criticalSuccessIndex()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float prevalence()**
|
|
|
|
- **float accuracy()**
|
|
|
|
- **float balancedAccuracy()**
|
|
|
|
- **float F1Score()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float MatthewsCorrelationCoefficient()**
|
|
|
|
- **float FowlkesMallowsIndex()**
|
|
|
|
- **float BookmakerInformedness()**
|
|
|
|
|
|
|
|
|
|
|
|
- **float markedness()**
|
|
|
|
- **float deltaP()**
|
|
|
|
- **float diagnosticOddsRatio()**
|
2022-02-27 06:06:47 -05:00
|
|
|
|
|
|
|
|
|
|
|
## Future
|
|
|
|
|
2023-01-26 14:26:23 -05:00
|
|
|
#### Must
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
- improve documentation
|
2023-01-26 14:26:23 -05:00
|
|
|
|
|
|
|
#### Should
|
|
|
|
|
2022-06-08 08:39:43 -04:00
|
|
|
- add functions
|
2023-01-26 14:26:23 -05:00
|
|
|
- percentage functions for TP TN FP and FN?
|
2022-02-27 06:06:47 -05:00
|
|
|
- test
|
|
|
|
- complete the CI test coverage.
|
2023-01-26 14:26:23 -05:00
|
|
|
|
|
|
|
#### Could
|
|
|
|
|
2022-02-27 06:06:47 -05:00
|
|
|
- examples
|
|
|
|
- add real life examples.
|
|
|
|
- combination with a sensor? batch testing?
|
2023-01-26 14:26:23 -05:00
|
|
|
|
2023-11-02 10:59:23 -04:00
|
|
|
#### Wont
|
|
|
|
|
|
|
|
|
|
|
|
## Support
|
|
|
|
|
|
|
|
If you appreciate my libraries, you can support the development and maintenance.
|
|
|
|
Improve the quality of the libraries by providing issues and Pull Requests, or
|
|
|
|
donate through PayPal or GitHub sponsors.
|
|
|
|
|
|
|
|
Thank you,
|
|
|
|
|