From 9d217ae6a63baa99fea8c759babe75273188316c Mon Sep 17 00:00:00 2001 From: Maximilian Berkmann Date: Tue, 23 Jul 2019 19:38:13 +0100 Subject: [PATCH] fix(confusionMatrix): minor rectification (#22) * fix(confusionmatrix): minor rectification * feat(playground): added a dry-run option --- playground/playground-fullStats-copy.json | 533 ++++++++++++++++++++++ playground/playground-fullStats.json | 454 +++++++++--------- playground/playground.js | 2 +- src/confusionMatrix.js | 7 +- 4 files changed, 764 insertions(+), 232 deletions(-) create mode 100644 playground/playground-fullStats-copy.json diff --git a/playground/playground-fullStats-copy.json b/playground/playground-fullStats-copy.json new file mode 100644 index 0000000..8201df6 --- /dev/null +++ b/playground/playground-fullStats-copy.json @@ -0,0 +1,533 @@ +{ + "total": 73, + "correctPredictions": 38, + "incorrectPredictions": 35, + "classes": [ + "blog", + "bug", + "business", + "code", + "content", + "design", + "doc", + "eventOrganizing", + "example", + "financial", + "fundingFinding", + "ideas", + "infra", + "maintenance", + "null", + "platform", + "plugin", + "projectManagement", + "question", + "review", + "security", + "talk", + "test", + "tool", + "translation", + "tutorial", + "userTesting", + "video" + ], + "microAvg": { + "accuracy": 0.5205479452054794, + "f1": 0.5205479452054794, + "fallOut": 0.017757483510908167, + "missRate": 0.4794520547945205, + "precision": 0.5205479452054794, + "prevalence": 0.03571428571428571, + "recall": 0.5205479452054794, + "specificity": 0.9822425164890918 + }, + "macroAvg": { + "accuracy": 0.9657534246575343, + "f1": null, + "fallOut": 0.025875062762786567, + "missRate": null, + "precision": null, + "prevalence": 0.03571428571428571, + "recall": null, + "specificity": 0.9741249372372136 + }, + "results": { + "blog": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "bug": { + "total": 3, + "samplePortion": 0.0410958904109589, + "tp": 1, + "fp": 0, + "fn": 2, + "tn": 70, + "accuracy": 0.9726027397260274, + "f1": 0.5, + "fallOut": 0, + "missRate": 0.6666666666666666, + "precision": 1, + "prevalence": 0.0410958904109589, + "recall": 0.3333333333333333, + "specificity": 1, + "confusionMatrix": [[1, 0], [2, 70]] + }, + "business": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "code": { + "total": 6, + "samplePortion": 0.0821917808219178, + "tp": 2, + "fp": 2, + "fn": 4, + "tn": 65, + "accuracy": 0.9178082191780822, + "f1": 0.4, + "fallOut": 0.029850746268656716, + "missRate": 0.6666666666666666, + "precision": 0.5, + "prevalence": 0.0821917808219178, + "recall": 0.3333333333333333, + "specificity": 0.9701492537313433, + "confusionMatrix": [[2, 2], [4, 65]] + }, + "content": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "design": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "doc": { + "total": 4, + "samplePortion": 0.0547945205479452, + "tp": 3, + "fp": 0, + "fn": 1, + "tn": 69, + "accuracy": 0.9863013698630136, + "f1": 0.8571428571428571, + "fallOut": 0, + "missRate": 0.25, + "precision": 1, + "prevalence": 0.0547945205479452, + "recall": 0.75, + "specificity": 1, + "confusionMatrix": [[3, 0], [1, 69]] + }, + "eventOrganizing": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "example": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "financial": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "fundingFinding": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "ideas": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "infra": { + "total": 6, + "samplePortion": 0.0821917808219178, + "tp": 3, + "fp": 0, + "fn": 3, + "tn": 67, + "accuracy": 0.958904109589041, + "f1": 0.6666666666666666, + "fallOut": 0, + "missRate": 0.5, + "precision": 1, + "prevalence": 0.0821917808219178, + "recall": 0.5, + "specificity": 1, + "confusionMatrix": [[3, 0], [3, 67]] + }, + "maintenance": { + "total": 4, + "samplePortion": 0.0547945205479452, + "tp": 1, + "fp": 1, + "fn": 3, + "tn": 68, + "accuracy": 0.9452054794520548, + "f1": 0.3333333333333333, + "fallOut": 0.014492753623188406, + "missRate": 0.75, + "precision": 0.5, + "prevalence": 0.0547945205479452, + "recall": 0.25, + "specificity": 0.9855072463768116, + "confusionMatrix": [[1, 1], [3, 68]] + }, + "null": { + "total": 27, + "samplePortion": 0.3698630136986301, + "tp": 25, + "fp": 30, + "fn": 2, + "tn": 16, + "accuracy": 0.5616438356164384, + "f1": 0.6097560975609756, + "fallOut": 0.6521739130434783, + "missRate": 0.07407407407407407, + "precision": 0.45454545454545453, + "prevalence": 0.3698630136986301, + "recall": 0.9259259259259259, + "specificity": 0.34782608695652173, + "confusionMatrix": [[25, 30], [2, 16]] + }, + "platform": { + "total": 7, + "samplePortion": 0.0958904109589041, + "tp": 1, + "fp": 0, + "fn": 6, + "tn": 66, + "accuracy": 0.9178082191780822, + "f1": 0.25, + "fallOut": 0, + "missRate": 0.8571428571428571, + "precision": 1, + "prevalence": 0.0958904109589041, + "recall": 0.14285714285714285, + "specificity": 1, + "confusionMatrix": [[1, 0], [6, 66]] + }, + "plugin": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "projectManagement": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "question": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "review": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "security": { + "total": 2, + "samplePortion": 0.0273972602739726, + "tp": 1, + "fp": 0, + "fn": 1, + "tn": 71, + "accuracy": 0.9863013698630136, + "f1": 0.6666666666666666, + "fallOut": 0, + "missRate": 0.5, + "precision": 1, + "prevalence": 0.0273972602739726, + "recall": 0.5, + "specificity": 1, + "confusionMatrix": [[1, 0], [1, 71]] + }, + "talk": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "test": { + "total": 3, + "samplePortion": 0.0410958904109589, + "tp": 1, + "fp": 1, + "fn": 2, + "tn": 69, + "accuracy": 0.958904109589041, + "f1": 0.4, + "fallOut": 0.014285714285714285, + "missRate": 0.6666666666666666, + "precision": 0.5, + "prevalence": 0.0410958904109589, + "recall": 0.3333333333333333, + "specificity": 0.9857142857142858, + "confusionMatrix": [[1, 1], [2, 69]] + }, + "tool": { + "total": 2, + "samplePortion": 0.0273972602739726, + "tp": 0, + "fp": 0, + "fn": 2, + "tn": 71, + "accuracy": 0.9726027397260274, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0273972602739726, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [2, 71]] + }, + "translation": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "tutorial": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, + "fp": 0, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [1, 72]] + }, + "userTesting": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 1, + "fn": 0, + "tn": 72, + "accuracy": 0.9863013698630136, + "f1": null, + "fallOut": 0.0136986301369863, + "missRate": null, + "precision": 0, + "prevalence": 0, + "recall": null, + "specificity": 0.9863013698630136, + "confusionMatrix": [[0, 1], [0, 72]] + }, + "video": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + } + } +} diff --git a/playground/playground-fullStats.json b/playground/playground-fullStats.json index 8201df6..cb4de1c 100644 --- a/playground/playground-fullStats.json +++ b/playground/playground-fullStats.json @@ -1,7 +1,7 @@ { "total": 73, - "correctPredictions": 38, - "incorrectPredictions": 35, + "correctPredictions": 47, + "incorrectPredictions": 26, "classes": [ "blog", "bug", @@ -33,59 +33,59 @@ "video" ], "microAvg": { - "accuracy": 0.5205479452054794, - "f1": 0.5205479452054794, - "fallOut": 0.017757483510908167, - "missRate": 0.4794520547945205, - "precision": 0.5205479452054794, + "accuracy": 0.6438356164383562, + "f1": 0.6438356164383562, + "fallOut": 0.013191273465246067, + "missRate": 0.3561643835616438, + "precision": 0.6438356164383562, "prevalence": 0.03571428571428571, - "recall": 0.5205479452054794, - "specificity": 0.9822425164890918 + "recall": 0.6438356164383562, + "specificity": 0.9868087265347539 }, "macroAvg": { - "accuracy": 0.9657534246575343, + "accuracy": 0.9745596868884542, "f1": null, - "fallOut": 0.025875062762786567, + "fallOut": 0.022092799854683657, "missRate": null, "precision": null, "prevalence": 0.03571428571428571, "recall": null, - "specificity": 0.9741249372372136 + "specificity": 0.9779072001453163 }, "results": { "blog": { - "total": 1, - "samplePortion": 0.0136986301369863, + "total": 0, + "samplePortion": 0, "tp": 0, "fp": 0, - "fn": 1, - "tn": 72, - "accuracy": 0.9863013698630136, + "fn": 0, + "tn": 73, + "accuracy": 1, "f1": null, "fallOut": 0, - "missRate": 1, + "missRate": null, "precision": null, - "prevalence": 0.0136986301369863, - "recall": 0, + "prevalence": 0, + "recall": null, "specificity": 1, - "confusionMatrix": [[0, 0], [1, 72]] + "confusionMatrix": [[0, 0], [0, 73]] }, "bug": { - "total": 3, - "samplePortion": 0.0410958904109589, - "tp": 1, - "fp": 0, - "fn": 2, + "total": 2, + "samplePortion": 0.0273972602739726, + "tp": 2, + "fp": 1, + "fn": 0, "tn": 70, - "accuracy": 0.9726027397260274, - "f1": 0.5, - "fallOut": 0, - "missRate": 0.6666666666666666, - "precision": 1, - "prevalence": 0.0410958904109589, - "recall": 0.3333333333333333, - "specificity": 1, - "confusionMatrix": [[1, 0], [2, 70]] + "accuracy": 0.9863013698630136, + "f1": 0.8, + "fallOut": 0.014084507042253521, + "missRate": 0, + "precision": 0.6666666666666666, + "prevalence": 0.0273972602739726, + "recall": 1, + "specificity": 0.9859154929577465, + "confusionMatrix": [[2, 1], [0, 70]] }, "business": { "total": 1, @@ -105,40 +105,23 @@ "confusionMatrix": [[0, 0], [1, 72]] }, "code": { - "total": 6, - "samplePortion": 0.0821917808219178, - "tp": 2, - "fp": 2, + "total": 9, + "samplePortion": 0.1232876712328767, + "tp": 5, + "fp": 1, "fn": 4, - "tn": 65, - "accuracy": 0.9178082191780822, - "f1": 0.4, - "fallOut": 0.029850746268656716, - "missRate": 0.6666666666666666, - "precision": 0.5, - "prevalence": 0.0821917808219178, - "recall": 0.3333333333333333, - "specificity": 0.9701492537313433, - "confusionMatrix": [[2, 2], [4, 65]] + "tn": 63, + "accuracy": 0.9315068493150684, + "f1": 0.6666666666666667, + "fallOut": 0.015625, + "missRate": 0.4444444444444444, + "precision": 0.8333333333333334, + "prevalence": 0.1232876712328767, + "recall": 0.5555555555555556, + "specificity": 0.984375, + "confusionMatrix": [[5, 1], [4, 63]] }, "content": { - "total": 1, - "samplePortion": 0.0136986301369863, - "tp": 0, - "fp": 0, - "fn": 1, - "tn": 72, - "accuracy": 0.9863013698630136, - "f1": null, - "fallOut": 0, - "missRate": 1, - "precision": null, - "prevalence": 0.0136986301369863, - "recall": 0, - "specificity": 1, - "confusionMatrix": [[0, 0], [1, 72]] - }, - "design": { "total": 0, "samplePortion": 0, "tp": 0, @@ -155,41 +138,41 @@ "specificity": 1, "confusionMatrix": [[0, 0], [0, 73]] }, - "doc": { - "total": 4, - "samplePortion": 0.0547945205479452, - "tp": 3, + "design": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 0, "fp": 0, "fn": 1, - "tn": 69, + "tn": 72, "accuracy": 0.9863013698630136, - "f1": 0.8571428571428571, + "f1": null, "fallOut": 0, - "missRate": 0.25, - "precision": 1, - "prevalence": 0.0547945205479452, - "recall": 0.75, + "missRate": 1, + "precision": null, + "prevalence": 0.0136986301369863, + "recall": 0, "specificity": 1, - "confusionMatrix": [[3, 0], [1, 69]] + "confusionMatrix": [[0, 0], [1, 72]] }, - "eventOrganizing": { - "total": 0, - "samplePortion": 0, - "tp": 0, + "doc": { + "total": 3, + "samplePortion": 0.0410958904109589, + "tp": 2, "fp": 0, - "fn": 0, - "tn": 73, - "accuracy": 1, - "f1": null, + "fn": 1, + "tn": 70, + "accuracy": 0.9863013698630136, + "f1": 0.8, "fallOut": 0, - "missRate": null, - "precision": null, - "prevalence": 0, - "recall": null, + "missRate": 0.3333333333333333, + "precision": 1, + "prevalence": 0.0410958904109589, + "recall": 0.6666666666666666, "specificity": 1, - "confusionMatrix": [[0, 0], [0, 73]] + "confusionMatrix": [[2, 0], [1, 70]] }, - "example": { + "eventOrganizing": { "total": 1, "samplePortion": 0.0136986301369863, "tp": 0, @@ -206,22 +189,39 @@ "specificity": 1, "confusionMatrix": [[0, 0], [1, 72]] }, - "financial": { + "example": { "total": 1, "samplePortion": 0.0136986301369863, + "tp": 1, + "fp": 1, + "fn": 0, + "tn": 71, + "accuracy": 0.9863013698630136, + "f1": 0.6666666666666666, + "fallOut": 0.013888888888888888, + "missRate": 0, + "precision": 0.5, + "prevalence": 0.0136986301369863, + "recall": 1, + "specificity": 0.9861111111111112, + "confusionMatrix": [[1, 1], [0, 71]] + }, + "financial": { + "total": 0, + "samplePortion": 0, "tp": 0, "fp": 0, - "fn": 1, - "tn": 72, - "accuracy": 0.9863013698630136, + "fn": 0, + "tn": 73, + "accuracy": 1, "f1": null, "fallOut": 0, - "missRate": 1, + "missRate": null, "precision": null, - "prevalence": 0.0136986301369863, - "recall": 0, + "prevalence": 0, + "recall": null, "specificity": 1, - "confusionMatrix": [[0, 0], [1, 72]] + "confusionMatrix": [[0, 0], [0, 73]] }, "fundingFinding": { "total": 0, @@ -241,6 +241,23 @@ "confusionMatrix": [[0, 0], [0, 73]] }, "ideas": { + "total": 4, + "samplePortion": 0.0547945205479452, + "tp": 1, + "fp": 0, + "fn": 3, + "tn": 69, + "accuracy": 0.958904109589041, + "f1": 0.4, + "fallOut": 0, + "missRate": 0.75, + "precision": 1, + "prevalence": 0.0547945205479452, + "recall": 0.25, + "specificity": 1, + "confusionMatrix": [[1, 0], [3, 69]] + }, + "infra": { "total": 1, "samplePortion": 0.0136986301369863, "tp": 0, @@ -257,92 +274,58 @@ "specificity": 1, "confusionMatrix": [[0, 0], [1, 72]] }, - "infra": { - "total": 6, - "samplePortion": 0.0821917808219178, - "tp": 3, + "maintenance": { + "total": 3, + "samplePortion": 0.0410958904109589, + "tp": 1, "fp": 0, - "fn": 3, - "tn": 67, - "accuracy": 0.958904109589041, - "f1": 0.6666666666666666, + "fn": 2, + "tn": 70, + "accuracy": 0.9726027397260274, + "f1": 0.5, "fallOut": 0, - "missRate": 0.5, + "missRate": 0.6666666666666666, "precision": 1, - "prevalence": 0.0821917808219178, - "recall": 0.5, + "prevalence": 0.0410958904109589, + "recall": 0.3333333333333333, "specificity": 1, - "confusionMatrix": [[3, 0], [3, 67]] - }, - "maintenance": { - "total": 4, - "samplePortion": 0.0547945205479452, - "tp": 1, - "fp": 1, - "fn": 3, - "tn": 68, - "accuracy": 0.9452054794520548, - "f1": 0.3333333333333333, - "fallOut": 0.014492753623188406, - "missRate": 0.75, - "precision": 0.5, - "prevalence": 0.0547945205479452, - "recall": 0.25, - "specificity": 0.9855072463768116, - "confusionMatrix": [[1, 1], [3, 68]] + "confusionMatrix": [[1, 0], [2, 70]] }, "null": { - "total": 27, - "samplePortion": 0.3698630136986301, - "tp": 25, - "fp": 30, + "total": 33, + "samplePortion": 0.4520547945205479, + "tp": 31, + "fp": 23, "fn": 2, - "tn": 16, - "accuracy": 0.5616438356164384, - "f1": 0.6097560975609756, - "fallOut": 0.6521739130434783, - "missRate": 0.07407407407407407, - "precision": 0.45454545454545453, - "prevalence": 0.3698630136986301, - "recall": 0.9259259259259259, - "specificity": 0.34782608695652173, - "confusionMatrix": [[25, 30], [2, 16]] + "tn": 17, + "accuracy": 0.6575342465753424, + "f1": 0.7126436781609197, + "fallOut": 0.575, + "missRate": 0.06060606060606061, + "precision": 0.5740740740740741, + "prevalence": 0.4520547945205479, + "recall": 0.9393939393939394, + "specificity": 0.425, + "confusionMatrix": [[31, 23], [2, 17]] }, "platform": { - "total": 7, - "samplePortion": 0.0958904109589041, - "tp": 1, + "total": 5, + "samplePortion": 0.0684931506849315, + "tp": 2, "fp": 0, - "fn": 6, - "tn": 66, - "accuracy": 0.9178082191780822, - "f1": 0.25, + "fn": 3, + "tn": 68, + "accuracy": 0.958904109589041, + "f1": 0.5714285714285715, "fallOut": 0, - "missRate": 0.8571428571428571, + "missRate": 0.6, "precision": 1, - "prevalence": 0.0958904109589041, - "recall": 0.14285714285714285, + "prevalence": 0.0684931506849315, + "recall": 0.4, "specificity": 1, - "confusionMatrix": [[1, 0], [6, 66]] + "confusionMatrix": [[2, 0], [3, 68]] }, "plugin": { - "total": 1, - "samplePortion": 0.0136986301369863, - "tp": 0, - "fp": 0, - "fn": 1, - "tn": 72, - "accuracy": 0.9863013698630136, - "f1": null, - "fallOut": 0, - "missRate": 1, - "precision": null, - "prevalence": 0.0136986301369863, - "recall": 0, - "specificity": 1, - "confusionMatrix": [[0, 0], [1, 72]] - }, - "projectManagement": { "total": 0, "samplePortion": 0, "tp": 0, @@ -359,22 +342,39 @@ "specificity": 1, "confusionMatrix": [[0, 0], [0, 73]] }, - "question": { - "total": 0, - "samplePortion": 0, + "projectManagement": { + "total": 1, + "samplePortion": 0.0136986301369863, "tp": 0, "fp": 0, - "fn": 0, - "tn": 73, - "accuracy": 1, + "fn": 1, + "tn": 72, + "accuracy": 0.9863013698630136, "f1": null, "fallOut": 0, - "missRate": null, + "missRate": 1, "precision": null, - "prevalence": 0, - "recall": null, + "prevalence": 0.0136986301369863, + "recall": 0, "specificity": 1, - "confusionMatrix": [[0, 0], [0, 73]] + "confusionMatrix": [[0, 0], [1, 72]] + }, + "question": { + "total": 1, + "samplePortion": 0.0136986301369863, + "tp": 1, + "fp": 0, + "fn": 0, + "tn": 72, + "accuracy": 1, + "f1": 1, + "fallOut": 0, + "missRate": 0, + "precision": 1, + "prevalence": 0.0136986301369863, + "recall": 1, + "specificity": 1, + "confusionMatrix": [[1, 0], [0, 72]] }, "review": { "total": 0, @@ -394,21 +394,21 @@ "confusionMatrix": [[0, 0], [0, 73]] }, "security": { - "total": 2, - "samplePortion": 0.0273972602739726, + "total": 1, + "samplePortion": 0.0136986301369863, "tp": 1, "fp": 0, - "fn": 1, - "tn": 71, - "accuracy": 0.9863013698630136, - "f1": 0.6666666666666666, + "fn": 0, + "tn": 72, + "accuracy": 1, + "f1": 1, "fallOut": 0, - "missRate": 0.5, + "missRate": 0, "precision": 1, - "prevalence": 0.0273972602739726, - "recall": 0.5, + "prevalence": 0.0136986301369863, + "recall": 1, "specificity": 1, - "confusionMatrix": [[1, 0], [1, 71]] + "confusionMatrix": [[1, 0], [0, 72]] }, "talk": { "total": 0, @@ -430,19 +430,19 @@ "test": { "total": 3, "samplePortion": 0.0410958904109589, - "tp": 1, - "fp": 1, - "fn": 2, - "tn": 69, + "tp": 0, + "fp": 0, + "fn": 3, + "tn": 70, "accuracy": 0.958904109589041, - "f1": 0.4, - "fallOut": 0.014285714285714285, - "missRate": 0.6666666666666666, - "precision": 0.5, + "f1": null, + "fallOut": 0, + "missRate": 1, + "precision": null, "prevalence": 0.0410958904109589, - "recall": 0.3333333333333333, - "specificity": 0.9857142857142858, - "confusionMatrix": [[1, 1], [2, 69]] + "recall": 0, + "specificity": 1, + "confusionMatrix": [[0, 0], [3, 70]] }, "tool": { "total": 2, @@ -462,23 +462,40 @@ "confusionMatrix": [[0, 0], [2, 71]] }, "translation": { - "total": 1, - "samplePortion": 0.0136986301369863, + "total": 0, + "samplePortion": 0, "tp": 0, "fp": 0, - "fn": 1, - "tn": 72, - "accuracy": 0.9863013698630136, + "fn": 0, + "tn": 73, + "accuracy": 1, "f1": null, "fallOut": 0, - "missRate": 1, + "missRate": null, "precision": null, - "prevalence": 0.0136986301369863, - "recall": 0, + "prevalence": 0, + "recall": null, "specificity": 1, - "confusionMatrix": [[0, 0], [1, 72]] + "confusionMatrix": [[0, 0], [0, 73]] }, "tutorial": { + "total": 0, + "samplePortion": 0, + "tp": 0, + "fp": 0, + "fn": 0, + "tn": 73, + "accuracy": 1, + "f1": null, + "fallOut": 0, + "missRate": null, + "precision": null, + "prevalence": 0, + "recall": null, + "specificity": 1, + "confusionMatrix": [[0, 0], [0, 73]] + }, + "userTesting": { "total": 1, "samplePortion": 0.0136986301369863, "tp": 0, @@ -495,23 +512,6 @@ "specificity": 1, "confusionMatrix": [[0, 0], [1, 72]] }, - "userTesting": { - "total": 0, - "samplePortion": 0, - "tp": 0, - "fp": 1, - "fn": 0, - "tn": 72, - "accuracy": 0.9863013698630136, - "f1": null, - "fallOut": 0.0136986301369863, - "missRate": null, - "precision": 0, - "prevalence": 0, - "recall": null, - "specificity": 0.9863013698630136, - "confusionMatrix": [[0, 1], [0, 72]] - }, "video": { "total": 0, "samplePortion": 0, diff --git a/playground/playground.js b/playground/playground.js index 24a9669..e81ca5c 100644 --- a/playground/playground.js +++ b/playground/playground.js @@ -4,7 +4,7 @@ const Learner = require('../src') let learner = null -if (existsSync('playground-learner.json')) { +if (existsSync('playground-learner.json') && !process.env.DRY) { //If there's already a JSON version of a learner, use it's past training samples const pgl = require('./playground-learner.json') learner = Learner.fromJSON(pgl) diff --git a/src/confusionMatrix.js b/src/confusionMatrix.js index 8832fe8..e56fe3f 100644 --- a/src/confusionMatrix.js +++ b/src/confusionMatrix.js @@ -274,8 +274,7 @@ class ConfusionMatrix { * @protected */ getMicroAccuracy() { - const Ts = this.getTrue() - return Ts / (Ts + this.getFalse()) + return this.getTrue() / this.getTotal() } /** @@ -629,8 +628,8 @@ class ConfusionMatrix { getShortStats() { return `Total: ${this.getTotal()}\nTrue: ${this.getTrue()}\nFalse: ${this.getFalse()}\nAccuracy: ${this.getMicroAccuracy() * 100}%\nPrecision: ${this.getMicroPrecision() * - 100}%\nRecall: ${this.getMicroPrecision() * - 100}%\nF1: ${this.getMicroF1() * 100}%` + 100}%\nRecall: ${this.getMicroRecall() * 100}%\nF1: ${this.getMicroF1() * + 100}%` } /**