nlptoolkit-classification 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (178) hide show
  1. package/dist/Attribute/Attribute.js +6 -16
  2. package/dist/Attribute/Attribute.js.map +1 -1
  3. package/dist/Attribute/AttributeType.js +22 -32
  4. package/dist/Attribute/AttributeType.js.map +1 -1
  5. package/dist/Attribute/BinaryAttribute.js +14 -24
  6. package/dist/Attribute/BinaryAttribute.js.map +1 -1
  7. package/dist/Attribute/ContinuousAttribute.js +46 -55
  8. package/dist/Attribute/ContinuousAttribute.js.map +1 -1
  9. package/dist/Attribute/DiscreteAttribute.js +38 -48
  10. package/dist/Attribute/DiscreteAttribute.js.map +1 -1
  11. package/dist/Attribute/DiscreteIndexedAttribute.js +47 -55
  12. package/dist/Attribute/DiscreteIndexedAttribute.js.map +1 -1
  13. package/dist/DataSet/DataDefinition.js +115 -123
  14. package/dist/DataSet/DataDefinition.js.map +1 -1
  15. package/dist/DataSet/DataSet.js +268 -245
  16. package/dist/DataSet/DataSet.js.map +1 -1
  17. package/dist/DistanceMetric/DistanceMetric.js +2 -12
  18. package/dist/DistanceMetric/EuclidianDistance.js +27 -37
  19. package/dist/DistanceMetric/EuclidianDistance.js.map +1 -1
  20. package/dist/DistanceMetric/MahalanobisDistance.js +27 -36
  21. package/dist/DistanceMetric/MahalanobisDistance.js.map +1 -1
  22. package/dist/Experiment/BootstrapRun.js +31 -40
  23. package/dist/Experiment/BootstrapRun.js.map +1 -1
  24. package/dist/Experiment/Experiment.js +46 -53
  25. package/dist/Experiment/Experiment.js.map +1 -1
  26. package/dist/Experiment/KFoldRun.js +45 -54
  27. package/dist/Experiment/KFoldRun.js.map +1 -1
  28. package/dist/Experiment/KFoldRunSeparateTest.js +48 -58
  29. package/dist/Experiment/KFoldRunSeparateTest.js.map +1 -1
  30. package/dist/Experiment/MultipleRun.js +2 -12
  31. package/dist/Experiment/MxKFoldRun.js +31 -40
  32. package/dist/Experiment/MxKFoldRun.js.map +1 -1
  33. package/dist/Experiment/MxKFoldRunSeparateTest.js +35 -44
  34. package/dist/Experiment/MxKFoldRunSeparateTest.js.map +1 -1
  35. package/dist/Experiment/SingleRun.js +2 -12
  36. package/dist/Experiment/SingleRunWithK.js +39 -48
  37. package/dist/Experiment/SingleRunWithK.js.map +1 -1
  38. package/dist/Experiment/StratifiedKFoldRun.js +26 -36
  39. package/dist/Experiment/StratifiedKFoldRun.js.map +1 -1
  40. package/dist/Experiment/StratifiedKFoldRunSeparateTest.js +30 -40
  41. package/dist/Experiment/StratifiedKFoldRunSeparateTest.js.map +1 -1
  42. package/dist/Experiment/StratifiedMxKFoldRun.js +29 -39
  43. package/dist/Experiment/StratifiedMxKFoldRun.js.map +1 -1
  44. package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js +34 -43
  45. package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js.map +1 -1
  46. package/dist/Experiment/StratifiedSingleRunWithK.js +27 -36
  47. package/dist/Experiment/StratifiedSingleRunWithK.js.map +1 -1
  48. package/dist/FeatureSelection/BackwardSelection.js +26 -36
  49. package/dist/FeatureSelection/BackwardSelection.js.map +1 -1
  50. package/dist/FeatureSelection/FeatureSubSet.js +72 -82
  51. package/dist/FeatureSelection/FeatureSubSet.js.map +1 -1
  52. package/dist/FeatureSelection/FloatingSelection.js +25 -35
  53. package/dist/FeatureSelection/FloatingSelection.js.map +1 -1
  54. package/dist/FeatureSelection/ForwardSelection.js +25 -35
  55. package/dist/FeatureSelection/ForwardSelection.js.map +1 -1
  56. package/dist/FeatureSelection/SubSetSelection.js +69 -78
  57. package/dist/FeatureSelection/SubSetSelection.js.map +1 -1
  58. package/dist/Filter/DiscreteToContinuous.js +50 -60
  59. package/dist/Filter/DiscreteToContinuous.js.map +1 -1
  60. package/dist/Filter/DiscreteToIndexed.js +40 -50
  61. package/dist/Filter/DiscreteToIndexed.js.map +1 -1
  62. package/dist/Filter/FeatureFilter.js +23 -32
  63. package/dist/Filter/FeatureFilter.js.map +1 -1
  64. package/dist/Filter/LaryFilter.js +46 -55
  65. package/dist/Filter/LaryFilter.js.map +1 -1
  66. package/dist/Filter/LaryToBinary.js +48 -58
  67. package/dist/Filter/LaryToBinary.js.map +1 -1
  68. package/dist/Filter/Normalize.js +33 -41
  69. package/dist/Filter/Normalize.js.map +1 -1
  70. package/dist/Filter/Pca.js +86 -96
  71. package/dist/Filter/Pca.js.map +1 -1
  72. package/dist/Filter/TrainedFeatureFilter.js +14 -24
  73. package/dist/Filter/TrainedFeatureFilter.js.map +1 -1
  74. package/dist/Instance/CompositeInstance.js +46 -56
  75. package/dist/Instance/CompositeInstance.js.map +1 -1
  76. package/dist/Instance/Instance.js +145 -154
  77. package/dist/Instance/Instance.js.map +1 -1
  78. package/dist/InstanceList/InstanceList.js +466 -443
  79. package/dist/InstanceList/InstanceList.js.map +1 -1
  80. package/dist/InstanceList/InstanceListOfSameClass.js +23 -32
  81. package/dist/InstanceList/InstanceListOfSameClass.js.map +1 -1
  82. package/dist/InstanceList/Partition.js +167 -177
  83. package/dist/InstanceList/Partition.js.map +1 -1
  84. package/dist/Model/DecisionTree/DecisionCondition.js +71 -80
  85. package/dist/Model/DecisionTree/DecisionCondition.js.map +1 -1
  86. package/dist/Model/DecisionTree/DecisionNode.js +302 -311
  87. package/dist/Model/DecisionTree/DecisionNode.js.map +1 -1
  88. package/dist/Model/DecisionTree/DecisionStump.js +22 -32
  89. package/dist/Model/DecisionTree/DecisionStump.js.map +1 -1
  90. package/dist/Model/DecisionTree/DecisionTree.js +89 -98
  91. package/dist/Model/DecisionTree/DecisionTree.js.map +1 -1
  92. package/dist/Model/DummyModel.js +64 -73
  93. package/dist/Model/DummyModel.js.map +1 -1
  94. package/dist/Model/Ensemble/BaggingModel.js +34 -44
  95. package/dist/Model/Ensemble/BaggingModel.js.map +1 -1
  96. package/dist/Model/Ensemble/RandomForestModel.js +31 -41
  97. package/dist/Model/Ensemble/RandomForestModel.js.map +1 -1
  98. package/dist/Model/Ensemble/TreeEnsembleModel.js +55 -64
  99. package/dist/Model/Ensemble/TreeEnsembleModel.js.map +1 -1
  100. package/dist/Model/Model.js +130 -140
  101. package/dist/Model/Model.js.map +1 -1
  102. package/dist/Model/NeuralNetwork/DeepNetworkModel.js +162 -169
  103. package/dist/Model/NeuralNetwork/DeepNetworkModel.js.map +1 -1
  104. package/dist/Model/NeuralNetwork/LinearPerceptronModel.js +69 -78
  105. package/dist/Model/NeuralNetwork/LinearPerceptronModel.js.map +1 -1
  106. package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js +112 -120
  107. package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js.map +1 -1
  108. package/dist/Model/NeuralNetwork/NeuralNetworkModel.js +197 -201
  109. package/dist/Model/NeuralNetwork/NeuralNetworkModel.js.map +1 -1
  110. package/dist/Model/NonParametric/KnnInstance.js +21 -29
  111. package/dist/Model/NonParametric/KnnInstance.js.map +1 -1
  112. package/dist/Model/NonParametric/KnnModel.js +101 -108
  113. package/dist/Model/NonParametric/KnnModel.js.map +1 -1
  114. package/dist/Model/Parametric/GaussianModel.js +82 -91
  115. package/dist/Model/Parametric/GaussianModel.js.map +1 -1
  116. package/dist/Model/Parametric/KMeansModel.js +59 -67
  117. package/dist/Model/Parametric/KMeansModel.js.map +1 -1
  118. package/dist/Model/Parametric/LdaModel.js +83 -91
  119. package/dist/Model/Parametric/LdaModel.js.map +1 -1
  120. package/dist/Model/Parametric/NaiveBayesModel.js +119 -132
  121. package/dist/Model/Parametric/NaiveBayesModel.js.map +1 -1
  122. package/dist/Model/Parametric/QdaModel.js +70 -79
  123. package/dist/Model/Parametric/QdaModel.js.map +1 -1
  124. package/dist/Model/RandomModel.js +85 -92
  125. package/dist/Model/RandomModel.js.map +1 -1
  126. package/dist/Model/ValidatedModel.js +21 -31
  127. package/dist/Model/ValidatedModel.js.map +1 -1
  128. package/dist/Parameter/ActivationFunction.js +9 -19
  129. package/dist/Parameter/ActivationFunction.js.map +1 -1
  130. package/dist/Parameter/BaggingParameter.js +24 -33
  131. package/dist/Parameter/BaggingParameter.js.map +1 -1
  132. package/dist/Parameter/C45Parameter.js +34 -42
  133. package/dist/Parameter/C45Parameter.js.map +1 -1
  134. package/dist/Parameter/DeepNetworkParameter.js +48 -56
  135. package/dist/Parameter/DeepNetworkParameter.js.map +1 -1
  136. package/dist/Parameter/KMeansParameter.js +29 -38
  137. package/dist/Parameter/KMeansParameter.js.map +1 -1
  138. package/dist/Parameter/KnnParameter.js +25 -34
  139. package/dist/Parameter/KnnParameter.js.map +1 -1
  140. package/dist/Parameter/LinearPerceptronParameter.js +56 -62
  141. package/dist/Parameter/LinearPerceptronParameter.js.map +1 -1
  142. package/dist/Parameter/MultiLayerPerceptronParameter.js +38 -46
  143. package/dist/Parameter/MultiLayerPerceptronParameter.js.map +1 -1
  144. package/dist/Parameter/Parameter.js +21 -30
  145. package/dist/Parameter/Parameter.js.map +1 -1
  146. package/dist/Parameter/RandomForestParameter.js +25 -34
  147. package/dist/Parameter/RandomForestParameter.js.map +1 -1
  148. package/dist/Performance/ClassificationPerformance.js +24 -33
  149. package/dist/Performance/ClassificationPerformance.js.map +1 -1
  150. package/dist/Performance/ConfusionMatrix.js +149 -158
  151. package/dist/Performance/ConfusionMatrix.js.map +1 -1
  152. package/dist/Performance/DetailedClassificationPerformance.js +23 -32
  153. package/dist/Performance/DetailedClassificationPerformance.js.map +1 -1
  154. package/dist/Performance/ExperimentPerformance.js +184 -161
  155. package/dist/Performance/ExperimentPerformance.js.map +1 -1
  156. package/dist/Performance/Performance.js +21 -30
  157. package/dist/Performance/Performance.js.map +1 -1
  158. package/dist/StatisticalTest/Combined5x2F.js +41 -51
  159. package/dist/StatisticalTest/Combined5x2F.js.map +1 -1
  160. package/dist/StatisticalTest/Combined5x2t.js +42 -52
  161. package/dist/StatisticalTest/Combined5x2t.js.map +1 -1
  162. package/dist/StatisticalTest/Paired5x2t.js +40 -50
  163. package/dist/StatisticalTest/Paired5x2t.js.map +1 -1
  164. package/dist/StatisticalTest/PairedTest.js +31 -41
  165. package/dist/StatisticalTest/PairedTest.js.map +1 -1
  166. package/dist/StatisticalTest/Pairedt.js +38 -48
  167. package/dist/StatisticalTest/Pairedt.js.map +1 -1
  168. package/dist/StatisticalTest/Sign.js +50 -60
  169. package/dist/StatisticalTest/Sign.js.map +1 -1
  170. package/dist/StatisticalTest/StatisticalTestResult.js +65 -73
  171. package/dist/StatisticalTest/StatisticalTestResult.js.map +1 -1
  172. package/dist/StatisticalTest/StatisticalTestResultType.js +11 -21
  173. package/dist/StatisticalTest/StatisticalTestResultType.js.map +1 -1
  174. package/dist/index.js +95 -101
  175. package/dist/index.js.map +1 -1
  176. package/package.json +7 -6
  177. package/tsconfig.json +4 -3
  178. package/source/tsconfig.json +0 -13
