-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
605 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
compile: | ||
# Choosing to run compilation tests on 2 different Arduino platforms | ||
platforms: | ||
- uno | ||
# - due | ||
# - zero | ||
# - leonardo | ||
- m4 | ||
- esp32 | ||
# - esp8266 | ||
# - mega2560 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
name: Arduino-lint | ||
|
||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: arduino/arduino-lint-action@v1 | ||
with: | ||
library-manager: update | ||
compliance: strict |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Arduino CI | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
runTest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
- run: | | ||
gem install arduino_ci | ||
arduino_ci.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: JSON check | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.json' | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: json-syntax-check | ||
uses: limitusus/json-syntax-check@v1 | ||
with: | ||
pattern: "\\.json$" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#pragma once | ||
// | ||
// FILE: GST.h | ||
// VERSION: 0.1.0 | ||
// 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. | ||
|
||
|
||
#define GST_LIB_VERSION (F("0.1.0")) | ||
|
||
|
||
class GST | ||
{ | ||
public: | ||
GST() {}; | ||
|
||
// These 4 need to be filled in. | ||
void setTruePositive(float v) { TP = v; P = TP + FN; }; | ||
void setTrueNegative(float v) { TN = v; N = TN + FP; }; | ||
void setFalsePositive(float v) { FP = v; N = TN + FP; }; | ||
void setFalseNegative(float v) { FN = v; P = TP + FN; }; | ||
|
||
float getTruePositive() { return TP; }; | ||
float getTrueNegative() { return TN; }; | ||
float getFalsePositive() { return FP; }; | ||
float getFalseNegative() { return FN; }; | ||
|
||
float getTotal() { return P + N; }; | ||
float getActualPositive() { return P; }; | ||
float getActualNegative() { return N; }; | ||
float getTestedPositive() { return TP + FP; }; | ||
float getTestedNegative() { return TN + FN; }; | ||
|
||
float sensitivity() { return TPR(); }; | ||
float specificity() { return TNR(); }; | ||
|
||
|
||
|
||
// true positive rate | ||
float TPR() { return TP / P; }; | ||
// true negative rate | ||
float TNR() { return TN / N; }; | ||
|
||
// false negative rate | ||
float FNR() { return FN / (FN + TP); }; | ||
// false positive rate | ||
float FPR() { return FP / (FP + TN); }; | ||
|
||
|
||
|
||
// positive predictive value | ||
float PPV() { return TP / (TP + FP); }; | ||
// negative predictive value | ||
float NPV() { return TN / (TN + FN); }; | ||
|
||
// false discovery rate | ||
float FDR() { return FP / (FP + TP); }; | ||
// false omission rate | ||
float FOR() { return FN / (FN + TN); }; | ||
|
||
|
||
|
||
// positive likelihood ratio | ||
float LRplus() { return TPR() / FPR(); }; | ||
// negative likelihood ratio | ||
float LRminus() { return FNR() / TNR(); }; | ||
|
||
|
||
|
||
float prevalenceThreshold() { return sqrt(FPR()) / (sqrt(TPR()) + sqrt(FPR())); }; | ||
float threatScore() { return TP / (TP + FN + FP); }; | ||
float criticalSuccessIndex() { return threatScore(); }; | ||
|
||
|
||
|
||
float prevalence() { return P / (P + N); }; | ||
float accuracy() { return (TP + TN) / (P + N); }; | ||
float balancedAccuracy() { return (TPR() + TNR()) / 2; }; | ||
float F1Score() { return (2 * TP)/(2 * TP + FP + FN); }; | ||
|
||
|
||
|
||
// Matthews correlation coefficient | ||
float MCC() { return (TP*TN-FP*FN)/sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)); }; | ||
float phi() { return MCC(); }; | ||
// Fowlkes–Mallows index | ||
float FM() { return sqrt(PPV()*TPR()); }; | ||
// Bookmaker informedness | ||
float BM() { return TPR() + TNR() - 1; }; | ||
// markedness | ||
float MK() { return PPV() + NPV() - 1; }; | ||
float deltaP() { return MK(); }; | ||
// diagnostic odds ratio | ||
float DOR() { return LRplus() / LRminus(); }; | ||
|
||
|
||
private: | ||
float P = 0; | ||
float N = 0; | ||
float TP = 0; | ||
float TN = 0; | ||
float FP = 0; | ||
float FN = 0; | ||
}; | ||
|
||
|
||
// -- END OF FILE -- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,42 @@ | ||
|
||
[![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) | ||
[![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) | ||
|
||
|
||
# GST | ||
Arduino library for Gold Standard Test metrics | ||
|
||
Arduino library for Gold Standard Test metrics. | ||
|
||
|
||
## Description | ||
|
||
The GST library is **experimental**. | ||
|
||
|
||
#### Links | ||
|
||
- https://en.wikipedia.org/wiki/Sensitivity_and_specificity | ||
- https://en.wikipedia.org/wiki/Confusion_matrix | ||
|
||
|
||
## Interface | ||
|
||
See .h file | ||
|
||
|
||
## Future | ||
|
||
- documentation | ||
- improve | ||
- more links? | ||
- test | ||
- complete the CI test coverage. | ||
- examples | ||
- add real life examples. | ||
- combination with a sensor? batch testing? | ||
- code | ||
- full name functions instead of acronyms. (wrap?) | ||
- is GST a good class name? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
# GST Changelog | ||
|
||
|
||
## 0.1.0 2022-02-25 | ||
- initial version | ||
- | ||
|
||
|
Oops, something went wrong.