Skip to content

Commit

Permalink
update unit tests (#4)
Browse files Browse the repository at this point in the history
- update unit tests
- update GitHub actions
- update license 2023
- update readme.md
  • Loading branch information
RobTillaart committed Jan 26, 2023
1 parent de3f2a8 commit 250b1e4
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 34 deletions.
6 changes: 3 additions & 3 deletions GST.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// FILE: GST.cpp
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for Gold Standard Test metrics
// URL: https://github.com/RobTillaart/GST
// https://en.wikipedia.org/wiki/Sensitivity_and_specificity
// https://en.wikipedia.org/wiki/Confusion_matrix
//
// formula's based upon Wikipedia.
// formula's based upon Wikipedia.


#include "GST.h"
Expand Down Expand Up @@ -222,5 +222,5 @@ float GST::DOR()
};


// -- END OF FILE --
// -- END OF FILE --

9 changes: 5 additions & 4 deletions GST.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once
//
// FILE: GST.h
// VERSION: 0.1.2
// VERSION: 0.1.3
// PURPOSE: Arduino library for Gold Standard Test metrics
// URL: https://github.com/RobTillaart/GST
// https://en.wikipedia.org/wiki/Sensitivity_and_specificity
// https://en.wikipedia.org/wiki/Confusion_matrix
//
// formula's based upon Wikipedia.
// formula's based upon Wikipedia.

#define GST_LIB_VERSION (F("0.1.2"))

#define GST_LIB_VERSION (F("0.1.3"))


#include "Arduino.h"
Expand Down Expand Up @@ -114,5 +115,5 @@ class GST
};


// -- END OF FILE --
// -- END OF FILE --

47 changes: 35 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ These sites describe the functions in more detail.
- https://en.wikipedia.org/wiki/Confusion_matrix


#### Related

- https://github.com/RobTillaart/Correlation
- https://github.com/RobTillaart/GST - Golden standard test metrics
- 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


#### Performance

The math functions are from pretty straightforward to rather complex.
Expand All @@ -34,16 +45,15 @@ 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.


#### Related libraries

- https://github.com/RobTillaart/Statistic


## Interface

```cpp
#include "GST.h"
```

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.

For the definitions please check - https://en.wikipedia.org/wiki/Sensitivity_and_specificity or
For the definitions please check - https://en.wikipedia.org/wiki/Sensitivity_and_specificity or
https://en.wikipedia.org/wiki/Confusion_matrix


Expand Down Expand Up @@ -98,15 +108,17 @@ Basic output
- **float specificity()** equals trueNegativeRate()


- **float truePositiveRate()**
- **float trueNegativeRate()**
- **float falseNegativeRate()**
- **float falsePositiveRate()**
**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


### Output functions II

These are the more 'complex' functions.
These output functions are the more 'complex' functions.
Read the Wikipedia pages for their uses.

- **float positivePredictiveValue()**
Expand Down Expand Up @@ -142,11 +154,22 @@ Read the Wikipedia pages for their uses.

## Future

#### Must

- improve documentation


#### Should

- add functions
- percentage functions for TP TN FP and FN?
- percentage functions for TP TN FP and FN?
- test
- complete the CI test coverage.


#### Could

- examples
- add real life examples.
- combination with a sensor? batch testing?

17 changes: 12 additions & 5 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
# Change Log GST

# GST Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).


## [0.1.3] - 2022-11-08
- update GitHub actions
- update license 2023
- update readme.md
- update unit tests


## [0.1.2] - 2022-11-08
- add RP2040 to build CI
- update changelog.md


## [0.1.1] - 2022-06-08
- add **addTruePositive()** etc functions.
- add defaults for **setTruePositive(value = 0)** etc functions
Expand All @@ -15,9 +25,6 @@
- added some documentation
- split off GST.cpp file, prevent - https://github.com/RobTillaart/CRC/issues/21


## [0.1.0] - 2022-02-25
- initial version
-


6 changes: 2 additions & 4 deletions examples/GST_add_runtime/GST_add_runtime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ void loop()
break;
}
confusion_matrix();
// confusion_matrix_normalized();


// confusion_matrix_normalized();
}


Expand Down Expand Up @@ -117,5 +115,5 @@ void confusion_matrix_normalized()
}


// -- END OF FILE --

// -- END OF FILE --
5 changes: 4 additions & 1 deletion examples/GST_test/GST_test.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
// PURPOSE: demo
// URL: https://github.com/RobTillaart/GST


#include "Arduino.h"
#include "GST.h"

GST gst;


void setup()
{
Serial.begin(115200);
Expand All @@ -30,6 +32,7 @@ void setup()

}


void loop()
{
}
Expand Down Expand Up @@ -163,4 +166,4 @@ void test_6()
}


// -- END OF FILE --
// -- END OF FILE --
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"type": "git",
"url": "https://github.com/RobTillaart/GST.git"
},
"version": "0.1.2",
"version": "0.1.3",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=GST
version=0.1.2
version=0.1.3
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for Golden Standard Test, confusion matrix.
Expand Down
36 changes: 33 additions & 3 deletions test/unit_test_001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ unittest(test_constructor)
{
GST gst;

// default 0;
// default 0;
assertEqualFloat(gst.getTruePositive() , 0, 0.001);
assertEqualFloat(gst.getTrueNegative() , 0, 0.001);
assertEqualFloat(gst.getFalsePositive() , 0, 0.001);
Expand Down Expand Up @@ -88,7 +88,7 @@ unittest(test_add)
}


unittest(test_one)
unittest(test_output_functions_I)
{
GST gst;

Expand All @@ -112,6 +112,36 @@ unittest(test_one)
}


unittest(test_output_functions_II)
{
GST gst;

gst.setTruePositive(653);
gst.setTrueNegative(312);
gst.setFalsePositive(124);
gst.setFalseNegative(423);

assertEqualFloat(gst.LRplus(), 2.133860, 0.0001);
assertEqualFloat(gst.LRminus(), 0.549364, 0.0001);
assertEqualFloat(gst.prevalenceThreshold(), 0.406376, 0.0001);
assertEqualFloat(gst.threatScore(), 0.544167, 0.0001);

assertEqualFloat(gst.criticalSuccessIndex(), 0.544167, 0.0001);
assertEqualFloat(gst.prevalence(), 0.711640, 0.0001);
assertEqualFloat(gst.accuracy(), 0.638228, 0.0001);
assertEqualFloat(gst.balancedAccuracy(), 0.661237, 0.0001);
assertEqualFloat(gst.F1Score(), 0.704803, 0.0001);

assertEqualFloat(gst.MCC(), 0.292273, 0.0001);
assertEqualFloat(gst.FM(), 0.714162, 0.0001);
assertEqualFloat(gst.BM(), 0.322474, 0.0001);
assertEqualFloat(gst.MK(), 0.264902, 0.0001);
assertEqualFloat(gst.DOR(), 3.884240, 0.0001);
}


unittest_main()

// --------

// -- END OF FILE --

0 comments on commit 250b1e4

Please sign in to comment.