@@ -1,56 +1,46 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./PairedTest", "./StatisticalTestResult", "nlptoolkit-math/dist/Distribution"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Combined5x2t = void 0;
13
- const PairedTest_1 = require("./PairedTest");
14
- const StatisticalTestResult_1 = require("./StatisticalTestResult");
15
- const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
16
- class Combined5x2t extends PairedTest_1.PairedTest {
17
- /**
18
- * Calculates the test statistic of the combined 5x2 cv t test.
19
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
20
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
21
- * @return Given the performances of two classifiers, the test statistic of the combined 5x2 cv t test.
22
- */
23
- testStatistic(classifier1, classifier2) {
24
- let difference = new Array();
25
- for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
26
- difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
27
- }
28
- let denominator = 0;
29
- let numerator = 0;
30
- for (let i = 0; i < classifier1.numberOfExperiments() / 2; i++) {
31
- let mean = (difference[2 * i] + difference[2 * i + 1]) / 2;
32
- numerator += mean;
33
- let variance = (difference[2 * i] - mean) * (difference[2 * i] - mean) +
34
- (difference[2 * i + 1] - mean) * (difference[2 * i + 1] - mean);
35
- denominator += variance;
36
- }
37
- numerator = Math.sqrt(10) * numerator / 5;
38
- denominator = Math.sqrt(denominator / 5);
39
- return numerator / denominator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Combined5x2t = void 0;
4
+ const PairedTest_1 = require("./PairedTest");
5
+ const StatisticalTestResult_1 = require("./StatisticalTestResult");
6
+ const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
7
+ class Combined5x2t extends PairedTest_1.PairedTest {
8
+ /**
9
+ * Calculates the test statistic of the combined 5x2 cv t test.
10
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
11
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
12
+ * @return Given the performances of two classifiers, the test statistic of the combined 5x2 cv t test.
13
+ */
14
+ testStatistic(classifier1, classifier2) {
15
+ let difference = new Array();
16
+ for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
17
+ difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
40
18
  }
41
- /**
42
- * Compares two classification algorithms based on their performances (accuracy or error rate) using combined 5x2
43
- * cv t test.
44
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
45
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
46
- * @return Statistical test result of the comparison.
47
- */
48
- compareClassifiers(classifier1, classifier2) {
49
- let statistic = this.testStatistic(classifier1, classifier2);
50
- let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
51
- return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
19
+ let denominator = 0;
20
+ let numerator = 0;
21
+ for (let i = 0; i < classifier1.numberOfExperiments() / 2; i++) {
22
+ let mean = (difference[2 * i] + difference[2 * i + 1]) / 2;
23
+ numerator += mean;
24
+ let variance = (difference[2 * i] - mean) * (difference[2 * i] - mean) +
25
+ (difference[2 * i + 1] - mean) * (difference[2 * i + 1] - mean);
26
+ denominator += variance;
52
27
  }
28
+ numerator = Math.sqrt(10) * numerator / 5;
29
+ denominator = Math.sqrt(denominator / 5);
30
+ return numerator / denominator;
31
+ }
32
+ /**
33
+ * Compares two classification algorithms based on their performances (accuracy or error rate) using combined 5x2
34
+ * cv t test.
35
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
36
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
37
+ * @return Statistical test result of the comparison.
38
+ */
39
+ compareClassifiers(classifier1, classifier2) {
40
+ let statistic = this.testStatistic(classifier1, classifier2);
41
+ let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
42
+ return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
53
43
  }
54
- exports.Combined5x2t = Combined5x2t;
55
- });
44
+ }
45
+ exports.Combined5x2t = Combined5x2t;
56
46
  //# sourceMappingURL=Combined5x2t.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Combined5x2t.js","sourceRoot":"","sources":["../../source/StatisticalTest/Combined5x2t.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6CAAwC;IAExC,mEAA8D;IAC9D,oEAA+D;IAE/D,MAAa,YAAa,SAAQ,uBAAU;QAExC;;;;;WAKG;QACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;YACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;YACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC;gBACvD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,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,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YACpE,WAAW,IAAI,QAAQ,CAAC;QAC5B,CAAC;QACD,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC;QAC1C,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACzC,OAAO,SAAS,GAAG,WAAW,CAAC;IACnC,CAAC;IAED;;;;;;OAMG;IACH,kBAAkB,CAAC,WAAkC,EAAE,WAAkC;QACrF,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,IAAI,eAAe,GAAG,WAAW,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;QAC5D,OAAO,IAAI,6CAAqB,CAAC,2BAAY,CAAC,aAAa,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,KAAK,CAAC,CAAC;IACpG,CAAC;CAEJ;AAxCD,oCAwCC"}
