Skip to content

Commit e146531

Browse files
committed
0.1.0 GST
1 parent d76f508 commit e146531

File tree

13 files changed

+626
-0
lines changed

13 files changed

+626
-0
lines changed

libraries/GST/.arduino-ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
compile:
2+
# Choosing to run compilation tests on 2 different Arduino platforms
3+
platforms:
4+
- uno
5+
# - due
6+
# - zero
7+
# - leonardo
8+
- m4
9+
- esp32
10+
# - esp8266
11+
# - mega2560
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
name: Arduino-lint
3+
4+
on: [push, pull_request]
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: arduino/arduino-lint-action@v1
11+
with:
12+
library-manager: update
13+
compliance: strict
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
name: Arduino CI
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
runTest:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: ruby/setup-ruby@v1
13+
with:
14+
ruby-version: 2.6
15+
- run: |
16+
gem install arduino_ci
17+
arduino_ci.rb
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: JSON check
2+
3+
on:
4+
push:
5+
paths:
6+
- '**.json'
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: json-syntax-check
15+
uses: limitusus/json-syntax-check@v1
16+
with:
17+
pattern: "\\.json$"
18+

libraries/GST/GST.h

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#pragma once
2+
//
3+
// FILE: GST.h
4+
// VERSION: 0.1.0
5+
// PURPOSE: Arduino library for Gold Standard Test metrics
6+
// URL: https://github.com/RobTillaart/GST
7+
// https://en.wikipedia.org/wiki/Sensitivity_and_specificity
8+
// https://en.wikipedia.org/wiki/Confusion_matrix
9+
//
10+
// formula's based upon wikipedia.
11+
12+
13+
#define GST_LIB_VERSION (F("0.1.0"))
14+
15+
16+
class GST
17+
{
18+
public:
19+
GST() {};
20+
21+
// These 4 need to be filled in.
22+
void setTruePositive(float v) { TP = v; P = TP + FN; };
23+
void setTrueNegative(float v) { TN = v; N = TN + FP; };
24+
void setFalsePositive(float v) { FP = v; N = TN + FP; };
25+
void setFalseNegative(float v) { FN = v; P = TP + FN; };
26+
27+
float getTruePositive() { return TP; };
28+
float getTrueNegative() { return TN; };
29+
float getFalsePositive() { return FP; };
30+
float getFalseNegative() { return FN; };
31+
32+
float getTotal() { return P + N; };
33+
float getActualPositive() { return P; };
34+
float getActualNegative() { return N; };
35+
float getTestedPositive() { return TP + FP; };
36+
float getTestedNegative() { return TN + FN; };
37+
38+
float sensitivity() { return TPR(); };
39+
float specificity() { return TNR(); };
40+
41+
42+
43+
// true positive rate
44+
float TPR() { return TP / P; };
45+
// true negative rate
46+
float TNR() { return TN / N; };
47+
48+
// false negative rate
49+
float FNR() { return FN / (FN + TP); };
50+
// false positive rate
51+
float FPR() { return FP / (FP + TN); };
52+
53+
54+
55+
// positive predictive value
56+
float PPV() { return TP / (TP + FP); };
57+
// negative predictive value
58+
float NPV() { return TN / (TN + FN); };
59+
60+
// false discovery rate
61+
float FDR() { return FP / (FP + TP); };
62+
// false omission rate
63+
float FOR() { return FN / (FN + TN); };
64+
65+
66+
67+
// positive likelihood ratio
68+
float LRplus() { return TPR() / FPR(); };
69+
// negative likelihood ratio
70+
float LRminus() { return FNR() / TNR(); };
71+
72+
73+
74+
float prevalenceThreshold() { return sqrt(FPR()) / (sqrt(TPR()) + sqrt(FPR())); };
75+
float threatScore() { return TP / (TP + FN + FP); };
76+
float criticalSuccessIndex() { return threatScore(); };
77+
78+
79+
80+
float prevalence() { return P / (P + N); };
81+
float accuracy() { return (TP + TN) / (P + N); };
82+
float balancedAccuracy() { return (TPR() + TNR()) / 2; };
83+
float F1Score() { return (2 * TP)/(2 * TP + FP + FN); };
84+
85+
86+
87+
// Matthews correlation coefficient
88+
float MCC() { return (TP*TN-FP*FN)/sqrt((TP+FP)*(TP+FN)*(TN+FP)*(TN+FN)); };
89+
float phi() { return MCC(); };
90+
// Fowlkes–Mallows index
91+
float FM() { return sqrt(PPV()*TPR()); };
92+
// Bookmaker informedness
93+
float BM() { return TPR() + TNR() - 1; };
94+
// markedness
95+
float MK() { return PPV() + NPV() - 1; };
96+
float deltaP() { return MK(); };
97+
// diagnostic odds ratio
98+
float DOR() { return LRplus() / LRminus(); };
99+
100+
101+
private:
102+
float P = 0;
103+
float N = 0;
104+
float TP = 0;
105+
float TN = 0;
106+
float FP = 0;
107+
float FN = 0;
108+
};
109+
110+
111+
// -- END OF FILE --
112+

libraries/GST/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022-2022 Rob Tillaart
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

libraries/GST/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
[![Arduino CI](https://github.com/RobTillaart/GST/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
3+
[![Arduino-lint](https://github.com/RobTillaart/GST/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/GST/actions/workflows/arduino-lint.yml)
4+
[![JSON check](https://github.com/RobTillaart/GST/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/GST/actions/workflows/jsoncheck.yml)
5+
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/GST/blob/master/LICENSE)
6+
[![GitHub release](https://img.shields.io/github/release/RobTillaart/GST.svg?maxAge=3600)](https://github.com/RobTillaart/GST/releases)
7+
8+
9+
# GST
10+
11+
Arduino library for Gold Standard Test metrics.
12+
13+
14+
## Description
15+
16+
The GST library is **experimental**.
17+
18+
19+
#### Links
20+
21+
- https://en.wikipedia.org/wiki/Sensitivity_and_specificity
22+
- https://en.wikipedia.org/wiki/Confusion_matrix
23+
24+
25+
## Interface
26+
27+
See .h file
28+
29+
30+
## Future
31+
32+
- documentation
33+
- improve
34+
- more links?
35+
- test
36+
- complete the CI test coverage.
37+
- examples
38+
- add real life examples.
39+
- combination with a sensor? batch testing?
40+
- code
41+
- full name functions instead of acronyms. (wrap?)
42+
- is GST a good class name?

libraries/GST/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
# GST Changelog
3+
4+
5+
## 0.1.0 2022-02-25
6+
- initial version
7+
-
8+
9+

0 commit comments

Comments
 (0)