nlptoolkit-classification 1.0.7 → 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/README.md +1 -0
- 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.d.ts +1 -1
- package/dist/Attribute/DiscreteAttribute.js +38 -48
- package/dist/Attribute/DiscreteAttribute.js.map +1 -1
- package/dist/Attribute/DiscreteIndexedAttribute.d.ts +2 -2
- package/dist/Attribute/DiscreteIndexedAttribute.js +47 -55
- package/dist/Attribute/DiscreteIndexedAttribute.js.map +1 -1
- package/dist/DataSet/DataDefinition.d.ts +11 -0
- package/dist/DataSet/DataDefinition.js +115 -112
- 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.d.ts +7 -7
- package/dist/Experiment/Experiment.js +46 -53
- package/dist/Experiment/Experiment.js.map +1 -1
- package/dist/Experiment/KFoldRun.d.ts +17 -2
- package/dist/Experiment/KFoldRun.js +45 -39
- package/dist/Experiment/KFoldRun.js.map +1 -1
- package/dist/Experiment/KFoldRunSeparateTest.d.ts +13 -2
- package/dist/Experiment/KFoldRunSeparateTest.js +48 -47
- 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.d.ts +18 -3
- package/dist/Experiment/SingleRunWithK.js +39 -33
- 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.d.ts +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.d.ts +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.d.ts +45 -0
- package/dist/InstanceList/Partition.js +176 -131
- package/dist/InstanceList/Partition.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionCondition.d.ts +8 -0
- package/dist/Model/DecisionTree/DecisionCondition.js +71 -72
- package/dist/Model/DecisionTree/DecisionCondition.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionNode.d.ts +38 -1
- package/dist/Model/DecisionTree/DecisionNode.js +302 -275
- package/dist/Model/DecisionTree/DecisionNode.js.map +1 -1
- package/dist/Model/DecisionTree/DecisionStump.d.ts +17 -0
- package/dist/Model/DecisionTree/DecisionStump.js +25 -0
- package/dist/Model/DecisionTree/DecisionStump.js.map +1 -0
- package/dist/Model/DecisionTree/DecisionTree.d.ts +24 -9
- package/dist/Model/DecisionTree/DecisionTree.js +90 -76
- package/dist/Model/DecisionTree/DecisionTree.js.map +1 -1
- package/dist/Model/DummyModel.d.ts +28 -3
- package/dist/Model/DummyModel.js +64 -50
- package/dist/Model/DummyModel.js.map +1 -1
- package/dist/{Classifier/Bagging.d.ts → Model/Ensemble/BaggingModel.d.ts} +8 -4
- package/dist/Model/Ensemble/BaggingModel.js +37 -0
- package/dist/Model/Ensemble/BaggingModel.js.map +1 -0
- package/dist/{Classifier/RandomForest.d.ts → Model/Ensemble/RandomForestModel.d.ts} +8 -4
- package/dist/Model/Ensemble/RandomForestModel.js +34 -0
- package/dist/Model/Ensemble/RandomForestModel.js.map +1 -0
- package/dist/Model/Ensemble/TreeEnsembleModel.d.ts +32 -0
- package/dist/Model/Ensemble/TreeEnsembleModel.js +61 -0
- package/dist/Model/Ensemble/TreeEnsembleModel.js.map +1 -0
- package/dist/Model/Model.d.ts +50 -0
- package/dist/Model/Model.js +131 -72
- package/dist/Model/Model.js.map +1 -1
- package/dist/Model/NeuralNetwork/DeepNetworkModel.d.ts +47 -0
- package/dist/Model/NeuralNetwork/DeepNetworkModel.js +180 -0
- package/dist/Model/NeuralNetwork/DeepNetworkModel.js.map +1 -0
- package/dist/Model/NeuralNetwork/LinearPerceptronModel.d.ts +31 -0
- package/dist/Model/NeuralNetwork/LinearPerceptronModel.js +75 -0
- package/dist/Model/NeuralNetwork/LinearPerceptronModel.js.map +1 -0
- package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.d.ts +39 -0
- package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js +119 -0
- package/dist/Model/NeuralNetwork/MultiLayerPerceptronModel.js.map +1 -0
- package/dist/Model/{NeuralNetworkModel.d.ts → NeuralNetwork/NeuralNetworkModel.d.ts} +19 -5
- package/dist/Model/NeuralNetwork/NeuralNetworkModel.js +211 -0
- package/dist/Model/NeuralNetwork/NeuralNetworkModel.js.map +1 -0
- package/dist/Model/{KnnInstance.d.ts → NonParametric/KnnInstance.d.ts} +1 -1
- package/dist/Model/NonParametric/KnnInstance.js +25 -0
- package/dist/Model/NonParametric/KnnInstance.js.map +1 -0
- package/dist/Model/{KnnModel.d.ts → NonParametric/KnnModel.d.ts} +30 -6
- package/dist/Model/NonParametric/KnnModel.js +111 -0
- package/dist/Model/NonParametric/KnnModel.js.map +1 -0
- package/dist/Model/{GaussianModel.d.ts → Parametric/GaussianModel.d.ts} +20 -2
- package/dist/Model/Parametric/GaussianModel.js +95 -0
- package/dist/Model/Parametric/GaussianModel.js.map +1 -0
- package/dist/Model/Parametric/KMeansModel.d.ts +36 -0
- package/dist/Model/Parametric/KMeansModel.js +65 -0
- package/dist/Model/Parametric/KMeansModel.js.map +1 -0
- package/dist/Model/Parametric/LdaModel.d.ts +44 -0
- package/dist/Model/Parametric/LdaModel.js +90 -0
- package/dist/Model/Parametric/LdaModel.js.map +1 -0
- package/dist/Model/{NaiveBayesModel.d.ts → Parametric/NaiveBayesModel.d.ts} +30 -10
- package/dist/Model/Parametric/NaiveBayesModel.js +131 -0
- package/dist/Model/Parametric/NaiveBayesModel.js.map +1 -0
- package/dist/Model/Parametric/QdaModel.d.ts +30 -0
- package/dist/Model/Parametric/QdaModel.js +75 -0
- package/dist/Model/Parametric/QdaModel.js.map +1 -0
- package/dist/Model/RandomModel.d.ts +32 -2
- package/dist/Model/RandomModel.js +85 -60
- 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.d.ts +2 -2
- package/dist/Parameter/C45Parameter.js +34 -42
- package/dist/Parameter/C45Parameter.js.map +1 -1
- package/dist/Parameter/DeepNetworkParameter.d.ts +2 -2
- 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.d.ts +1 -1
- package/dist/Parameter/KnnParameter.js +25 -34
- package/dist/Parameter/KnnParameter.js.map +1 -1
- package/dist/Parameter/LinearPerceptronParameter.d.ts +4 -4
- package/dist/Parameter/LinearPerceptronParameter.js +56 -62
- package/dist/Parameter/LinearPerceptronParameter.js.map +1 -1
- package/dist/Parameter/MultiLayerPerceptronParameter.d.ts +2 -2
- package/dist/Parameter/MultiLayerPerceptronParameter.js +38 -46
- package/dist/Parameter/MultiLayerPerceptronParameter.js.map +1 -1
- package/dist/Parameter/Parameter.d.ts +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.d.ts +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.d.ts +12 -0
- package/dist/StatisticalTest/Combined5x2F.js +41 -39
- package/dist/StatisticalTest/Combined5x2F.js.map +1 -1
- package/dist/StatisticalTest/Combined5x2t.d.ts +13 -0
- package/dist/StatisticalTest/Combined5x2t.js +42 -39
- package/dist/StatisticalTest/Combined5x2t.js.map +1 -1
- package/dist/StatisticalTest/Paired5x2t.d.ts +12 -0
- package/dist/StatisticalTest/Paired5x2t.js +40 -38
- package/dist/StatisticalTest/Paired5x2t.js.map +1 -1
- package/dist/StatisticalTest/PairedTest.d.ts +12 -0
- package/dist/StatisticalTest/PairedTest.js +31 -29
- package/dist/StatisticalTest/PairedTest.js.map +1 -1
- package/dist/StatisticalTest/Pairedt.d.ts +12 -0
- package/dist/StatisticalTest/Pairedt.js +38 -36
- package/dist/StatisticalTest/Pairedt.js.map +1 -1
- package/dist/StatisticalTest/Sign.d.ts +17 -0
- package/dist/StatisticalTest/Sign.js +50 -43
- package/dist/StatisticalTest/Sign.js.map +1 -1
- package/dist/StatisticalTest/StatisticalTestResult.d.ts +30 -0
- package/dist/StatisticalTest/StatisticalTestResult.js +65 -43
- 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.d.ts +88 -0
- package/dist/index.js +105 -0
- package/dist/index.js.map +1 -0
- package/package.json +9 -8
- package/source/Attribute/DiscreteAttribute.ts +1 -1
- package/source/Attribute/DiscreteIndexedAttribute.ts +2 -2
- package/source/DataSet/DataDefinition.ts +11 -0
- package/source/Experiment/BootstrapRun.ts +2 -2
- package/source/Experiment/Experiment.ts +10 -10
- package/source/Experiment/KFoldRun.ts +20 -5
- package/source/Experiment/KFoldRunSeparateTest.ts +16 -5
- package/source/Experiment/MxKFoldRun.ts +1 -1
- package/source/Experiment/MxKFoldRunSeparateTest.ts +1 -1
- package/source/Experiment/SingleRunWithK.ts +20 -5
- package/source/Experiment/StratifiedKFoldRun.ts +1 -1
- package/source/Experiment/StratifiedKFoldRunSeparateTest.ts +1 -1
- package/source/Experiment/StratifiedMxKFoldRun.ts +1 -1
- package/source/Experiment/StratifiedMxKFoldRunSeparateTest.ts +3 -3
- package/source/Experiment/StratifiedSingleRunWithK.ts +1 -1
- package/source/Filter/LaryFilter.ts +1 -1
- package/source/Filter/TrainedFeatureFilter.ts +1 -1
- package/source/InstanceList/Partition.ts +125 -65
- package/source/Model/DecisionTree/DecisionCondition.ts +8 -0
- package/source/Model/DecisionTree/DecisionNode.ts +56 -20
- package/source/Model/DecisionTree/DecisionStump.ts +26 -0
- package/source/Model/DecisionTree/DecisionTree.ts +44 -15
- package/source/Model/DummyModel.ts +40 -10
- package/source/{Classifier/Bagging.ts → Model/Ensemble/BaggingModel.ts} +15 -12
- package/source/{Classifier/RandomForest.ts → Model/Ensemble/RandomForestModel.ts} +14 -12
- package/source/Model/{TreeEnsembleModel.ts → Ensemble/TreeEnsembleModel.ts} +26 -18
- package/source/Model/Model.ts +77 -0
- package/source/Model/{DeepNetworkModel.ts → NeuralNetwork/DeepNetworkModel.ts} +59 -56
- package/source/Model/NeuralNetwork/LinearPerceptronModel.ts +81 -0
- package/source/Model/{MultiLayerPerceptronModel.ts → NeuralNetwork/MultiLayerPerceptronModel.ts} +46 -39
- package/source/Model/{NeuralNetworkModel.ts → NeuralNetwork/NeuralNetworkModel.ts} +20 -7
- package/source/Model/{KnnInstance.ts → NonParametric/KnnInstance.ts} +1 -1
- package/source/Model/{KnnModel.ts → NonParametric/KnnModel.ts} +48 -19
- package/source/Model/{GaussianModel.ts → Parametric/GaussianModel.ts} +21 -3
- package/source/Model/Parametric/KMeansModel.ts +72 -0
- package/source/Model/Parametric/LdaModel.ts +98 -0
- package/source/Model/{NaiveBayesModel.ts → Parametric/NaiveBayesModel.ts} +68 -25
- package/source/Model/Parametric/QdaModel.ts +83 -0
- package/source/Model/RandomModel.ts +54 -16
- package/source/Parameter/C45Parameter.ts +2 -2
- package/source/Parameter/DeepNetworkParameter.ts +2 -2
- package/source/Parameter/KnnParameter.ts +1 -1
- package/source/Parameter/LinearPerceptronParameter.ts +4 -4
- package/source/Parameter/MultiLayerPerceptronParameter.ts +2 -2
- package/source/Parameter/Parameter.ts +1 -1
- package/source/Performance/ConfusionMatrix.ts +1 -1
- package/source/StatisticalTest/Combined5x2F.ts +12 -0
- package/source/StatisticalTest/Combined5x2t.ts +13 -0
- package/source/StatisticalTest/Paired5x2t.ts +12 -0
- package/source/StatisticalTest/PairedTest.ts +12 -0
- package/source/StatisticalTest/Pairedt.ts +12 -0
- package/source/StatisticalTest/Sign.ts +17 -0
- package/source/StatisticalTest/StatisticalTestResult.ts +30 -0
- package/source/index.ts +88 -0
- package/tests/Classifier/C45Test.ts +2 -2
- package/tests/Classifier/DeepNetworkTest.ts +3 -5
- package/tests/Classifier/DummyTest.ts +2 -2
- package/tests/Classifier/KMeansTest.ts +2 -2
- package/tests/Classifier/KnnTest.ts +2 -2
- package/tests/Classifier/LdaTest.ts +2 -2
- package/tests/Classifier/LinearPerceptronTest.ts +2 -2
- package/tests/Classifier/MultiLayerPerceptronTest.ts +2 -3
- package/tests/Classifier/NaiveBayesTest.ts +2 -2
- package/tests/Classifier/QdaTest.ts +2 -2
- package/tests/Classifier/RandomForestTest.ts +2 -2
- package/tsconfig.json +4 -4
- package/dist/Classifier/Bagging.js +0 -45
- package/dist/Classifier/Bagging.js.map +0 -1
- package/dist/Classifier/C45.d.ts +0 -14
- package/dist/Classifier/C45.js +0 -43
- package/dist/Classifier/C45.js.map +0 -1
- package/dist/Classifier/C45Stump.d.ts +0 -13
- package/dist/Classifier/C45Stump.js +0 -32
- package/dist/Classifier/C45Stump.js.map +0 -1
- package/dist/Classifier/Classifier.d.ts +0 -40
- package/dist/Classifier/Classifier.js +0 -72
- package/dist/Classifier/Classifier.js.map +0 -1
- package/dist/Classifier/DeepNetwork.d.ts +0 -14
- package/dist/Classifier/DeepNetwork.js +0 -34
- package/dist/Classifier/DeepNetwork.js.map +0 -1
- package/dist/Classifier/Dummy.d.ts +0 -14
- package/dist/Classifier/Dummy.js +0 -32
- package/dist/Classifier/Dummy.js.map +0 -1
- package/dist/Classifier/KMeans.d.ts +0 -13
- package/dist/Classifier/KMeans.js +0 -39
- package/dist/Classifier/KMeans.js.map +0 -1
- package/dist/Classifier/Knn.d.ts +0 -14
- package/dist/Classifier/Knn.js +0 -32
- package/dist/Classifier/Knn.js.map +0 -1
- package/dist/Classifier/Lda.d.ts +0 -13
- package/dist/Classifier/Lda.js +0 -55
- package/dist/Classifier/Lda.js.map +0 -1
- package/dist/Classifier/LinearPerceptron.d.ts +0 -15
- package/dist/Classifier/LinearPerceptron.js +0 -35
- package/dist/Classifier/LinearPerceptron.js.map +0 -1
- package/dist/Classifier/MultiLayerPerceptron.d.ts +0 -15
- package/dist/Classifier/MultiLayerPerceptron.js +0 -35
- package/dist/Classifier/MultiLayerPerceptron.js.map +0 -1
- package/dist/Classifier/NaiveBayes.d.ts +0 -26
- package/dist/Classifier/NaiveBayes.js +0 -70
- package/dist/Classifier/NaiveBayes.js.map +0 -1
- package/dist/Classifier/Qda.d.ts +0 -13
- package/dist/Classifier/Qda.js +0 -53
- package/dist/Classifier/Qda.js.map +0 -1
- package/dist/Classifier/RandomClassifier.d.ts +0 -13
- package/dist/Classifier/RandomClassifier.js +0 -35
- package/dist/Classifier/RandomClassifier.js.map +0 -1
- package/dist/Classifier/RandomForest.js +0 -42
- package/dist/Classifier/RandomForest.js.map +0 -1
- package/dist/Model/DeepNetworkModel.d.ts +0 -45
- package/dist/Model/DeepNetworkModel.js +0 -187
- package/dist/Model/DeepNetworkModel.js.map +0 -1
- package/dist/Model/GaussianModel.js +0 -86
- package/dist/Model/GaussianModel.js.map +0 -1
- package/dist/Model/KMeansModel.d.ts +0 -28
- package/dist/Model/KMeansModel.js +0 -61
- package/dist/Model/KMeansModel.js.map +0 -1
- package/dist/Model/KnnInstance.js +0 -33
- package/dist/Model/KnnInstance.js.map +0 -1
- package/dist/Model/KnnModel.js +0 -95
- package/dist/Model/KnnModel.js.map +0 -1
- package/dist/Model/LdaModel.d.ts +0 -28
- package/dist/Model/LdaModel.js +0 -67
- package/dist/Model/LdaModel.js.map +0 -1
- package/dist/Model/LinearPerceptronModel.d.ts +0 -24
- package/dist/Model/LinearPerceptronModel.js +0 -91
- package/dist/Model/LinearPerceptronModel.js.map +0 -1
- package/dist/Model/MultiLayerPerceptronModel.d.ts +0 -33
- package/dist/Model/MultiLayerPerceptronModel.js +0 -123
- package/dist/Model/MultiLayerPerceptronModel.js.map +0 -1
- package/dist/Model/NaiveBayesModel.js +0 -107
- package/dist/Model/NaiveBayesModel.js.map +0 -1
- package/dist/Model/NeuralNetworkModel.js +0 -202
- package/dist/Model/NeuralNetworkModel.js.map +0 -1
- package/dist/Model/QdaModel.d.ts +0 -27
- package/dist/Model/QdaModel.js +0 -63
- package/dist/Model/QdaModel.js.map +0 -1
- package/dist/Model/TreeEnsembleModel.d.ts +0 -22
- package/dist/Model/TreeEnsembleModel.js +0 -64
- package/dist/Model/TreeEnsembleModel.js.map +0 -1
- package/index.js +0 -100
- package/source/Classifier/C45.ts +0 -34
- package/source/Classifier/C45Stump.ts +0 -23
- package/source/Classifier/Classifier.ts +0 -72
- package/source/Classifier/DeepNetwork.ts +0 -26
- package/source/Classifier/Dummy.ts +0 -23
- package/source/Classifier/KMeans.ts +0 -30
- package/source/Classifier/Knn.ts +0 -25
- package/source/Classifier/Lda.ts +0 -47
- package/source/Classifier/LinearPerceptron.ts +0 -27
- package/source/Classifier/MultiLayerPerceptron.ts +0 -27
- package/source/Classifier/NaiveBayes.ts +0 -66
- package/source/Classifier/Qda.ts +0 -46
- package/source/Classifier/RandomClassifier.ts +0 -26
- package/source/Model/KMeansModel.ts +0 -56
- package/source/Model/LdaModel.ts +0 -62
- package/source/Model/LinearPerceptronModel.ts +0 -83
- package/source/Model/QdaModel.ts +0 -57
- package/source/tsconfig.json +0 -13
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {LdaModel} from "./LdaModel";
|
|
2
|
+
import {Matrix} from "nlptoolkit-math/dist/Matrix";
|
|
3
|
+
import {Vector} from "nlptoolkit-math/dist/Vector";
|
|
4
|
+
import {Instance} from "../../Instance/Instance";
|
|
5
|
+
import {FileContents} from "nlptoolkit-util/dist/FileContents";
|
|
6
|
+
import {InstanceList} from "../../InstanceList/InstanceList";
|
|
7
|
+
import {Parameter} from "../../Parameter/Parameter";
|
|
8
|
+
import {Partition} from "../../InstanceList/Partition";
|
|
9
|
+
import {InstanceListOfSameClass} from "../../InstanceList/InstanceListOfSameClass";
|
|
10
|
+
|
|
11
|
+
export class QdaModel extends LdaModel{
|
|
12
|
+
|
|
13
|
+
private W: Map<string, Matrix>
|
|
14
|
+
|
|
15
|
+
constructor2(fileName: string) {
|
|
16
|
+
let input = new FileContents(fileName)
|
|
17
|
+
let size = this.loadPriorDistribution(input)
|
|
18
|
+
this.loadWandW0(input, size)
|
|
19
|
+
this.W = new Map<string, Matrix>()
|
|
20
|
+
for (let i = 0; i < size; i++){
|
|
21
|
+
let c = input.readLine()
|
|
22
|
+
let matrix = this.loadMatrix(input)
|
|
23
|
+
this.W.set(c, matrix)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The calculateMetric method takes an {@link Instance} and a String as inputs. It multiplies Matrix Wi with Vector xi
|
|
29
|
+
* then calculates the dot product of it with xi. Then, again it finds the dot product of wi and xi and returns the summation with w0i.
|
|
30
|
+
*
|
|
31
|
+
* @param instance {@link Instance} input.
|
|
32
|
+
* @param Ci String input.
|
|
33
|
+
* @return The result of Wi.multiplyWithVectorFromLeft(xi).dotProduct(xi) + wi.dotProduct(xi) + w0i.
|
|
34
|
+
*/
|
|
35
|
+
calculateMetric(instance: Instance, Ci: string): number {
|
|
36
|
+
let xi = instance.toVector();
|
|
37
|
+
let Wi = this.W.get(Ci);
|
|
38
|
+
let wi = this.w.get(Ci);
|
|
39
|
+
let w0i = this.w0.get(Ci);
|
|
40
|
+
return Wi.multiplyWithVectorFromLeft(xi).dotProduct(xi) + wi.dotProduct(xi) + w0i;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
saveTxt(fileName: string){
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Training algorithm for the quadratic discriminant analysis classifier (Introduction to Machine Learning, Alpaydin, 2015).
|
|
48
|
+
*
|
|
49
|
+
* @param trainSet Training data given to the algorithm.
|
|
50
|
+
* @param parameters -
|
|
51
|
+
*/
|
|
52
|
+
train(trainSet: InstanceList, parameters: Parameter) {
|
|
53
|
+
let determinant = 0
|
|
54
|
+
this.w0 = new Map<string, number>();
|
|
55
|
+
this.w = new Map<string, Vector>();
|
|
56
|
+
this.W = new Map<string, Matrix>();
|
|
57
|
+
let classLists = new Partition(trainSet);
|
|
58
|
+
this.priorDistribution = trainSet.classDistribution();
|
|
59
|
+
for (let i = 0; i < classLists.size(); i++) {
|
|
60
|
+
let Ci = (<InstanceListOfSameClass> classLists.get(i)).getClassLabel();
|
|
61
|
+
let averageVector = new Vector(classLists.get(i).continuousAttributeAverage());
|
|
62
|
+
let classCovariance = classLists.get(i).covariance(averageVector);
|
|
63
|
+
determinant = classCovariance.determinant();
|
|
64
|
+
classCovariance.inverse();
|
|
65
|
+
let Wi = classCovariance.clone();
|
|
66
|
+
Wi.multiplyWithConstant(-0.5);
|
|
67
|
+
this.W.set(Ci, Wi);
|
|
68
|
+
let wi = classCovariance.multiplyWithVectorFromLeft(averageVector);
|
|
69
|
+
this.w.set(Ci, wi);
|
|
70
|
+
let w0i = -0.5 * (wi.dotProduct(averageVector) + Math.log(determinant)) + Math.log(this.priorDistribution.getProbability(Ci));
|
|
71
|
+
this.w0.set(Ci, w0i);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Loads the Qda model from an input file.
|
|
77
|
+
* @param fileName File name of the Qda model.
|
|
78
|
+
*/
|
|
79
|
+
loadModel(fileName: string): void{
|
|
80
|
+
this.constructor2(fileName)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
@@ -3,28 +3,39 @@ import {Instance} from "../Instance/Instance";
|
|
|
3
3
|
import {CompositeInstance} from "../Instance/CompositeInstance";
|
|
4
4
|
import {Random} from "nlptoolkit-util/dist/Random";
|
|
5
5
|
import {FileContents} from "nlptoolkit-util/dist/FileContents";
|
|
6
|
+
import {InstanceList} from "../InstanceList/InstanceList";
|
|
7
|
+
import {Parameter} from "../Parameter/Parameter";
|
|
6
8
|
|
|
7
9
|
export class RandomModel extends Model{
|
|
8
10
|
|
|
9
|
-
private
|
|
11
|
+
private classLabels: Array<string>
|
|
10
12
|
private random: Random
|
|
11
13
|
private seed: number
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
15
|
+
/**
|
|
16
|
+
* A constructor that sets the class labels.
|
|
17
|
+
*
|
|
18
|
+
* @param classLabels An ArrayList of class labels.
|
|
19
|
+
* @param seed Seed of the random function.
|
|
20
|
+
*/
|
|
21
|
+
constructor1(classLabels: Array<string>, seed: number) {
|
|
22
|
+
this.classLabels = classLabels
|
|
23
|
+
this.random = new Random(seed)
|
|
24
|
+
this.seed = seed
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Loads a random classifier model from an input model file.
|
|
29
|
+
* @param fileName Model file name.
|
|
30
|
+
*/
|
|
31
|
+
constructor2(fileName: string) {
|
|
32
|
+
let input = new FileContents(fileName)
|
|
33
|
+
this.seed = parseInt(input.readLine())
|
|
34
|
+
this.random = new Random(this.seed)
|
|
35
|
+
let size = parseInt(input.readLine())
|
|
36
|
+
this.classLabels = new Array<string>()
|
|
37
|
+
for (let i = 0; i < size; i++){
|
|
38
|
+
this.classLabels.push(input.readLine())
|
|
28
39
|
}
|
|
29
40
|
}
|
|
30
41
|
|
|
@@ -48,6 +59,11 @@ export class RandomModel extends Model{
|
|
|
48
59
|
}
|
|
49
60
|
}
|
|
50
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Calculates the posterior probability distribution for the given instance according to random model.
|
|
64
|
+
* @param instance Instance for which posterior probability distribution is calculated.
|
|
65
|
+
* @return Posterior probability distribution for the given instance.
|
|
66
|
+
*/
|
|
51
67
|
predictProbability(instance: Instance): Map<string, number> {
|
|
52
68
|
let result = new Map<string, number>();
|
|
53
69
|
for (let classLabel of this.classLabels){
|
|
@@ -59,4 +75,26 @@ export class RandomModel extends Model{
|
|
|
59
75
|
saveTxt(fileName: string){
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Training algorithm for random classifier.
|
|
80
|
+
*
|
|
81
|
+
* @param trainSet Training data given to the algorithm.
|
|
82
|
+
* @param parameters -
|
|
83
|
+
*/
|
|
84
|
+
train(trainSet: InstanceList, parameters: Parameter): void {
|
|
85
|
+
let result = new Array<string>()
|
|
86
|
+
for (let s of trainSet.classDistribution().keys()){
|
|
87
|
+
result.push(s)
|
|
88
|
+
}
|
|
89
|
+
this.constructor1(result, parameters.getSeed());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Loads the random classifier model from an input file.
|
|
94
|
+
* @param fileName File name of the random classifier model.
|
|
95
|
+
*/
|
|
96
|
+
loadModel(fileName: string): void{
|
|
97
|
+
this.constructor2(fileName)
|
|
98
|
+
}
|
|
99
|
+
|
|
62
100
|
}
|
|
@@ -2,8 +2,8 @@ import {Parameter} from "./Parameter";
|
|
|
2
2
|
|
|
3
3
|
export class C45Parameter extends Parameter{
|
|
4
4
|
|
|
5
|
-
private prune: boolean
|
|
6
|
-
private crossValidationRatio: number
|
|
5
|
+
private readonly prune: boolean
|
|
6
|
+
private readonly crossValidationRatio: number
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Parameters of the C4.5 univariate decision tree classifier.
|
|
@@ -2,8 +2,8 @@ import {LinearPerceptronParameter} from "./LinearPerceptronParameter";
|
|
|
2
2
|
import {ActivationFunction} from "./ActivationFunction";
|
|
3
3
|
|
|
4
4
|
export class DeepNetworkParameter extends LinearPerceptronParameter{
|
|
5
|
-
private hiddenLayers: Array<number>
|
|
6
|
-
private activationFunction: ActivationFunction
|
|
5
|
+
private readonly hiddenLayers: Array<number>
|
|
6
|
+
private readonly activationFunction: ActivationFunction
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Parameters of the deep network classifier.
|
|
@@ -2,10 +2,10 @@ import {Parameter} from "./Parameter";
|
|
|
2
2
|
|
|
3
3
|
export class LinearPerceptronParameter extends Parameter{
|
|
4
4
|
|
|
5
|
-
private learningRate: number
|
|
6
|
-
private etaDecrease: number
|
|
7
|
-
private crossValidationRatio: number
|
|
8
|
-
private epoch: number
|
|
5
|
+
private readonly learningRate: number
|
|
6
|
+
private readonly etaDecrease: number
|
|
7
|
+
private readonly crossValidationRatio: number
|
|
8
|
+
private readonly epoch: number
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Parameters of the linear perceptron algorithm.
|
|
@@ -3,8 +3,8 @@ import {ActivationFunction} from "./ActivationFunction";
|
|
|
3
3
|
|
|
4
4
|
export class MultiLayerPerceptronParameter extends LinearPerceptronParameter{
|
|
5
5
|
|
|
6
|
-
private hiddenNodes: number
|
|
7
|
-
private activationFunction: ActivationFunction
|
|
6
|
+
private readonly hiddenNodes: number
|
|
7
|
+
private readonly activationFunction: ActivationFunction
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Parameters of the multi layer perceptron algorithm.
|
|
@@ -3,7 +3,7 @@ import {CounterHashMap} from "nlptoolkit-datastructure/dist/CounterHashMap";
|
|
|
3
3
|
export class ConfusionMatrix {
|
|
4
4
|
|
|
5
5
|
private matrix: Map<string, CounterHashMap<string>> = new Map<string, CounterHashMap<string>>()
|
|
6
|
-
private classLabels: Array<string>
|
|
6
|
+
private readonly classLabels: Array<string>
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Constructor that sets the class labels {@link Array} and creates new {@link Map} matrix
|
|
@@ -5,6 +5,12 @@ import {Distribution} from "nlptoolkit-math/dist/Distribution";
|
|
|
5
5
|
|
|
6
6
|
export class Combined5x2F extends PairedTest{
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Calculates the test statistic of the combined 5x2 cv F 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 F test.
|
|
13
|
+
*/
|
|
8
14
|
private testStatistic(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): number{
|
|
9
15
|
let difference = new Array<number>();
|
|
10
16
|
let numerator = 0
|
|
@@ -23,6 +29,12 @@ export class Combined5x2F extends PairedTest{
|
|
|
23
29
|
return numerator / denominator;
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate) using combined 5x2 cv F 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
|
+
*/
|
|
26
38
|
compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult {
|
|
27
39
|
let statistic = this.testStatistic(classifier1, classifier2);
|
|
28
40
|
let degreeOfFreedom1 = classifier1.numberOfExperiments();
|
|
@@ -5,6 +5,12 @@ import {Distribution} from "nlptoolkit-math/dist/Distribution";
|
|
|
5
5
|
|
|
6
6
|
export class Combined5x2t extends PairedTest{
|
|
7
7
|
|
|
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
|
+
*/
|
|
8
14
|
private testStatistic(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): number{
|
|
9
15
|
let difference = new Array<number>();
|
|
10
16
|
for (let i = 0; i < classifier1.numberOfExperiments(); i++){
|
|
@@ -24,6 +30,13 @@ export class Combined5x2t extends PairedTest{
|
|
|
24
30
|
return numerator / denominator;
|
|
25
31
|
}
|
|
26
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate) using combined 5x2
|
|
35
|
+
* cv t test.
|
|
36
|
+
* @param classifier1 Performance (error rate or accuracy) results of the first classifier.
|
|
37
|
+
* @param classifier2 Performance (error rate or accuracy) results of the second classifier.
|
|
38
|
+
* @return Statistical test result of the comparison.
|
|
39
|
+
*/
|
|
27
40
|
compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult {
|
|
28
41
|
let statistic = this.testStatistic(classifier1, classifier2);
|
|
29
42
|
let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
|
|
@@ -5,6 +5,12 @@ import {Distribution} from "nlptoolkit-math/dist/Distribution";
|
|
|
5
5
|
|
|
6
6
|
export class Paired5x2t extends PairedTest{
|
|
7
7
|
|
|
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
|
+
*/
|
|
8
14
|
private testStatistic(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): number{
|
|
9
15
|
let difference = new Array<number>();
|
|
10
16
|
let sum = 0.0;
|
|
@@ -23,6 +29,12 @@ export class Paired5x2t extends PairedTest{
|
|
|
23
29
|
return difference[0] / denominator;
|
|
24
30
|
}
|
|
25
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate) using 5x2 t 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
|
+
*/
|
|
26
38
|
compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult {
|
|
27
39
|
let statistic = this.testStatistic(classifier1, classifier2);
|
|
28
40
|
let degreeOfFreedom = classifier1.numberOfExperiments() / 2;
|
|
@@ -6,6 +6,18 @@ export abstract class PairedTest {
|
|
|
6
6
|
|
|
7
7
|
abstract compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate). The method first
|
|
11
|
+
* checks the null hypothesis mu1 < mu2, if the test rejects this null hypothesis with alpha level of confidence, it
|
|
12
|
+
* decides mu1 > mu2. The algorithm then checks the null hypothesis mu1 > mu2, if the test rejects that null
|
|
13
|
+
* hypothesis with alpha level of confidence, if decides mu1 < mu2. If none of the two tests are rejected, it can not
|
|
14
|
+
* make a decision about the performances of algorithms.
|
|
15
|
+
* @param classifier1 Performance (error rate or accuracy) results of the first classifier.
|
|
16
|
+
* @param classifier2 Performance (error rate or accuracy) results of the second classifier.
|
|
17
|
+
* @param alpha Alpha level defined for the statistical test.
|
|
18
|
+
* @return 1 if the performance of the first algorithm is larger than the second algorithm, -1 if the performance of
|
|
19
|
+
* the second algorithm is larger than the first algorithm, 0 if they have similar performance.
|
|
20
|
+
*/
|
|
9
21
|
compare(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance, alpha: number): number{
|
|
10
22
|
let testResult1 = this.compareClassifiers(classifier1, classifier2);
|
|
11
23
|
let testResult2 = this.compareClassifiers(classifier2, classifier1);
|
|
@@ -5,6 +5,12 @@ import {Distribution} from "nlptoolkit-math/dist/Distribution";
|
|
|
5
5
|
|
|
6
6
|
export class Pairedt extends PairedTest{
|
|
7
7
|
|
|
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
|
+
*/
|
|
8
14
|
private testStatistic(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): number{
|
|
9
15
|
let difference = new Array<number>();
|
|
10
16
|
let sum = 0.0;
|
|
@@ -21,6 +27,12 @@ export class Pairedt extends PairedTest{
|
|
|
21
27
|
return Math.sqrt(classifier1.numberOfExperiments()) * mean / standardDeviation;
|
|
22
28
|
}
|
|
23
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate) using paired t test.
|
|
32
|
+
* @param classifier1 Performance (error rate or accuracy) results of the first classifier.
|
|
33
|
+
* @param classifier2 Performance (error rate or accuracy) results of the second classifier.
|
|
34
|
+
* @return Statistical test result of the comparison.
|
|
35
|
+
*/
|
|
24
36
|
compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult {
|
|
25
37
|
let statistic = this.testStatistic(classifier1, classifier2);
|
|
26
38
|
let degreeOfFreedom = classifier1.numberOfExperiments() - 1;
|
|
@@ -4,6 +4,11 @@ import {StatisticalTestResult} from "./StatisticalTestResult";
|
|
|
4
4
|
|
|
5
5
|
export class Sign extends PairedTest{
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Calculates n!.
|
|
9
|
+
* @param n n is n!
|
|
10
|
+
* @return n!.
|
|
11
|
+
*/
|
|
7
12
|
private factorial(n: number): number{
|
|
8
13
|
let result = 1;
|
|
9
14
|
for (let i = 2; i <= n; i++)
|
|
@@ -11,6 +16,12 @@ export class Sign extends PairedTest{
|
|
|
11
16
|
return result;
|
|
12
17
|
}
|
|
13
18
|
|
|
19
|
+
/**
|
|
20
|
+
* Calculates m of n that is C(n, m)
|
|
21
|
+
* @param m m in C(m, n)
|
|
22
|
+
* @param n n in C(m, n)
|
|
23
|
+
* @return C(m, n)
|
|
24
|
+
*/
|
|
14
25
|
private binomial(m: number, n: number): number{
|
|
15
26
|
if (n == 0 || m == n){
|
|
16
27
|
return 1;
|
|
@@ -19,6 +30,12 @@ export class Sign extends PairedTest{
|
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Compares two classification algorithms based on their performances (accuracy or error rate) using sign 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
|
+
*/
|
|
22
39
|
compareClassifiers(classifier1: ExperimentPerformance, classifier2: ExperimentPerformance): StatisticalTestResult {
|
|
23
40
|
let plus = 0, minus = 0;
|
|
24
41
|
for (let i = 0; i < classifier1.numberOfExperiments(); i++){
|
|
@@ -5,11 +5,24 @@ export class StatisticalTestResult {
|
|
|
5
5
|
private readonly pValue: number
|
|
6
6
|
private readonly onlyTwoTailed: boolean
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Constructor of the StatisticalTestResult. It sets the attribute values.
|
|
10
|
+
* @param pValue p value of the statistical test result
|
|
11
|
+
* @param onlyTwoTailed True, if this test applicable only two tailed tests, false otherwise.
|
|
12
|
+
*/
|
|
8
13
|
constructor(pValue: number, onlyTwoTailed: boolean) {
|
|
9
14
|
this.pValue = pValue
|
|
10
15
|
this.onlyTwoTailed = onlyTwoTailed
|
|
11
16
|
}
|
|
12
17
|
|
|
18
|
+
/**
|
|
19
|
+
* Returns reject or failed to reject, depending on the alpha level and p value of the statistical test that checks
|
|
20
|
+
* one tailed null hypothesis such as mu1 < mu2. If p value is less than the alpha level, the test rejects the null
|
|
21
|
+
* hypothesis. Otherwise, it fails to reject the null hypothesis.
|
|
22
|
+
* @param alpha Alpha level of the test
|
|
23
|
+
* @return If p value is less than the alpha level, the test rejects the null hypothesis. Otherwise, it fails to
|
|
24
|
+
* reject the null hypothesis.
|
|
25
|
+
*/
|
|
13
26
|
oneTailed(alpha: number): StatisticalTestResultType{
|
|
14
27
|
if (!this.onlyTwoTailed){
|
|
15
28
|
if (this.pValue < alpha){
|
|
@@ -20,6 +33,19 @@ export class StatisticalTestResult {
|
|
|
20
33
|
}
|
|
21
34
|
}
|
|
22
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Returns reject or failed to reject, depending on the alpha level and p value of the statistical test that checks
|
|
38
|
+
* one tailed null hypothesis such as mu1 < mu2 or two tailed null hypothesis such as mu1 = mu2. If the null
|
|
39
|
+
* hypothesis is two tailed, and p value is less than the alpha level, the test rejects the null hypothesis.
|
|
40
|
+
* Otherwise, it fails to reject the null hypothesis. If the null hypothesis is one tailed, and p value is less
|
|
41
|
+
* than alpha / 2 or p value is larger than 1 - alpha / 2, the test rejects the null hypothesis. Otherwise, it
|
|
42
|
+
* fails to reject the null hypothesis.
|
|
43
|
+
* @param alpha Alpha level of the test
|
|
44
|
+
* @return If the null hypothesis is two tailed, and p value is less than the alpha level, the test rejects the
|
|
45
|
+
* null hypothesis. Otherwise, it fails to reject the null hypothesis. If the null hypothesis is one tailed, and
|
|
46
|
+
* p value is less than alpha / 2 or p value is larger than 1 - alpha / 2, the test rejects the null hypothesis.
|
|
47
|
+
* Otherwise, it fails to reject the null hypothesis.
|
|
48
|
+
*/
|
|
23
49
|
twoTailed(alpha: number): StatisticalTestResultType{
|
|
24
50
|
if (this.onlyTwoTailed){
|
|
25
51
|
if (this.pValue < alpha){
|
|
@@ -36,6 +62,10 @@ export class StatisticalTestResult {
|
|
|
36
62
|
}
|
|
37
63
|
}
|
|
38
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Accessor for the p value of the statistical test result.
|
|
67
|
+
* @return p value of the statistical test result
|
|
68
|
+
*/
|
|
39
69
|
getPValue(): number{
|
|
40
70
|
return this.pValue
|
|
41
71
|
}
|
package/source/index.ts
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export * from "./Attribute/Attribute"
|
|
2
|
+
export * from "./Attribute/AttributeType"
|
|
3
|
+
export * from "./Attribute/BinaryAttribute"
|
|
4
|
+
export * from "./Attribute/ContinuousAttribute"
|
|
5
|
+
export * from "./Attribute/DiscreteAttribute"
|
|
6
|
+
export * from "./Attribute/DiscreteIndexedAttribute"
|
|
7
|
+
export * from "./DataSet/DataDefinition"
|
|
8
|
+
export * from "./DataSet/DataSet"
|
|
9
|
+
export * from "./DistanceMetric/DistanceMetric"
|
|
10
|
+
export * from "./DistanceMetric/EuclidianDistance"
|
|
11
|
+
export * from "./DistanceMetric/MahalanobisDistance"
|
|
12
|
+
export * from "./Experiment/BootstrapRun"
|
|
13
|
+
export * from "./Experiment/Experiment"
|
|
14
|
+
export * from "./Experiment/KFoldRun"
|
|
15
|
+
export * from "./Experiment/KFoldRunSeparateTest"
|
|
16
|
+
export * from "./Experiment/MultipleRun"
|
|
17
|
+
export * from "./Experiment/MxKFoldRun"
|
|
18
|
+
export * from "./Experiment/MxKFoldRunSeparateTest"
|
|
19
|
+
export * from "./Experiment/SingleRun"
|
|
20
|
+
export * from "./Experiment/SingleRunWithK"
|
|
21
|
+
export * from "./Experiment/StratifiedKFoldRun"
|
|
22
|
+
export * from "./Experiment/StratifiedKFoldRunSeparateTest"
|
|
23
|
+
export * from "./Experiment/StratifiedMxKFoldRun"
|
|
24
|
+
export * from "./Experiment/StratifiedMxKFoldRunSeparateTest"
|
|
25
|
+
export * from "./Experiment/StratifiedSingleRunWithK"
|
|
26
|
+
export * from "./FeatureSelection/BackwardSelection"
|
|
27
|
+
export * from "./FeatureSelection/FeatureSubSet"
|
|
28
|
+
export * from "./FeatureSelection/FloatingSelection"
|
|
29
|
+
export * from "./FeatureSelection/ForwardSelection"
|
|
30
|
+
export * from "./FeatureSelection/SubSetSelection"
|
|
31
|
+
export * from "./Filter/DiscreteToContinuous"
|
|
32
|
+
export * from "./Filter/DiscreteToIndexed"
|
|
33
|
+
export * from "./Filter/FeatureFilter"
|
|
34
|
+
export * from "./Filter/LaryFilter"
|
|
35
|
+
export * from "./Filter/LaryToBinary"
|
|
36
|
+
export * from "./Filter/Normalize"
|
|
37
|
+
export * from "./Filter/Pca"
|
|
38
|
+
export * from "./Filter/TrainedFeatureFilter"
|
|
39
|
+
export * from "./Instance/CompositeInstance"
|
|
40
|
+
export * from "./Instance/Instance"
|
|
41
|
+
export * from "./InstanceList/InstanceList"
|
|
42
|
+
export * from "./InstanceList/InstanceListOfSameClass"
|
|
43
|
+
export * from "./InstanceList/Partition"
|
|
44
|
+
export * from "./Model/DecisionTree/DecisionCondition"
|
|
45
|
+
export * from "./Model/DecisionTree/DecisionNode"
|
|
46
|
+
export * from "./Model/DecisionTree/DecisionTree"
|
|
47
|
+
export * from "./Model/DecisionTree/DecisionStump"
|
|
48
|
+
export * from "./Model/Ensemble/BaggingModel"
|
|
49
|
+
export * from "./Model/NeuralNetwork/DeepNetworkModel"
|
|
50
|
+
export * from "./Model/DummyModel"
|
|
51
|
+
export * from "./Model/Parametric/GaussianModel"
|
|
52
|
+
export * from "./Model/Parametric/KMeansModel"
|
|
53
|
+
export * from "./Model/Parametric/LdaModel"
|
|
54
|
+
export * from "./Model/Parametric/QdaModel"
|
|
55
|
+
export * from "./Model/Parametric/NaiveBayesModel"
|
|
56
|
+
export * from "./Model/NonParametric/KnnInstance"
|
|
57
|
+
export * from "./Model/NonParametric/KnnModel"
|
|
58
|
+
export * from "./Model/NeuralNetwork/LinearPerceptronModel"
|
|
59
|
+
export * from "./Model/Model"
|
|
60
|
+
export * from "./Model/NeuralNetwork/MultiLayerPerceptronModel"
|
|
61
|
+
export * from "./Model/NeuralNetwork/NeuralNetworkModel"
|
|
62
|
+
export * from "./Model/RandomModel"
|
|
63
|
+
export * from "./Model/Ensemble/RandomForestModel"
|
|
64
|
+
export * from "./Model/Ensemble/TreeEnsembleModel"
|
|
65
|
+
export * from "./Model/ValidatedModel"
|
|
66
|
+
export * from "./Parameter/ActivationFunction"
|
|
67
|
+
export * from "./Parameter/BaggingParameter"
|
|
68
|
+
export * from "./Parameter/C45Parameter"
|
|
69
|
+
export * from "./Parameter/DeepNetworkParameter"
|
|
70
|
+
export * from "./Parameter/KMeansParameter"
|
|
71
|
+
export * from "./Parameter/KnnParameter"
|
|
72
|
+
export * from "./Parameter/LinearPerceptronParameter"
|
|
73
|
+
export * from "./Parameter/MultiLayerPerceptronParameter"
|
|
74
|
+
export * from "./Parameter/Parameter"
|
|
75
|
+
export * from "./Parameter/RandomForestParameter"
|
|
76
|
+
export * from "./Performance/ClassificationPerformance"
|
|
77
|
+
export * from "./Performance/ConfusionMatrix"
|
|
78
|
+
export * from "./Performance/DetailedClassificationPerformance"
|
|
79
|
+
export * from "./Performance/ExperimentPerformance"
|
|
80
|
+
export * from "./Performance/Performance"
|
|
81
|
+
export * from "./StatisticalTest/Combined5x2F"
|
|
82
|
+
export * from "./StatisticalTest/Combined5x2t"
|
|
83
|
+
export * from "./StatisticalTest/Paired5x2t"
|
|
84
|
+
export * from "./StatisticalTest/Pairedt"
|
|
85
|
+
export * from "./StatisticalTest/PairedTest"
|
|
86
|
+
export * from "./StatisticalTest/Sign"
|
|
87
|
+
export * from "./StatisticalTest/StatisticalTestResult"
|
|
88
|
+
export * from "./StatisticalTest/StatisticalTestResultType"
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as assert from "assert";
|
|
2
|
-
import {C45} from "../../dist/Classifier/C45";
|
|
3
2
|
import {C45Parameter} from "../../dist/Parameter/C45Parameter";
|
|
4
3
|
import {AttributeType} from "../../dist/Attribute/AttributeType";
|
|
5
4
|
import {DataDefinition} from "../../dist/DataSet/DataDefinition";
|
|
6
5
|
import {DataSet} from "../../dist/DataSet/DataSet";
|
|
6
|
+
import {DecisionTree} from "../../dist/Model/DecisionTree/DecisionTree";
|
|
7
7
|
|
|
8
8
|
describe('C45Test', function() {
|
|
9
9
|
describe('C45Test', function() {
|
|
10
|
-
let c45 = new
|
|
10
|
+
let c45 = new DecisionTree()
|
|
11
11
|
let c45Parameter = new C45Parameter(1, true, 0.2)
|
|
12
12
|
let attributeTypes = new Array<AttributeType>();
|
|
13
13
|
for (let i = 0; i < 4; i++){
|
|
@@ -2,15 +2,13 @@ import * as assert from "assert";
|
|
|
2
2
|
import {AttributeType} from "../../dist/Attribute/AttributeType";
|
|
3
3
|
import {DataDefinition} from "../../dist/DataSet/DataDefinition";
|
|
4
4
|
import {DataSet} from "../../dist/DataSet/DataSet";
|
|
5
|
-
import {MultiLayerPerceptron} from "../../dist/Classifier/MultiLayerPerceptron";
|
|
6
|
-
import {MultiLayerPerceptronParameter} from "../../dist/Parameter/MultiLayerPerceptronParameter";
|
|
7
5
|
import {ActivationFunction} from "../../dist/Parameter/ActivationFunction";
|
|
8
|
-
import {DeepNetwork} from "../../dist/Classifier/DeepNetwork";
|
|
9
6
|
import {DeepNetworkParameter} from "../../dist/Parameter/DeepNetworkParameter";
|
|
7
|
+
import {DeepNetworkModel} from "../../dist/Model/NeuralNetwork/DeepNetworkModel";
|
|
10
8
|
|
|
11
9
|
describe('DeepNetworkTest', function() {
|
|
12
10
|
describe('DeepNetworkTest', function() {
|
|
13
|
-
let deepNetwork = new
|
|
11
|
+
let deepNetwork = new DeepNetworkModel()
|
|
14
12
|
let attributeTypes = new Array<AttributeType>();
|
|
15
13
|
for (let i = 0; i < 4; i++){
|
|
16
14
|
attributeTypes.push(AttributeType.CONTINUOUS)
|
|
@@ -38,7 +36,7 @@ describe('DeepNetworkTest', function() {
|
|
|
38
36
|
assert.ok(Math.abs(28.70 - 100 * deepNetwork.test(bupa.getInstanceList()).getErrorRate()) <= 0.01);
|
|
39
37
|
deepNetworkParameter = new DeepNetworkParameter(1, 0.01, 0.99, 0.2, 100, [20], ActivationFunction.SIGMOID)
|
|
40
38
|
deepNetwork.train(dermatology.getInstanceList(), deepNetworkParameter);
|
|
41
|
-
assert.ok(Math.abs(
|
|
39
|
+
assert.ok(Math.abs(1.37 - 100 * deepNetwork.test(dermatology.getInstanceList()).getErrorRate()) <= 0.01);
|
|
42
40
|
});
|
|
43
41
|
it('testLoad', function() {
|
|
44
42
|
deepNetwork.loadModel("models/deepNetwork-iris.txt");
|
|
@@ -2,11 +2,11 @@ import {AttributeType} from "../../dist/Attribute/AttributeType";
|
|
|
2
2
|
import {DataDefinition} from "../../dist/DataSet/DataDefinition";
|
|
3
3
|
import {DataSet} from "../../dist/DataSet/DataSet";
|
|
4
4
|
import * as assert from "assert";
|
|
5
|
-
import {
|
|
5
|
+
import {DummyModel} from "../../dist/Model/DummyModel";
|
|
6
6
|
|
|
7
7
|
describe('DummyTest', function() {
|
|
8
8
|
describe('DummyTest', function() {
|
|
9
|
-
let dummy = new
|
|
9
|
+
let dummy = new DummyModel()
|
|
10
10
|
let attributeTypes = new Array<AttributeType>();
|
|
11
11
|
for (let i = 0; i < 4; i++){
|
|
12
12
|
attributeTypes.push(AttributeType.CONTINUOUS)
|
|
@@ -2,12 +2,12 @@ import {AttributeType} from "../../dist/Attribute/AttributeType";
|
|
|
2
2
|
import {DataDefinition} from "../../dist/DataSet/DataDefinition";
|
|
3
3
|
import {DataSet} from "../../dist/DataSet/DataSet";
|
|
4
4
|
import * as assert from "assert";
|
|
5
|
-
import {KMeans} from "../../dist/Classifier/KMeans";
|
|
6
5
|
import {KMeansParameter} from "../../dist/Parameter/KMeansParameter";
|
|
6
|
+
import {KMeansModel} from "../../dist/Model/Parametric/KMeansModel";
|
|
7
7
|
|
|
8
8
|
describe('KMeansTest', function() {
|
|
9
9
|
describe('KMeansTest', function() {
|
|
10
|
-
let kMeans = new
|
|
10
|
+
let kMeans = new KMeansModel()
|
|
11
11
|
let kMeansParameter = new KMeansParameter(1)
|
|
12
12
|
let attributeTypes = new Array<AttributeType>();
|
|
13
13
|
for (let i = 0; i < 4; i++){
|