@@ -1,54 +1,44 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./PairedTest", "./StatisticalTestResult", "nlptoolkit-math/dist/Distribution"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Paired5x2t = void 0;
13
- const PairedTest_1 = require("./PairedTest");
14
- const StatisticalTestResult_1 = require("./StatisticalTestResult");
15
- const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
16
- class Paired5x2t extends PairedTest_1.PairedTest {
17
- /**
18
- * Calculates the test statistic of the 5x2 t test.
19
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
20
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
21
- * @return Given the performances of two classifiers, the test statistic of the 5x2 t test.
22
- */
23
- testStatistic(classifier1, classifier2) {
24
- let difference = new Array();
25
- let sum = 0.0;
26
- for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
27
- difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
28
- sum += difference[i];
29
- }
30
- let denominator = 0;
31
- for (let i = 0; i < classifier1.numberOfExperiments() / 2; i++) {
32
- let mean = (difference[2 * i] + difference[2 * i + 1]) / 2;
33
- let variance = (difference[2 * i] - mean) * (difference[2 * i] - mean) +
34
- (difference[2 * i + 1] - mean) * (difference[2 * i + 1] - mean);
35
- denominator += variance;
36
- }
37
- denominator = Math.sqrt(denominator / 5);
38
- return difference[0] / denominator;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Paired5x2t = void 0;
4
+ const PairedTest_1 = require("./PairedTest");
5
+ const StatisticalTestResult_1 = require("./StatisticalTestResult");
6
+ const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
7
+ class Paired5x2t extends PairedTest_1.PairedTest {
8
+ /**
9
+ * Calculates the test statistic of the 5x2 t test.
10
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
11
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
12
+ * @return Given the performances of two classifiers, the test statistic of the 5x2 t test.
13
+ */
14
+ testStatistic(classifier1, classifier2) {
15
+ let difference = new Array();
16
+ let sum = 0.0;
17
+ for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
18
+ difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
19
+ sum += difference[i];
39
20
  }
40
- /**
41
- * Compares two classification algorithms based on their performances (accuracy or error rate) using 5x2 t test.
42
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
43
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
44
- * @return Statistical test result of the comparison.
45
- */
46
- compareClassifiers(classifier1, classifier2) {
47
- let statistic = this.testStatistic(classifier1, classifier2);
48
- let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
49
- return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
21
+ let denominator = 0;
22
+ for (let i = 0; i < classifier1.numberOfExperiments() / 2; i++) {
23
+ let mean = (difference[2 * i] + difference[2 * i + 1]) / 2;
24
+ let variance = (difference[2 * i] - mean) * (difference[2 * i] - mean) +
25
+ (difference[2 * i + 1] - mean) * (difference[2 * i + 1] - mean);
26
+ denominator += variance;
50
27
  }
28
+ denominator = Math.sqrt(denominator / 5);
29
+ return difference[0] / denominator;
30
+ }
31
+ /**
32
+ * Compares two classification algorithms based on their performances (accuracy or error rate) using 5x2 t test.
33
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
34
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
35
+ * @return Statistical test result of the comparison.
36
+ */
37
+ compareClassifiers(classifier1, classifier2) {
38
+ let statistic = this.testStatistic(classifier1, classifier2);
39
+ let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
40
+ return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
51
41
  }
52
- exports.Paired5x2t = Paired5x2t;
53
- });
42
+ }
43
+ exports.Paired5x2t = Paired5x2t;
54
44
  //# sourceMappingURL=Paired5x2t.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Paired5x2t.js","sourceRoot":"","sources":["../../source/StatisticalTest/Paired5x2t.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6CAAwC;IAExC,mEAA8D;IAC9D,oEAA+D;IAE/D,MAAa,UAAW,SAAQ,uBAAU;QAEtC;;;;;WAKG;QACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;YACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;YACrC,IAAI,GAAG,GAAG,GAAG,CAAC;YACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAA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AAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;YACpE,WAAW,IAAI,QAAQ,CAAC;QAC5B,CAAC;QACD,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC;QACzC,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,kBAAkB,CAAC,WAAkC,EAAE,WAAkC;QACrF,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QAC7D,IAAI,eAAe,GAAG,WAAW,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;QAC5D,OAAO,IAAI,6CAAqB,CAAC,2BAAY,CAAC,aAAa,CAAC,SAAS,EAAE,eAAe,CAAC,EAAE,KAAK,CAAC,CAAC;IACpG,CAAC;CAEJ;AAtCD,gCAsCC"}
