Skip to content

Commit

Permalink
initial version (#1)
Browse files Browse the repository at this point in the history
* initial version
  • Loading branch information
RobTillaart committed Feb 27, 2022
1 parent 815fe1a commit 0f5486f
Show file tree
Hide file tree
Showing 13 changed files with 605 additions and 2 deletions.
11 changes: 11 additions & 0 deletions .arduino-ci.yml
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
13 changes: 13 additions & 0 deletions .github/workflows/arduino-lint.yml
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
17 changes: 17 additions & 0 deletions .github/workflows/arduino_test_runner.yml
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
18 changes: 18 additions & 0 deletions .github/workflows/jsoncheck.yml
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$"

112 changes: 112 additions & 0 deletions GST.h
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 --

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Rob Tillaart
Copyright (c) 2022-2022 Rob Tillaart

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
42 changes: 41 additions & 1 deletion README.md
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?
9 changes: 9 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

# GST Changelog


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


Loading

0 comments on commit 0f5486f

Please sign in to comment.