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,43 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
* @param instance2 Second instance
|
|
22
|
-
* @return Euclidian distance between two instances.
|
|
23
|
-
*/
|
|
24
|
-
distance(instance1, instance2) {
|
|
25
|
-
let result = 0;
|
|
26
|
-
for (let i = 0; i < instance1.attributeSize(); i++) {
|
|
27
|
-
if (instance1.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute && instance2.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute) {
|
|
28
|
-
if (instance1.getAttribute(i).getValue() != null && instance1.getAttribute(i).getValue() != instance2.getAttribute(i).getValue()) {
|
|
29
|
-
result += 1;
|
|
30
|
-
}
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EuclidianDistance = void 0;
|
|
4
|
+
const DiscreteAttribute_1 = require("../Attribute/DiscreteAttribute");
|
|
5
|
+
const ContinuousAttribute_1 = require("../Attribute/ContinuousAttribute");
|
|
6
|
+
class EuclidianDistance {
|
|
7
|
+
/**
|
|
8
|
+
* Calculates Euclidian distance between two instances. For continuous features: \sum_{i=1}^d (x_i^(1) - x_i^(2))^2,
|
|
9
|
+
* For discrete features: \sum_{i=1}^d 1(x_i^(1) == x_i^(2))
|
|
10
|
+
*
|
|
11
|
+
* @param instance1 First instance
|
|
12
|
+
* @param instance2 Second instance
|
|
13
|
+
* @return Euclidian distance between two instances.
|
|
14
|
+
*/
|
|
15
|
+
distance(instance1, instance2) {
|
|
16
|
+
let result = 0;
|
|
17
|
+
for (let i = 0; i < instance1.attributeSize(); i++) {
|
|
18
|
+
if (instance1.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute && instance2.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute) {
|
|
19
|
+
if (instance1.getAttribute(i).getValue() != null && instance1.getAttribute(i).getValue() != instance2.getAttribute(i).getValue()) {
|
|
20
|
+
result += 1;
|
|
31
21
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
if (instance1.getAttribute(i) instanceof ContinuousAttribute_1.ContinuousAttribute && instance2.getAttribute(i) instanceof ContinuousAttribute_1.ContinuousAttribute) {
|
|
25
|
+
result += Math.pow(instance1.getAttribute(i).getValue() - instance2.getAttribute(i).getValue(), 2);
|
|
36
26
|
}
|
|
37
27
|
}
|
|
38
|
-
return result;
|
|
39
28
|
}
|
|
29
|
+
return result;
|
|
40
30
|
}
|
|
41
|
-
|
|
42
|
-
|
|
31
|
+
}
|
|
32
|
+
exports.EuclidianDistance = EuclidianDistance;
|
|
43
33
|
//# sourceMappingURL=EuclidianDistance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EuclidianDistance.js","sourceRoot":"","sources":["../../source/DistanceMetric/EuclidianDistance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EuclidianDistance.js","sourceRoot":"","sources":["../../source/DistanceMetric/EuclidianDistance.ts"],"names":[],"mappings":";;;AAEA,sEAAiE;AACjE,0EAAqE;AAErE,MAAa,iBAAiB;IAE1B;;;;;;;OAOG;IACH,QAAQ,CAAC,SAAmB,EAAE,SAAmB;QAC7C,IAAI,MAAM,GAAG,CAAC,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,aAAa,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;YACjD,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,qCAAiB,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,qCAAiB,EAAE,CAAC;gBACnH,IAAyB,SAAS,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,IAAI,IAAI,IAAyB,SAAS,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,IAAyB,SAAS,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACjM,MAAM,IAAI,CAAC,CAAC;gBAChB,CAAC;YACL,CAAC;iBAAM,CAAC;gBACJ,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,yCAAmB,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,yCAAmB,EAAE,CAAC;oBACvH,MAAM,IAAI,IAAI,CAAC,GAAG,CAAwB,SAAS,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,GAA0B,SAAS,CAAC,YAAY,CAAC,CAAC,CAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;gBACvJ,CAAC;YACL,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ;AA1BD,8CA0BC"}
|
|
@@ -1,39 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MahalanobisDistance = void 0;
|
|
4
|
+
class MahalanobisDistance {
|
|
5
|
+
covarianceInverse;
|
|
6
|
+
/**
|
|
7
|
+
* Constructor for the MahalanobisDistance class. Basically sets the inverse of the covariance matrix.
|
|
8
|
+
*
|
|
9
|
+
* @param covarianceInverse Inverse of the covariance matrix.
|
|
10
|
+
*/
|
|
11
|
+
constructor(covarianceInverse) {
|
|
12
|
+
this.covarianceInverse = covarianceInverse;
|
|
5
13
|
}
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Calculates Mahalanobis distance between two instances. (x^(1) - x^(2)) S (x^(1) - x^(2))^T
|
|
16
|
+
*
|
|
17
|
+
* @param instance1 First instance.
|
|
18
|
+
* @param instance2 Second instance.
|
|
19
|
+
* @return Mahalanobis distance between two instances.
|
|
20
|
+
*/
|
|
21
|
+
distance(instance1, instance2) {
|
|
22
|
+
let v1 = instance1.toVector();
|
|
23
|
+
let v2 = instance2.toVector();
|
|
24
|
+
v1.subtract(v2);
|
|
25
|
+
let v3 = this.covarianceInverse.multiplyWithVectorFromLeft(v1);
|
|
26
|
+
return v3.dotProduct(v1);
|
|
8
27
|
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.MahalanobisDistance = void 0;
|
|
13
|
-
class MahalanobisDistance {
|
|
14
|
-
/**
|
|
15
|
-
* Constructor for the MahalanobisDistance class. Basically sets the inverse of the covariance matrix.
|
|
16
|
-
*
|
|
17
|
-
* @param covarianceInverse Inverse of the covariance matrix.
|
|
18
|
-
*/
|
|
19
|
-
constructor(covarianceInverse) {
|
|
20
|
-
this.covarianceInverse = covarianceInverse;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Calculates Mahalanobis distance between two instances. (x^(1) - x^(2)) S (x^(1) - x^(2))^T
|
|
24
|
-
*
|
|
25
|
-
* @param instance1 First instance.
|
|
26
|
-
* @param instance2 Second instance.
|
|
27
|
-
* @return Mahalanobis distance between two instances.
|
|
28
|
-
*/
|
|
29
|
-
distance(instance1, instance2) {
|
|
30
|
-
let v1 = instance1.toVector();
|
|
31
|
-
let v2 = instance2.toVector();
|
|
32
|
-
v1.subtract(v2);
|
|
33
|
-
let v3 = this.covarianceInverse.multiplyWithVectorFromLeft(v1);
|
|
34
|
-
return v3.dotProduct(v1);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.MahalanobisDistance = MahalanobisDistance;
|
|
38
|
-
});
|
|
28
|
+
}
|
|
29
|
+
exports.MahalanobisDistance = MahalanobisDistance;
|
|
39
30
|
//# sourceMappingURL=MahalanobisDistance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MahalanobisDistance.js","sourceRoot":"","sources":["../../source/DistanceMetric/MahalanobisDistance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MahalanobisDistance.js","sourceRoot":"","sources":["../../source/DistanceMetric/MahalanobisDistance.ts"],"names":[],"mappings":";;;AAIA,MAAa,mBAAmB;IAEpB,iBAAiB,CAAQ;IAEjC;;;;OAIG;IACH,YAAY,iBAAyB;QACjC,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAA;IAC9C,CAAC;IAED;;;;;;OAMG;IACH,QAAQ,CAAC,SAAmB,EAAE,SAAmB;QAC7C,IAAI,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9B,IAAI,EAAE,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;QAC9B,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QAChB,IAAI,EAAE,GAAG,IAAI,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC;QAC/D,OAAO,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IAC7B,CAAC;CAEJ;AA5BD,kDA4BC"}
|
|
@@ -1,44 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BootstrapRun = void 0;
|
|
4
|
+
const ExperimentPerformance_1 = require("../Performance/ExperimentPerformance");
|
|
5
|
+
const Bootstrap_1 = require("nlptoolkit-sampling/dist/Bootstrap");
|
|
6
|
+
const InstanceList_1 = require("../InstanceList/InstanceList");
|
|
7
|
+
class BootstrapRun {
|
|
8
|
+
numberOfBootstraps;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor for BootstrapRun class. Basically sets the number of bootstrap runs.
|
|
11
|
+
*
|
|
12
|
+
* @param numberOfBootstraps Number of bootstrap runs.
|
|
13
|
+
*/
|
|
14
|
+
constructor(numberOfBootstraps) {
|
|
15
|
+
this.numberOfBootstraps = numberOfBootstraps;
|
|
5
16
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
*
|
|
20
|
-
* @param numberOfBootstraps Number of bootstrap runs.
|
|
21
|
-
*/
|
|
22
|
-
constructor(numberOfBootstraps) {
|
|
23
|
-
this.numberOfBootstraps = numberOfBootstraps;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Execute the bootstrap run with the given classifier on the given data set using the given parameters.
|
|
27
|
-
*
|
|
28
|
-
* @param experiment Experiment to be run.
|
|
29
|
-
* @return An ExperimentPerformance instance.
|
|
30
|
-
*/
|
|
31
|
-
execute(experiment) {
|
|
32
|
-
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
33
|
-
for (let i = 0; i < this.numberOfBootstraps; i++) {
|
|
34
|
-
let bootstrap = new Bootstrap_1.Bootstrap(experiment.getDataSet().getInstances(), i + experiment.getParameter().getSeed());
|
|
35
|
-
let bootstrapSample = new InstanceList_1.InstanceList(bootstrap.getSample());
|
|
36
|
-
experiment.getmodel().train(bootstrapSample, experiment.getParameter());
|
|
37
|
-
result.add(experiment.getmodel().test(experiment.getDataSet().getInstanceList()));
|
|
38
|
-
}
|
|
39
|
-
return result;
|
|
17
|
+
/**
|
|
18
|
+
* Execute the bootstrap run with the given classifier on the given data set using the given parameters.
|
|
19
|
+
*
|
|
20
|
+
* @param experiment Experiment to be run.
|
|
21
|
+
* @return An ExperimentPerformance instance.
|
|
22
|
+
*/
|
|
23
|
+
execute(experiment) {
|
|
24
|
+
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
25
|
+
for (let i = 0; i < this.numberOfBootstraps; i++) {
|
|
26
|
+
let bootstrap = new Bootstrap_1.Bootstrap(experiment.getDataSet().getInstances(), i + experiment.getParameter().getSeed());
|
|
27
|
+
let bootstrapSample = new InstanceList_1.InstanceList(bootstrap.getSample());
|
|
28
|
+
experiment.getmodel().train(bootstrapSample, experiment.getParameter());
|
|
29
|
+
result.add(experiment.getmodel().test(experiment.getDataSet().getInstanceList()));
|
|
40
30
|
}
|
|
31
|
+
return result;
|
|
41
32
|
}
|
|
42
|
-
|
|
43
|
-
|
|
33
|
+
}
|
|
34
|
+
exports.BootstrapRun = BootstrapRun;
|
|
44
35
|
//# sourceMappingURL=BootstrapRun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BootstrapRun.js","sourceRoot":"","sources":["../../source/Experiment/BootstrapRun.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BootstrapRun.js","sourceRoot":"","sources":["../../source/Experiment/BootstrapRun.ts"],"names":[],"mappings":";;;AAEA,gFAA2E;AAC3E,kEAA6D;AAC7D,+DAA0D;AAG1D,MAAa,YAAY;IAEb,kBAAkB,CAAQ;IAElC;;;;OAIG;IACH,YAAY,kBAA0B;QAClC,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAA;IAChD,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,UAAsB;QAC1B,IAAI,MAAM,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACzC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,kBAAkB,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/C,IAAI,SAAS,GAAG,IAAI,qBAAS,CAAW,UAAU,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;YACzH,IAAI,eAAe,GAAG,IAAI,2BAAY,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,CAAC;YAC9D,UAAU,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,CAAC;YACxE,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,UAAU,EAAE,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;QACtF,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA7BD,oCA6BC"}
|
|
@@ -1,57 +1,50 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Experiment = void 0;
|
|
4
|
+
class Experiment {
|
|
5
|
+
model;
|
|
6
|
+
parameter;
|
|
7
|
+
dataSet;
|
|
8
|
+
/**
|
|
9
|
+
* Constructor for a specific machine learning experiment
|
|
10
|
+
* @param model Model used in the machine learning experiment
|
|
11
|
+
* @param parameter Parameter(s) of the classifier.
|
|
12
|
+
* @param dataSet DataSet on which the classifier is run.
|
|
13
|
+
*/
|
|
14
|
+
constructor(model, parameter, dataSet) {
|
|
15
|
+
this.model = model;
|
|
16
|
+
this.parameter = parameter;
|
|
17
|
+
this.dataSet = dataSet;
|
|
5
18
|
}
|
|
6
|
-
|
|
7
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Accessor for the classifier attribute.
|
|
21
|
+
* @return Classifier attribute.
|
|
22
|
+
*/
|
|
23
|
+
getmodel() {
|
|
24
|
+
return this.model;
|
|
8
25
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* Constructor for a specific machine learning experiment
|
|
16
|
-
* @param model Model used in the machine learning experiment
|
|
17
|
-
* @param parameter Parameter(s) of the classifier.
|
|
18
|
-
* @param dataSet DataSet on which the classifier is run.
|
|
19
|
-
*/
|
|
20
|
-
constructor(model, parameter, dataSet) {
|
|
21
|
-
this.model = model;
|
|
22
|
-
this.parameter = parameter;
|
|
23
|
-
this.dataSet = dataSet;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Accessor for the classifier attribute.
|
|
27
|
-
* @return Classifier attribute.
|
|
28
|
-
*/
|
|
29
|
-
getmodel() {
|
|
30
|
-
return this.model;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Accessor for the parameter attribute.
|
|
34
|
-
* @return Parameter attribute.
|
|
35
|
-
*/
|
|
36
|
-
getParameter() {
|
|
37
|
-
return this.parameter;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Accessor for the dataSet attribute.
|
|
41
|
-
* @return DataSet attribute.
|
|
42
|
-
*/
|
|
43
|
-
getDataSet() {
|
|
44
|
-
return this.dataSet;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Construct and returns a feature selection experiment.
|
|
48
|
-
* @param featureSubSet Feature subset used in the feature selection experiment
|
|
49
|
-
* @return Experiment constructed
|
|
50
|
-
*/
|
|
51
|
-
featureSelectedExperiment(featureSubSet) {
|
|
52
|
-
return new Experiment(this.model, this.parameter, this.dataSet.getSubSetOfFeatures(featureSubSet));
|
|
53
|
-
}
|
|
26
|
+
/**
|
|
27
|
+
* Accessor for the parameter attribute.
|
|
28
|
+
* @return Parameter attribute.
|
|
29
|
+
*/
|
|
30
|
+
getParameter() {
|
|
31
|
+
return this.parameter;
|
|
54
32
|
}
|
|
55
|
-
|
|
56
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Accessor for the dataSet attribute.
|
|
35
|
+
* @return DataSet attribute.
|
|
36
|
+
*/
|
|
37
|
+
getDataSet() {
|
|
38
|
+
return this.dataSet;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Construct and returns a feature selection experiment.
|
|
42
|
+
* @param featureSubSet Feature subset used in the feature selection experiment
|
|
43
|
+
* @return Experiment constructed
|
|
44
|
+
*/
|
|
45
|
+
featureSelectedExperiment(featureSubSet) {
|
|
46
|
+
return new Experiment(this.model, this.parameter, this.dataSet.getSubSetOfFeatures(featureSubSet));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.Experiment = Experiment;
|
|
57
50
|
//# sourceMappingURL=Experiment.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Experiment.js","sourceRoot":"","sources":["../../source/Experiment/Experiment.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Experiment.js","sourceRoot":"","sources":["../../source/Experiment/Experiment.ts"],"names":[],"mappings":";;;AAKA,MAAa,UAAU;IAEF,KAAK,CAAO;IACZ,SAAS,CAAW;IACpB,OAAO,CAAS;IAEjC;;;;;OAKG;IACH,YAAY,KAAY,EAAE,SAAoB,EAAE,OAAgB;QAC5D,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,CAAC;IAED;;;OAGG;IACH,QAAQ;QACJ,OAAO,IAAI,CAAC,KAAK,CAAA;IACrB,CAAC;IAED;;;OAGG;IACH,YAAY;QACR,OAAO,IAAI,CAAC,SAAS,CAAA;IACzB,CAAC;IAED;;;OAGG;IACH,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAA;IACvB,CAAC;IAED;;;;OAIG;IACH,yBAAyB,CAAC,aAA4B;QAClD,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC,CAAC;IACvG,CAAC;CAEJ;AAnDD,gCAmDC"}
|
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KFoldRun = void 0;
|
|
4
|
+
const ExperimentPerformance_1 = require("../Performance/ExperimentPerformance");
|
|
5
|
+
const InstanceList_1 = require("../InstanceList/InstanceList");
|
|
6
|
+
const KFoldCrossValidation_1 = require("nlptoolkit-sampling/dist/KFoldCrossValidation");
|
|
7
|
+
class KFoldRun {
|
|
8
|
+
K;
|
|
9
|
+
/**
|
|
10
|
+
* Constructor for KFoldRun class. Basically sets K parameter of the K-fold cross-validation.
|
|
11
|
+
*
|
|
12
|
+
* @param K K of the K-fold cross-validation.
|
|
13
|
+
*/
|
|
14
|
+
constructor(K) {
|
|
15
|
+
this.K = K;
|
|
5
16
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
constructor(K) {
|
|
23
|
-
this.K = K;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Runs a K fold cross-validated experiment for the given classifier with the given parameters. The experiment
|
|
27
|
-
* results will be added to the experimentPerformance.
|
|
28
|
-
* @param model Model for the experiment
|
|
29
|
-
* @param parameter Hyperparameters of the classifier of the experiment
|
|
30
|
-
* @param experimentPerformance Storage to add experiment results
|
|
31
|
-
* @param crossValidation K-fold crossvalidated dataset.
|
|
32
|
-
* @throws DiscreteFeaturesNotAllowed If the classifier does not allow discrete features and the dataset contains
|
|
33
|
-
* discrete features, DiscreteFeaturesNotAllowed will be thrown.
|
|
34
|
-
*/
|
|
35
|
-
runExperiment(model, parameter, experimentPerformance, crossValidation) {
|
|
36
|
-
for (let i = 0; i < this.K; i++) {
|
|
37
|
-
let trainSet = new InstanceList_1.InstanceList(crossValidation.getTrainFold(i));
|
|
38
|
-
let testSet = new InstanceList_1.InstanceList(crossValidation.getTestFold(i));
|
|
39
|
-
model.train(trainSet, parameter);
|
|
40
|
-
experimentPerformance.add(model.test(testSet));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Execute K-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
45
|
-
*
|
|
46
|
-
* @param experiment Experiment to be run.
|
|
47
|
-
* @return An ExperimentPerformance instance.
|
|
48
|
-
*/
|
|
49
|
-
execute(experiment) {
|
|
50
|
-
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
51
|
-
let crossValidation = new KFoldCrossValidation_1.KFoldCrossValidation(experiment.getDataSet().getInstances(), this.K, experiment.getParameter().getSeed());
|
|
52
|
-
this.runExperiment(experiment.getmodel(), experiment.getParameter(), result, crossValidation);
|
|
53
|
-
return result;
|
|
17
|
+
/**
|
|
18
|
+
* Runs a K fold cross-validated experiment for the given classifier with the given parameters. The experiment
|
|
19
|
+
* results will be added to the experimentPerformance.
|
|
20
|
+
* @param model Model for the experiment
|
|
21
|
+
* @param parameter Hyperparameters of the classifier of the experiment
|
|
22
|
+
* @param experimentPerformance Storage to add experiment results
|
|
23
|
+
* @param crossValidation K-fold crossvalidated dataset.
|
|
24
|
+
* @throws DiscreteFeaturesNotAllowed If the classifier does not allow discrete features and the dataset contains
|
|
25
|
+
* discrete features, DiscreteFeaturesNotAllowed will be thrown.
|
|
26
|
+
*/
|
|
27
|
+
runExperiment(model, parameter, experimentPerformance, crossValidation) {
|
|
28
|
+
for (let i = 0; i < this.K; i++) {
|
|
29
|
+
let trainSet = new InstanceList_1.InstanceList(crossValidation.getTrainFold(i));
|
|
30
|
+
let testSet = new InstanceList_1.InstanceList(crossValidation.getTestFold(i));
|
|
31
|
+
model.train(trainSet, parameter);
|
|
32
|
+
experimentPerformance.add(model.test(testSet));
|
|
54
33
|
}
|
|
55
34
|
}
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Execute K-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
37
|
+
*
|
|
38
|
+
* @param experiment Experiment to be run.
|
|
39
|
+
* @return An ExperimentPerformance instance.
|
|
40
|
+
*/
|
|
41
|
+
execute(experiment) {
|
|
42
|
+
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
43
|
+
let crossValidation = new KFoldCrossValidation_1.KFoldCrossValidation(experiment.getDataSet().getInstances(), this.K, experiment.getParameter().getSeed());
|
|
44
|
+
this.runExperiment(experiment.getmodel(), experiment.getParameter(), result, crossValidation);
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.KFoldRun = KFoldRun;
|
|
58
49
|
//# sourceMappingURL=KFoldRun.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KFoldRun.js","sourceRoot":"","sources":["../../source/Experiment/KFoldRun.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KFoldRun.js","sourceRoot":"","sources":["../../source/Experiment/KFoldRun.ts"],"names":[],"mappings":";;;AAEA,gFAA2E;AAI3E,+DAA0D;AAC1D,wFAAmF;AAGnF,MAAa,QAAQ;IAEP,CAAC,CAAQ;IAEnB;;;;OAIG;IACH,YAAY,CAAS;QACjB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED;;;;;;;;;OASG;IACO,aAAa,CAAC,KAAY,EACZ,SAAoB,EACpB,qBAA4C,EAC5C,eAA0C;QAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,IAAI,QAAQ,GAAG,IAAI,2BAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,IAAI,OAAO,GAAG,IAAI,2BAAY,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAC/D,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACjC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,UAAsB;QAC1B,IAAI,MAAM,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACzC,IAAI,eAAe,GAAG,IAAI,2CAAoB,CAAW,UAAU,CAAC,UAAU,EAAE,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QAC9I,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;QAC9F,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ;AAhDD,4BAgDC"}
|
|
@@ -1,62 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KFoldRunSeparateTest = void 0;
|
|
4
|
+
const KFoldRun_1 = require("./KFoldRun");
|
|
5
|
+
const ExperimentPerformance_1 = require("../Performance/ExperimentPerformance");
|
|
6
|
+
const InstanceList_1 = require("../InstanceList/InstanceList");
|
|
7
|
+
const KFoldCrossValidation_1 = require("nlptoolkit-sampling/dist/KFoldCrossValidation");
|
|
8
|
+
const Partition_1 = require("../InstanceList/Partition");
|
|
9
|
+
class KFoldRunSeparateTest extends KFoldRun_1.KFoldRun {
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for KFoldRunSeparateTest class. Basically sets K parameter of the K-fold cross-validation.
|
|
12
|
+
*
|
|
13
|
+
* @param K K of the K-fold cross-validation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(K) {
|
|
16
|
+
super(K);
|
|
5
17
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* @param K K of the K-fold cross-validation.
|
|
23
|
-
*/
|
|
24
|
-
constructor(K) {
|
|
25
|
-
super(K);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Runs a K fold cross-validated experiment for the given classifier with the given parameters. Testing will be
|
|
29
|
-
* done on the separate test set. The experiment results will be added to the experimentPerformance.
|
|
30
|
-
* @param model Model for the experiment
|
|
31
|
-
* @param parameter Hyperparameters of the classifier of the experiment
|
|
32
|
-
* @param experimentPerformance Storage to add experiment results
|
|
33
|
-
* @param crossValidation K-fold crossvalidated dataset.
|
|
34
|
-
* @param testSet Test set on which experiment performance is calculated.
|
|
35
|
-
* @throws DiscreteFeaturesNotAllowed If the classifier does not allow discrete features and the dataset contains
|
|
36
|
-
* discrete features, DiscreteFeaturesNotAllowed will be thrown.
|
|
37
|
-
*/
|
|
38
|
-
runExperiment(model, parameter, experimentPerformance, crossValidation, testSet) {
|
|
39
|
-
for (let i = 0; i < this.K; i++) {
|
|
40
|
-
let trainSet = new InstanceList_1.InstanceList(crossValidation.getTrainFold(i));
|
|
41
|
-
model.train(trainSet, parameter);
|
|
42
|
-
experimentPerformance.add(model.test(testSet));
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Execute K-fold cross-validation with separate test set with the given classifier on the given data set using the given parameters.
|
|
47
|
-
*
|
|
48
|
-
* @param experiment Experiment to be run.
|
|
49
|
-
* @return An ExperimentPerformance instance.
|
|
50
|
-
*/
|
|
51
|
-
execute(experiment) {
|
|
52
|
-
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
53
|
-
let instanceList = experiment.getDataSet().getInstanceList();
|
|
54
|
-
let partition = new Partition_1.Partition(instanceList, 0.25, true);
|
|
55
|
-
let crossValidation = new KFoldCrossValidation_1.KFoldCrossValidation(partition.get(1).getInstances(), this.K, experiment.getParameter().getSeed());
|
|
56
|
-
this.runExperiment(experiment.getmodel(), experiment.getParameter(), result, crossValidation, partition.get(0));
|
|
57
|
-
return result;
|
|
18
|
+
/**
|
|
19
|
+
* Runs a K fold cross-validated experiment for the given classifier with the given parameters. Testing will be
|
|
20
|
+
* done on the separate test set. The experiment results will be added to the experimentPerformance.
|
|
21
|
+
* @param model Model for the experiment
|
|
22
|
+
* @param parameter Hyperparameters of the classifier of the experiment
|
|
23
|
+
* @param experimentPerformance Storage to add experiment results
|
|
24
|
+
* @param crossValidation K-fold crossvalidated dataset.
|
|
25
|
+
* @param testSet Test set on which experiment performance is calculated.
|
|
26
|
+
* @throws DiscreteFeaturesNotAllowed If the classifier does not allow discrete features and the dataset contains
|
|
27
|
+
* discrete features, DiscreteFeaturesNotAllowed will be thrown.
|
|
28
|
+
*/
|
|
29
|
+
runExperiment(model, parameter, experimentPerformance, crossValidation, testSet) {
|
|
30
|
+
for (let i = 0; i < this.K; i++) {
|
|
31
|
+
let trainSet = new InstanceList_1.InstanceList(crossValidation.getTrainFold(i));
|
|
32
|
+
model.train(trainSet, parameter);
|
|
33
|
+
experimentPerformance.add(model.test(testSet));
|
|
58
34
|
}
|
|
59
35
|
}
|
|
60
|
-
|
|
61
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Execute K-fold cross-validation with separate test set with the given classifier on the given data set using the given parameters.
|
|
38
|
+
*
|
|
39
|
+
* @param experiment Experiment to be run.
|
|
40
|
+
* @return An ExperimentPerformance instance.
|
|
41
|
+
*/
|
|
42
|
+
execute(experiment) {
|
|
43
|
+
let result = new ExperimentPerformance_1.ExperimentPerformance();
|
|
44
|
+
let instanceList = experiment.getDataSet().getInstanceList();
|
|
45
|
+
let partition = new Partition_1.Partition(instanceList, 0.25, true);
|
|
46
|
+
let crossValidation = new KFoldCrossValidation_1.KFoldCrossValidation(partition.get(1).getInstances(), this.K, experiment.getParameter().getSeed());
|
|
47
|
+
this.runExperiment(experiment.getmodel(), experiment.getParameter(), result, crossValidation, partition.get(0));
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
exports.KFoldRunSeparateTest = KFoldRunSeparateTest;
|
|
62
52
|
//# sourceMappingURL=KFoldRunSeparateTest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KFoldRunSeparateTest.js","sourceRoot":"","sources":["../../source/Experiment/KFoldRunSeparateTest.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KFoldRunSeparateTest.js","sourceRoot":"","sources":["../../source/Experiment/KFoldRunSeparateTest.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,gFAA2E;AAC3E,+DAA0D;AAI1D,wFAAmF;AACnF,yDAAoD;AAGpD,MAAa,oBAAqB,SAAQ,mBAAQ;IAE9C;;;;OAIG;IACH,YAAY,CAAS;QACjB,KAAK,CAAC,CAAC,CAAC,CAAC;IACb,CAAC;IAED;;;;;;;;;;OAUG;IACO,aAAa,CAAC,KAAY,EACZ,SAAoB,EACpB,qBAA4C,EAC5C,eAA0C,EAC1C,OAAsB;QAC1C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YAC9B,IAAI,QAAQ,GAAG,IAAI,2BAAY,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;YACjE,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;YACjC,qBAAqB,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,OAAO,CAAC,UAAsB;QAC1B,IAAI,MAAM,GAAG,IAAI,6CAAqB,EAAE,CAAC;QACzC,IAAI,YAAY,GAAG,UAAU,CAAC,UAAU,EAAE,CAAC,eAAe,EAAE,CAAC;QAC7D,IAAI,SAAS,GAAG,IAAI,qBAAS,CAAC,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QACxD,IAAI,eAAe,GAAG,IAAI,2CAAoB,CAAW,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,EAAE,EAAE,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,YAAY,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACvI,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,UAAU,CAAC,YAAY,EAAE,EAAE,MAAM,EAAE,eAAe,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAChH,OAAO,MAAM,CAAC;IAClB,CAAC;CAEJ;AAjDD,oDAiDC"}
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
3
|
//# sourceMappingURL=MultipleRun.js.map
|