@@ -1,47 +1,37 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./StatisticalTestResultType"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PairedTest = void 0;
13
- const StatisticalTestResultType_1 = require("./StatisticalTestResultType");
14
- class PairedTest {
15
- /**
16
- * Compares two classification algorithms based on their performances (accuracy or error rate). The method first
17
- * checks the null hypothesis mu1 < mu2, if the test rejects this null hypothesis with alpha level of confidence, it
18
- * decides mu1 > mu2. The algorithm then checks the null hypothesis mu1 > mu2, if the test rejects that null
19
- * hypothesis with alpha level of confidence, if decides mu1 < mu2. If none of the two tests are rejected, it can not
20
- * make a decision about the performances of algorithms.
21
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
22
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
23
- * @param alpha Alpha level defined for the statistical test.
24
- * @return 1 if the performance of the first algorithm is larger than the second algorithm, -1 if the performance of
25
- * the second algorithm is larger than the first algorithm, 0 if they have similar performance.
26
- */
27
- compare(classifier1, classifier2, alpha) {
28
- let testResult1 = this.compareClassifiers(classifier1, classifier2);
29
- let testResult2 = this.compareClassifiers(classifier2, classifier1);
30
- let testResultType1 = testResult1.oneTailed(alpha);
31
- let testResultType2 = testResult2.oneTailed(alpha);
32
- if (testResultType1 == StatisticalTestResultType_1.StatisticalTestResultType.REJECT) {
33
- return 1;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PairedTest = void 0;
4
+ const StatisticalTestResultType_1 = require("./StatisticalTestResultType");
5
+ class PairedTest {
6
+ /**
7
+ * Compares two classification algorithms based on their performances (accuracy or error rate). The method first
8
+ * checks the null hypothesis mu1 < mu2, if the test rejects this null hypothesis with alpha level of confidence, it
9
+ * decides mu1 > mu2. The algorithm then checks the null hypothesis mu1 > mu2, if the test rejects that null
10
+ * hypothesis with alpha level of confidence, if decides mu1 < mu2. If none of the two tests are rejected, it can not
11
+ * make a decision about the performances of algorithms.
12
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
13
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
14
+ * @param alpha Alpha level defined for the statistical test.
15
+ * @return 1 if the performance of the first algorithm is larger than the second algorithm, -1 if the performance of
16
+ * the second algorithm is larger than the first algorithm, 0 if they have similar performance.
17
+ */
18
+ compare(classifier1, classifier2, alpha) {
19
+ let testResult1 = this.compareClassifiers(classifier1, classifier2);
20
+ let testResult2 = this.compareClassifiers(classifier2, classifier1);
21
+ let testResultType1 = testResult1.oneTailed(alpha);
22
+ let testResultType2 = testResult2.oneTailed(alpha);
23
+ if (testResultType1 == StatisticalTestResultType_1.StatisticalTestResultType.REJECT) {
24
+ return 1;
25
+ }
26
+ else {
27
+ if (testResultType2 == StatisticalTestResultType_1.StatisticalTestResultType.REJECT) {
28
+ return -1;
34
29
  }
35
30
  else {
36
- if (testResultType2 == StatisticalTestResultType_1.StatisticalTestResultType.REJECT) {
37
- return -1;
38
- }
39
- else {
40
- return 0;
41
- }
31
+ return 0;
42
32
  }
43
33
  }
44
34
  }
45
- exports.PairedTest = PairedTest;
46
- });
35
+ }
36
+ exports.PairedTest = PairedTest;
47
37
  //# sourceMappingURL=PairedTest.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PairedTest.js","sourceRoot":"","sources":["../../source/StatisticalTest/PairedTest.ts"],"names":[],"mappings":";;;;;;;;;;;;IAEA,2EAAsE;IAEtE,MAAsB,UAAU;QAI5B;;;;;;;;;;;WAWG;QACH,OAAO,CAAC,WAAkC,EAAE,WAAkC,EAAE,KAAa;YACzF,IAAI,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACpE,IAAI,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;YACpE,IAAI,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACnD,IAAI,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YACnD,IAAI,eAAe,IAAI,qDAAyB,CAAC,MAAM,EAAC;gBACpD,OAAO,CAAC,CAAC;aACZ;iBAAM;gBACH,IAAI,eAAe,IAAI,qDAAyB,CAAC,MAAM,EAAC;oBACpD,OAAO,CAAC,CAAC,CAAC;iBACb;qBAAM;oBACH,OAAO,CAAC,CAAC;iBACZ;aACJ;QACL,CAAC;KACJ;IA/BD,gCA+BC"}
1
+ {"version":3,"file":"PairedTest.js","sourceRoot":"","sources":["../../source/StatisticalTest/PairedTest.ts"],"names":[],"mappings":";;;AAEA,2EAAsE;AAEtE,MAAsB,UAAU;IAI5B;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,WAAkC,EAAE,WAAkC,EAAE,KAAa;QACzF,IAAI,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACpE,IAAI,WAAW,GAAG,IAAI,CAAC,kBAAkB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACpE,IAAI,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,eAAe,GAAG,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,eAAe,IAAI,qDAAyB,CAAC,MAAM,EAAC,CAAC;YACrD,OAAO,CAAC,CAAC;QACb,CAAC;aAAM,CAAC;YACJ,IAAI,eAAe,IAAI,qDAAyB,CAAC,MAAM,EAAC,CAAC;gBACrD,OAAO,CAAC,CAAC,CAAC;YACd,CAAC;iBAAM,CAAC;gBACJ,OAAO,CAAC,CAAC;YACb,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AA/BD,gCA+BC"}
@@ -1,52 +1,42 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./PairedTest", "./StatisticalTestResult", "nlptoolkit-math/dist/Distribution"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Pairedt = void 0;
13
- const PairedTest_1 = require("./PairedTest");
14
- const StatisticalTestResult_1 = require("./StatisticalTestResult");
15
- const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
16
- class Pairedt extends PairedTest_1.PairedTest {
17
- /**
18
- * Calculates the test statistic of the paired t test.
19
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
20
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
21
- * @return Given the performances of two classifiers, the test statistic of the paired t test.
22
- */
23
- testStatistic(classifier1, classifier2) {
24
- let difference = new Array();
25
- let sum = 0.0;
26
- for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
27
- difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
28
- sum += difference[i];
29
- }
30
- let mean = sum / classifier1.numberOfExperiments();
31
- sum = 0.0;
32
- for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
33
- sum += (difference[i] - mean) * (difference[i] - mean);
34
- }
35
- let standardDeviation = Math.sqrt(sum / (classifier1.numberOfExperiments() - 1));
36
- return Math.sqrt(classifier1.numberOfExperiments()) * mean / standardDeviation;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pairedt = void 0;
4
+ const PairedTest_1 = require("./PairedTest");
5
+ const StatisticalTestResult_1 = require("./StatisticalTestResult");
6
+ const Distribution_1 = require("nlptoolkit-math/dist/Distribution");
7
+ class Pairedt extends PairedTest_1.PairedTest {
8
+ /**
9
+ * Calculates the test statistic of the paired t test.
10
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
11
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
12
+ * @return Given the performances of two classifiers, the test statistic of the paired t test.
13
+ */
14
+ testStatistic(classifier1, classifier2) {
15
+ let difference = new Array();
16
+ let sum = 0.0;
17
+ for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
18
+ difference.push(classifier1.getErrorRate(i) - classifier2.getErrorRate(i));
19
+ sum += difference[i];
37
20
  }
38
- /**
39
- * Compares two classification algorithms based on their performances (accuracy or error rate) using paired t test.
40
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
41
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
42
- * @return Statistical test result of the comparison.
43
- */
44
- compareClassifiers(classifier1, classifier2) {
45
- let statistic = this.testStatistic(classifier1, classifier2);
46
- let degreeOfFreedom = classifier1.numberOfExperiments() - 1;
47
- return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
21
+ let mean = sum / classifier1.numberOfExperiments();
22
+ sum = 0.0;
23
+ for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
24
+ sum += (difference[i] - mean) * (difference[i] - mean);
48
25
  }
26
+ let standardDeviation = Math.sqrt(sum / (classifier1.numberOfExperiments() - 1));
27
+ return Math.sqrt(classifier1.numberOfExperiments()) * mean / standardDeviation;
28
+ }
29
+ /**
30
+ * Compares two classification algorithms based on their performances (accuracy or error rate) using paired t test.
31
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
32
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
33
+ * @return Statistical test result of the comparison.
34
+ */
35
+ compareClassifiers(classifier1, classifier2) {
36
+ let statistic = this.testStatistic(classifier1, classifier2);
37
+ let degreeOfFreedom = classifier1.numberOfExperiments() - 1;
38
+ return new StatisticalTestResult_1.StatisticalTestResult(Distribution_1.Distribution.tDistribution(statistic, degreeOfFreedom), false);
49
39
  }
50
- exports.Pairedt = Pairedt;
51
- });
40
+ }
41
+ exports.Pairedt = Pairedt;
52
42
  //# sourceMappingURL=Pairedt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Pairedt.js","sourceRoot":"","sources":["../../source/StatisticalTest/Pairedt.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6CAAwC;IAExC,mEAA8D;IAC9D,oEAA+D;IAE/D,MAAa,OAAQ,SAAQ,uBAAU;QAEnC;;;;;WAKG;QACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;YACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;YACrC,IAAI,GAAG,GAAG,GAAG,CAAC;YACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC;gBACvD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAA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C;IACpG,CAAC;CAEJ;AApCD,0BAoCC"}
