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.
- package/dist/Attribute/Attribute.js +6 -16
- package/dist/Attribute/Attribute.js.map +1 -1
- package/dist/Attribute/AttributeType.js +22 -32
- package/dist/Attribute/AttributeType.js.map +1 -1
- package/dist/Attribute/BinaryAttribute.js +14 -24
- package/dist/Attribute/BinaryAttribute.js.map +1 -1
- package/dist/Attribute/ContinuousAttribute.js +46 -55
- package/dist/Attribute/ContinuousAttribute.js.map +1 -1
- package/dist/Attribute/DiscreteAttribute.js +38 -48
- package/dist/Attribute/DiscreteAttribute.js.map +1 -1
- package/dist/Attribute/DiscreteIndexedAttribute.js +47 -55
- package/dist/Attribute/DiscreteIndexedAttribute.js.map +1 -1
- package/dist/DataSet/DataDefinition.js +115 -123
- package/dist/DataSet/DataDefinition.js.map +1 -1
- package/dist/DataSet/DataSet.js +268 -245
- package/dist/DataSet/DataSet.js.map +1 -1
- package/dist/DistanceMetric/DistanceMetric.js +2 -12
- package/dist/DistanceMetric/EuclidianDistance.js +27 -37
- package/dist/DistanceMetric/EuclidianDistance.js.map +1 -1
- package/dist/DistanceMetric/MahalanobisDistance.js +27 -36
- package/dist/DistanceMetric/MahalanobisDistance.js.map +1 -1
- package/dist/Experiment/BootstrapRun.js +31 -40
- package/dist/Experiment/BootstrapRun.js.map +1 -1
- package/dist/Experiment/Experiment.js +46 -53
- package/dist/Experiment/Experiment.js.map +1 -1
- package/dist/Experiment/KFoldRun.js +45 -54
- package/dist/Experiment/KFoldRun.js.map +1 -1
- package/dist/Experiment/KFoldRunSeparateTest.js +48 -58
- package/dist/Experiment/KFoldRunSeparateTest.js.map +1 -1
- package/dist/Experiment/MultipleRun.js +2 -12
- package/dist/Experiment/MxKFoldRun.js +31 -40
- package/dist/Experiment/MxKFoldRun.js.map +1 -1
- package/dist/Experiment/MxKFoldRunSeparateTest.js +35 -44
- package/dist/Experiment/MxKFoldRunSeparateTest.js.map +1 -1
- package/dist/Experiment/SingleRun.js +2 -12
- package/dist/Experiment/SingleRunWithK.js +39 -48
- package/dist/Experiment/SingleRunWithK.js.map +1 -1
- package/dist/Experiment/StratifiedKFoldRun.js +26 -36
- package/dist/Experiment/StratifiedKFoldRun.js.map +1 -1
- package/dist/Experiment/StratifiedKFoldRunSeparateTest.js +30 -40
- package/dist/Experiment/StratifiedKFoldRunSeparateTest.js.map +1 -1
- package/dist/Experiment/StratifiedMxKFoldRun.js +29 -39
- package/dist/Experiment/StratifiedMxKFoldRun.js.map +1 -1
- package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js +34 -43
- package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js.map +1 -1
- package/dist/Experiment/StratifiedSingleRunWithK.js +27 -36
- package/dist/Experiment/StratifiedSingleRunWithK.js.map +1 -1
- package/dist/FeatureSelection/BackwardSelection.js +26 -36
- package/dist/FeatureSelection/BackwardSelection.js.map +1 -1
- package/dist/FeatureSelection/FeatureSubSet.js +72 -82
- package/dist/FeatureSelection/FeatureSubSet.js.map +1 -1
- package/dist/FeatureSelection/FloatingSelection.js +25 -35
- package/dist/FeatureSelection/FloatingSelection.js.map +1 -1
- package/dist/FeatureSelection/ForwardSelection.js +25 -35
- package/dist/FeatureSelection/ForwardSelection.js.map +1 -1
- package/dist/FeatureSelection/SubSetSelection.js +69 -78
- package/dist/FeatureSelection/SubSetSelection.js.map +1 -1
- package/dist/Filter/DiscreteToContinuous.js +50 -60
- package/dist/Filter/DiscreteToContinuous.js.map +1 -1
- package/dist/Filter/DiscreteToIndexed.js +40 -50
- package/dist/Filter/DiscreteToIndexed.js.map +1 -1
- package/dist/Filter/FeatureFilter.js +23 -32
- package/dist/Filter/FeatureFilter.js.map +1 -1
- package/dist/Filter/LaryFilter.js +46 -55
- package/dist/Filter/LaryFilter.js.map +1 -1
- package/dist/Filter/LaryToBinary.js +48 -58
- package/dist/Filter/LaryToBinary.js.map +1 -1
- package/dist/Filter/Normalize.js +33 -41
- package/dist/Filter/Normalize.js.map +1 -1
- package/dist/Filter/Pca.js +86 -96
- package/dist/Filter/Pca.js.map +1 -1
- package/dist/Filter/TrainedFeatureFilter.js +14 -24
- package/dist/Filter/TrainedFeatureFilter.js.map +1 -1
- package/dist/Instance/CompositeInstance.js +46 -56
- package/dist/Instance/CompositeInstance.js.map +1 -1
- package/dist/Instance/Instance.js +145 -154
- package/dist/Instance/Instance.js.map +1 -1
- package/dist/InstanceList/InstanceList.js +466 -443
- package/dist/InstanceList/InstanceList.js.map +1 -1
- package/dist/InstanceList/InstanceListOfSameClass.js +23 -32
- package/dist/InstanceList/InstanceListOfSameClass.js.map +1 -1
- package/dist/InstanceList/Partition.js +167 -177
- package/dist/InstanceList/Partition.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionCondition.js +71 -80
- package/dist/Model/DecisionTree/DecisionCondition.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionNode.js +302 -311
- package/dist/Model/DecisionTree/DecisionNode.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionStump.js +22 -32
- package/dist/Model/DecisionTree/DecisionStump.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionTree.js +89 -98
- package/dist/Model/DecisionTree/DecisionTree.js.map +1 -1
- package/dist/Model/DummyModel.js +64 -73
- package/dist/Model/DummyModel.js.map +1 -1
- package/dist/Model/Ensemble/BaggingModel.js +34 -44
- package/dist/Model/Ensemble/BaggingModel.js.map +1 -1
- package/dist/Model/Ensemble/RandomForestModel.js +31 -41
- package/dist/Model/Ensemble/RandomForestModel.js.map +1 -1
- package/dist/Model/Ensemble/TreeEnsembleModel.js +55 -64
- package/dist/Model/Ensemble/TreeEnsembleModel.js.map +1 -1
- package/dist/Model/Model.js +130 -140
- package/dist/Model/Model.js.map +1 -1
- package/dist/Model/NeuralNetwork/DeepNetworkModel.js +162 -169
- package/dist/Model/NeuralNetwork/DeepNetworkModel.js.map +1 -1
- package/dist/Model/NeuralNetwork/LinearPerceptronModel.js +69 -78
- package/dist/Model/NeuralNetwork/LinearPerceptronModel.js.map +1 -1
- package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js +112 -120
- package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js.map +1 -1
- package/dist/Model/NeuralNetwork/NeuralNetworkModel.js +197 -201
- package/dist/Model/NeuralNetwork/NeuralNetworkModel.js.map +1 -1
- package/dist/Model/NonParametric/KnnInstance.js +21 -29
- package/dist/Model/NonParametric/KnnInstance.js.map +1 -1
- package/dist/Model/NonParametric/KnnModel.js +101 -108
- package/dist/Model/NonParametric/KnnModel.js.map +1 -1
- package/dist/Model/Parametric/GaussianModel.js +82 -91
- package/dist/Model/Parametric/GaussianModel.js.map +1 -1
- package/dist/Model/Parametric/KMeansModel.js +59 -67
- package/dist/Model/Parametric/KMeansModel.js.map +1 -1
- package/dist/Model/Parametric/LdaModel.js +83 -91
- package/dist/Model/Parametric/LdaModel.js.map +1 -1
- package/dist/Model/Parametric/NaiveBayesModel.js +119 -132
- package/dist/Model/Parametric/NaiveBayesModel.js.map +1 -1
- package/dist/Model/Parametric/QdaModel.js +70 -79
- package/dist/Model/Parametric/QdaModel.js.map +1 -1
- package/dist/Model/RandomModel.js +85 -92
- package/dist/Model/RandomModel.js.map +1 -1
- package/dist/Model/ValidatedModel.js +21 -31
- package/dist/Model/ValidatedModel.js.map +1 -1
- package/dist/Parameter/ActivationFunction.js +9 -19
- package/dist/Parameter/ActivationFunction.js.map +1 -1
- package/dist/Parameter/BaggingParameter.js +24 -33
- package/dist/Parameter/BaggingParameter.js.map +1 -1
- package/dist/Parameter/C45Parameter.js +34 -42
- package/dist/Parameter/C45Parameter.js.map +1 -1
- package/dist/Parameter/DeepNetworkParameter.js +48 -56
- package/dist/Parameter/DeepNetworkParameter.js.map +1 -1
- package/dist/Parameter/KMeansParameter.js +29 -38
- package/dist/Parameter/KMeansParameter.js.map +1 -1
- package/dist/Parameter/KnnParameter.js +25 -34
- package/dist/Parameter/KnnParameter.js.map +1 -1
- package/dist/Parameter/LinearPerceptronParameter.js +56 -62
- package/dist/Parameter/LinearPerceptronParameter.js.map +1 -1
- package/dist/Parameter/MultiLayerPerceptronParameter.js +38 -46
- package/dist/Parameter/MultiLayerPerceptronParameter.js.map +1 -1
- package/dist/Parameter/Parameter.js +21 -30
- package/dist/Parameter/Parameter.js.map +1 -1
- package/dist/Parameter/RandomForestParameter.js +25 -34
- package/dist/Parameter/RandomForestParameter.js.map +1 -1
- package/dist/Performance/ClassificationPerformance.js +24 -33
- package/dist/Performance/ClassificationPerformance.js.map +1 -1
- package/dist/Performance/ConfusionMatrix.js +149 -158
- package/dist/Performance/ConfusionMatrix.js.map +1 -1
- package/dist/Performance/DetailedClassificationPerformance.js +23 -32
- package/dist/Performance/DetailedClassificationPerformance.js.map +1 -1
- package/dist/Performance/ExperimentPerformance.js +184 -161
- package/dist/Performance/ExperimentPerformance.js.map +1 -1
- package/dist/Performance/Performance.js +21 -30
- package/dist/Performance/Performance.js.map +1 -1
- package/dist/StatisticalTest/Combined5x2F.js +41 -51
- package/dist/StatisticalTest/Combined5x2F.js.map +1 -1
- package/dist/StatisticalTest/Combined5x2t.js +42 -52
- package/dist/StatisticalTest/Combined5x2t.js.map +1 -1
- package/dist/StatisticalTest/Paired5x2t.js +40 -50
- package/dist/StatisticalTest/Paired5x2t.js.map +1 -1
- package/dist/StatisticalTest/PairedTest.js +31 -41
- package/dist/StatisticalTest/PairedTest.js.map +1 -1
- package/dist/StatisticalTest/Pairedt.js +38 -48
- package/dist/StatisticalTest/Pairedt.js.map +1 -1
- package/dist/StatisticalTest/Sign.js +50 -60
- package/dist/StatisticalTest/Sign.js.map +1 -1
- package/dist/StatisticalTest/StatisticalTestResult.js +65 -73
- package/dist/StatisticalTest/StatisticalTestResult.js.map +1 -1
- package/dist/StatisticalTest/StatisticalTestResultType.js +11 -21
- package/dist/StatisticalTest/StatisticalTestResultType.js.map +1 -1
- package/dist/index.js +95 -101
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/tsconfig.json +4 -3
- package/source/tsconfig.json +0 -13
|
@@ -1,56 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Combined5x2t.js","sourceRoot":"","sources":["../../source/StatisticalTest/Combined5x2t.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mEAA8D;AAC9D,oEAA+D;AAE/D,MAAa,YAAa,SAAQ,uBAAU;IAExC;;;;;OAKG;IACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;QACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC;YACxD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/E,CAAC;QACD,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,IAAI,S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"}
|
|
@@ -1,54 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Paired5x2t.js","sourceRoot":"","sources":["../../source/StatisticalTest/Paired5x2t.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mEAA8D;AAC9D,oEAA+D;AAE/D,MAAa,UAAW,SAAQ,uBAAU;IAEtC;;;;;OAKG;IACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;QACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;QACrC,IAAI,GAAG,GAAG,GAAG,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC;YACxD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,GAAG,CAAC,EAAE,CAAC,EAAE,EAAC,CAAC;YAC5D,IAAI,IAAI,GAAG,C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|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
37
|
-
return -1;
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
return 0;
|
|
41
|
-
}
|
|
31
|
+
return 0;
|
|
42
32
|
}
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
|
-
|
|
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":"
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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":"
|
|
1
|
+
{"version":3,"file":"Pairedt.js","sourceRoot":"","sources":["../../source/StatisticalTest/Pairedt.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mEAA8D;AAC9D,oEAA+D;AAE/D,MAAa,OAAQ,SAAQ,uBAAU;IAEnC;;;;;OAKG;IACK,aAAa,CAAC,WAAkC,EAAE,WAAkC;QACxF,IAAI,UAAU,GAAG,IAAI,KAAK,EAAU,CAAC;QACrC,IAAI,GAAG,GAAG,GAAG,CAAC;QACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC;YACxD,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3E,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;QACD,IAAI,IAAI,GAAG,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,CAAC;QACnD,GAAG,GAAG,GAAG,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAC,CAAC;YACxD,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3D,CAAC;QACD,IAAI,iBAAiB,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC,WAAW,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;QACjF,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,mBAAmB,EAAE,CAAC,GAAG,IAAI,GAAG,iBAAiB,CAAC;IACnF,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;AApCD,0BAoCC"}
|
|
@@ -1,69 +1,59 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
68
|
-
|
|
57
|
+
}
|
|
58
|
+
exports.Sign = Sign;
|
|
69
59
|
//# sourceMappingURL=Sign.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sign.js","sourceRoot":"","sources":["../../source/StatisticalTest/Sign.ts"],"names":[],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