@@ -1,69 +1,59 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Sign = void 0;
4
+ const PairedTest_1 = require("./PairedTest");
5
+ const StatisticalTestResult_1 = require("./StatisticalTestResult");
6
+ class Sign extends PairedTest_1.PairedTest {
7
+ /**
8
+ * Calculates n!.
9
+ * @param n n is n!
10
+ * @return n!.
11
+ */
12
+ factorial(n) {
13
+ let result = 1;
14
+ for (let i = 2; i <= n; i++)
15
+ result *= i;
16
+ return result;
5
17
  }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./PairedTest", "./StatisticalTestResult"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Sign = void 0;
13
- const PairedTest_1 = require("./PairedTest");
14
- const StatisticalTestResult_1 = require("./StatisticalTestResult");
15
- class Sign extends PairedTest_1.PairedTest {
16
- /**
17
- * Calculates n!.
18
- * @param n n is n!
19
- * @return n!.
20
- */
21
- factorial(n) {
22
- let result = 1;
23
- for (let i = 2; i <= n; i++)
24
- result *= i;
25
- return result;
18
+ /**
19
+ * Calculates m of n that is C(n, m)
20
+ * @param m m in C(m, n)
21
+ * @param n n in C(m, n)
22
+ * @return C(m, n)
23
+ */
24
+ binomial(m, n) {
25
+ if (n == 0 || m == n) {
26
+ return 1;
27
+ }
28
+ else {
29
+ return this.factorial(m) / (this.factorial(n) * this.factorial(m - n));
26
30
  }
27
- /**
28
- * Calculates m of n that is C(n, m)
29
- * @param m m in C(m, n)
30
- * @param n n in C(m, n)
31
- * @return C(m, n)
32
- */
33
- binomial(m, n) {
34
- if (n == 0 || m == n) {
35
- return 1;
31
+ }
32
+ /**
33
+ * Compares two classification algorithms based on their performances (accuracy or error rate) using sign test.
34
+ * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
35
+ * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
36
+ * @return Statistical test result of the comparison.
37
+ */
38
+ compareClassifiers(classifier1, classifier2) {
39
+ let plus = 0, minus = 0;
40
+ for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
41
+ if (classifier1.getErrorRate(i) < classifier2.getErrorRate(i)) {
42
+ plus++;
36
43
  }
37
44
  else {
38
- return this.factorial(m) / (this.factorial(n) * this.factorial(m - n));
39
- }
40
- }
41
- /**
42
- * Compares two classification algorithms based on their performances (accuracy or error rate) using sign test.
43
- * @param classifier1 Performance (error rate or accuracy) results of the first classifier.
44
- * @param classifier2 Performance (error rate or accuracy) results of the second classifier.
45
- * @return Statistical test result of the comparison.
46
- */
47
- compareClassifiers(classifier1, classifier2) {
48
- let plus = 0, minus = 0;
49
- for (let i = 0; i < classifier1.numberOfExperiments(); i++) {
50
- if (classifier1.getErrorRate(i) < classifier2.getErrorRate(i)) {
51
- plus++;
52
- }
53
- else {
54
- if (classifier1.getErrorRate(i) > classifier2.getErrorRate(i)) {
55
- minus++;
56
- }
45
+ if (classifier1.getErrorRate(i) > classifier2.getErrorRate(i)) {
46
+ minus++;
57
47
  }
58
48
  }
59
- let total = plus + minus;
60
- let pValue = 0.0;
61
- for (let i = 0; i <= plus; i++) {
62
- pValue += this.binomial(total, i) / Math.pow(2, total);
63
- }
64
- return new StatisticalTestResult_1.StatisticalTestResult(pValue, false);
65
49
  }
50
+ let total = plus + minus;
51
+ let pValue = 0.0;
52
+ for (let i = 0; i <= plus; i++) {
53
+ pValue += this.binomial(total, i) / Math.pow(2, total);
54
+ }
55
+ return new StatisticalTestResult_1.StatisticalTestResult(pValue, false);
66
56
  }
67
- exports.Sign = Sign;
68
- });
57
+ }
58
+ exports.Sign = Sign;
69
59
  //# sourceMappingURL=Sign.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Sign.js","sourceRoot":"","sources":["../../source/StatisticalTest/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