nlptoolkit-classification 1.0.0
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 +161 -0
- package/datasets/bupa.data +345 -0
- package/datasets/car.data +1728 -0
- package/datasets/chess.data +28056 -0
- package/datasets/dermatology.data +366 -0
- package/datasets/iris.data +150 -0
- package/datasets/nursery.data +12960 -0
- package/datasets/tictactoe.data +958 -0
- package/dist/Attribute/Attribute.d.ts +4 -0
- package/dist/Attribute/Attribute.js +17 -0
- package/dist/Attribute/Attribute.js.map +1 -0
- package/dist/Attribute/AttributeType.d.ts +18 -0
- package/dist/Attribute/AttributeType.js +33 -0
- package/dist/Attribute/AttributeType.js.map +1 -0
- package/dist/Attribute/BinaryAttribute.d.ts +9 -0
- package/dist/Attribute/BinaryAttribute.js +26 -0
- package/dist/Attribute/BinaryAttribute.js.map +1 -0
- package/dist/Attribute/ContinuousAttribute.d.ts +30 -0
- package/dist/Attribute/ContinuousAttribute.js +59 -0
- package/dist/Attribute/ContinuousAttribute.js.map +1 -0
- package/dist/Attribute/DiscreteAttribute.d.ts +24 -0
- package/dist/Attribute/DiscreteAttribute.js +53 -0
- package/dist/Attribute/DiscreteAttribute.js.map +1 -0
- package/dist/Attribute/DiscreteIndexedAttribute.d.ts +27 -0
- package/dist/Attribute/DiscreteIndexedAttribute.js +61 -0
- package/dist/Attribute/DiscreteIndexedAttribute.js.map +1 -0
- package/dist/Classifier/Bagging.d.ts +16 -0
- package/dist/Classifier/Bagging.js +42 -0
- package/dist/Classifier/Bagging.js.map +1 -0
- package/dist/Classifier/C45.d.ts +13 -0
- package/dist/Classifier/C45.js +40 -0
- package/dist/Classifier/C45.js.map +1 -0
- package/dist/Classifier/C45Stump.d.ts +12 -0
- package/dist/Classifier/C45Stump.js +29 -0
- package/dist/Classifier/C45Stump.js.map +1 -0
- package/dist/Classifier/Classifier.d.ts +39 -0
- package/dist/Classifier/Classifier.js +72 -0
- package/dist/Classifier/Classifier.js.map +1 -0
- package/dist/Classifier/DeepNetwork.d.ts +13 -0
- package/dist/Classifier/DeepNetwork.js +31 -0
- package/dist/Classifier/DeepNetwork.js.map +1 -0
- package/dist/Classifier/Dummy.d.ts +13 -0
- package/dist/Classifier/Dummy.js +29 -0
- package/dist/Classifier/Dummy.js.map +1 -0
- package/dist/Classifier/KMeans.d.ts +12 -0
- package/dist/Classifier/KMeans.js +36 -0
- package/dist/Classifier/KMeans.js.map +1 -0
- package/dist/Classifier/Knn.d.ts +13 -0
- package/dist/Classifier/Knn.js +29 -0
- package/dist/Classifier/Knn.js.map +1 -0
- package/dist/Classifier/Lda.d.ts +12 -0
- package/dist/Classifier/Lda.js +52 -0
- package/dist/Classifier/Lda.js.map +1 -0
- package/dist/Classifier/LinearPerceptron.d.ts +14 -0
- package/dist/Classifier/LinearPerceptron.js +32 -0
- package/dist/Classifier/LinearPerceptron.js.map +1 -0
- package/dist/Classifier/MultiLayerPerceptron.d.ts +14 -0
- package/dist/Classifier/MultiLayerPerceptron.js +32 -0
- package/dist/Classifier/MultiLayerPerceptron.js.map +1 -0
- package/dist/Classifier/NaiveBayes.d.ts +25 -0
- package/dist/Classifier/NaiveBayes.js +67 -0
- package/dist/Classifier/NaiveBayes.js.map +1 -0
- package/dist/Classifier/Qda.d.ts +12 -0
- package/dist/Classifier/Qda.js +50 -0
- package/dist/Classifier/Qda.js.map +1 -0
- package/dist/Classifier/RandomClassifier.d.ts +12 -0
- package/dist/Classifier/RandomClassifier.js +32 -0
- package/dist/Classifier/RandomClassifier.js.map +1 -0
- package/dist/Classifier/RandomForest.d.ts +13 -0
- package/dist/Classifier/RandomForest.js +39 -0
- package/dist/Classifier/RandomForest.js.map +1 -0
- package/dist/DataSet/DataDefinition.d.ts +59 -0
- package/dist/DataSet/DataDefinition.js +108 -0
- package/dist/DataSet/DataDefinition.js.map +1 -0
- package/dist/DataSet/DataSet.d.ts +111 -0
- package/dist/DataSet/DataSet.js +286 -0
- package/dist/DataSet/DataSet.js.map +1 -0
- package/dist/DistanceMetric/DistanceMetric.d.ts +4 -0
- package/dist/DistanceMetric/DistanceMetric.js +13 -0
- package/dist/DistanceMetric/DistanceMetric.js.map +1 -0
- package/dist/DistanceMetric/EuclidianDistance.d.ts +13 -0
- package/dist/DistanceMetric/EuclidianDistance.js +43 -0
- package/dist/DistanceMetric/EuclidianDistance.js.map +1 -0
- package/dist/DistanceMetric/MahalanobisDistance.d.ts +20 -0
- package/dist/DistanceMetric/MahalanobisDistance.js +39 -0
- package/dist/DistanceMetric/MahalanobisDistance.js.map +1 -0
- package/dist/Experiment/BootstrapRun.d.ts +19 -0
- package/dist/Experiment/BootstrapRun.js +44 -0
- package/dist/Experiment/BootstrapRun.js.map +1 -0
- package/dist/Experiment/Experiment.d.ts +37 -0
- package/dist/Experiment/Experiment.js +57 -0
- package/dist/Experiment/Experiment.js.map +1 -0
- package/dist/Experiment/KFoldRun.d.ts +19 -0
- package/dist/Experiment/KFoldRun.js +43 -0
- package/dist/Experiment/KFoldRun.js.map +1 -0
- package/dist/Experiment/KFoldRunSeparateTest.d.ts +24 -0
- package/dist/Experiment/KFoldRunSeparateTest.js +51 -0
- package/dist/Experiment/KFoldRunSeparateTest.js.map +1 -0
- package/dist/Experiment/MultipleRun.d.ts +5 -0
- package/dist/Experiment/MultipleRun.js +13 -0
- package/dist/Experiment/MultipleRun.js.map +1 -0
- package/dist/Experiment/MxKFoldRun.d.ts +20 -0
- package/dist/Experiment/MxKFoldRun.js +44 -0
- package/dist/Experiment/MxKFoldRun.js.map +1 -0
- package/dist/Experiment/MxKFoldRunSeparateTest.d.ts +21 -0
- package/dist/Experiment/MxKFoldRunSeparateTest.js +48 -0
- package/dist/Experiment/MxKFoldRunSeparateTest.js.map +1 -0
- package/dist/Experiment/SingleRun.d.ts +5 -0
- package/dist/Experiment/SingleRun.js +13 -0
- package/dist/Experiment/SingleRun.js.map +1 -0
- package/dist/Experiment/SingleRunWithK.d.ts +19 -0
- package/dist/Experiment/SingleRunWithK.js +37 -0
- package/dist/Experiment/SingleRunWithK.js.map +1 -0
- package/dist/Experiment/StratifiedKFoldRun.d.ts +17 -0
- package/dist/Experiment/StratifiedKFoldRun.js +39 -0
- package/dist/Experiment/StratifiedKFoldRun.js.map +1 -0
- package/dist/Experiment/StratifiedKFoldRunSeparateTest.d.ts +18 -0
- package/dist/Experiment/StratifiedKFoldRunSeparateTest.js +43 -0
- package/dist/Experiment/StratifiedKFoldRunSeparateTest.js.map +1 -0
- package/dist/Experiment/StratifiedMxKFoldRun.d.ts +19 -0
- package/dist/Experiment/StratifiedMxKFoldRun.js +43 -0
- package/dist/Experiment/StratifiedMxKFoldRun.js.map +1 -0
- package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.d.ts +20 -0
- package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js +47 -0
- package/dist/Experiment/StratifiedMxKFoldRunSeparateTest.js.map +1 -0
- package/dist/Experiment/StratifiedSingleRunWithK.d.ts +18 -0
- package/dist/Experiment/StratifiedSingleRunWithK.js +39 -0
- package/dist/Experiment/StratifiedSingleRunWithK.js.map +1 -0
- package/dist/FeatureSelection/BackwardSelection.d.ts +18 -0
- package/dist/FeatureSelection/BackwardSelection.js +39 -0
- package/dist/FeatureSelection/BackwardSelection.js.map +1 -0
- package/dist/FeatureSelection/FeatureSubSet.d.ts +47 -0
- package/dist/FeatureSelection/FeatureSubSet.js +89 -0
- package/dist/FeatureSelection/FeatureSubSet.js.map +1 -0
- package/dist/FeatureSelection/FloatingSelection.d.ts +16 -0
- package/dist/FeatureSelection/FloatingSelection.js +38 -0
- package/dist/FeatureSelection/FloatingSelection.js.map +1 -0
- package/dist/FeatureSelection/ForwardSelection.d.ts +17 -0
- package/dist/FeatureSelection/ForwardSelection.js +38 -0
- package/dist/FeatureSelection/ForwardSelection.js.map +1 -0
- package/dist/FeatureSelection/SubSetSelection.d.ts +37 -0
- package/dist/FeatureSelection/SubSetSelection.js +90 -0
- package/dist/FeatureSelection/SubSetSelection.js.map +1 -0
- package/dist/Filter/DiscreteToContinuous.d.ts +25 -0
- package/dist/Filter/DiscreteToContinuous.js +69 -0
- package/dist/Filter/DiscreteToContinuous.js.map +1 -0
- package/dist/Filter/DiscreteToIndexed.d.ts +21 -0
- package/dist/Filter/DiscreteToIndexed.js +56 -0
- package/dist/Filter/DiscreteToIndexed.js.map +1 -0
- package/dist/Filter/FeatureFilter.d.ts +18 -0
- package/dist/Filter/FeatureFilter.js +36 -0
- package/dist/Filter/FeatureFilter.js.map +1 -0
- package/dist/Filter/LaryFilter.d.ts +27 -0
- package/dist/Filter/LaryFilter.js +62 -0
- package/dist/Filter/LaryFilter.js.map +1 -0
- package/dist/Filter/LaryToBinary.d.ts +23 -0
- package/dist/Filter/LaryToBinary.js +67 -0
- package/dist/Filter/LaryToBinary.js.map +1 -0
- package/dist/Filter/Normalize.d.ts +21 -0
- package/dist/Filter/Normalize.js +47 -0
- package/dist/Filter/Normalize.js.map +1 -0
- package/dist/Filter/Pca.d.ts +44 -0
- package/dist/Filter/Pca.js +109 -0
- package/dist/Filter/Pca.js.map +1 -0
- package/dist/Filter/TrainedFeatureFilter.d.ts +11 -0
- package/dist/Filter/TrainedFeatureFilter.js +26 -0
- package/dist/Filter/TrainedFeatureFilter.js.map +1 -0
- package/dist/Instance/CompositeInstance.d.ts +32 -0
- package/dist/Instance/CompositeInstance.js +61 -0
- package/dist/Instance/CompositeInstance.js.map +1 -0
- package/dist/Instance/Instance.d.ts +89 -0
- package/dist/Instance/Instance.js +170 -0
- package/dist/Instance/Instance.js.map +1 -0
- package/dist/InstanceList/InstanceList.d.ts +188 -0
- package/dist/InstanceList/InstanceList.js +517 -0
- package/dist/InstanceList/InstanceList.js.map +1 -0
- package/dist/InstanceList/InstanceListOfSameClass.d.ts +16 -0
- package/dist/InstanceList/InstanceListOfSameClass.js +35 -0
- package/dist/InstanceList/InstanceListOfSameClass.js.map +1 -0
- package/dist/InstanceList/Partition.d.ts +31 -0
- package/dist/InstanceList/Partition.js +143 -0
- package/dist/InstanceList/Partition.js.map +1 -0
- package/dist/Model/DecisionTree/DecisionCondition.d.ts +34 -0
- package/dist/Model/DecisionTree/DecisionCondition.js +84 -0
- package/dist/Model/DecisionTree/DecisionCondition.js.map +1 -0
- package/dist/Model/DecisionTree/DecisionNode.d.ts +82 -0
- package/dist/Model/DecisionTree/DecisionNode.js +271 -0
- package/dist/Model/DecisionTree/DecisionNode.js.map +1 -0
- package/dist/Model/DecisionTree/DecisionTree.d.ts +37 -0
- package/dist/Model/DecisionTree/DecisionTree.js +75 -0
- package/dist/Model/DecisionTree/DecisionTree.js.map +1 -0
- package/dist/Model/DeepNetworkModel.d.ts +42 -0
- package/dist/Model/DeepNetworkModel.js +163 -0
- package/dist/Model/DeepNetworkModel.js.map +1 -0
- package/dist/Model/DummyModel.d.ts +20 -0
- package/dist/Model/DummyModel.js +46 -0
- package/dist/Model/DummyModel.js.map +1 -0
- package/dist/Model/GaussianModel.d.ts +24 -0
- package/dist/Model/GaussianModel.js +59 -0
- package/dist/Model/GaussianModel.js.map +1 -0
- package/dist/Model/KMeansModel.d.ts +27 -0
- package/dist/Model/KMeansModel.js +48 -0
- package/dist/Model/KMeansModel.js.map +1 -0
- package/dist/Model/KnnInstance.d.ts +14 -0
- package/dist/Model/KnnInstance.js +33 -0
- package/dist/Model/KnnInstance.js.map +1 -0
- package/dist/Model/KnnModel.d.ts +36 -0
- package/dist/Model/KnnModel.js +83 -0
- package/dist/Model/KnnModel.js.map +1 -0
- package/dist/Model/LdaModel.d.ts +25 -0
- package/dist/Model/LdaModel.js +45 -0
- package/dist/Model/LdaModel.js.map +1 -0
- package/dist/Model/LinearPerceptronModel.d.ts +21 -0
- package/dist/Model/LinearPerceptronModel.js +62 -0
- package/dist/Model/LinearPerceptronModel.js.map +1 -0
- package/dist/Model/Model.d.ts +12 -0
- package/dist/Model/Model.js +31 -0
- package/dist/Model/Model.js.map +1 -0
- package/dist/Model/MultiLayerPerceptronModel.d.ts +29 -0
- package/dist/Model/MultiLayerPerceptronModel.js +101 -0
- package/dist/Model/MultiLayerPerceptronModel.js.map +1 -0
- package/dist/Model/NaiveBayesModel.d.ts +47 -0
- package/dist/Model/NaiveBayesModel.js +95 -0
- package/dist/Model/NaiveBayesModel.js.map +1 -0
- package/dist/Model/NeuralNetworkModel.d.ts +99 -0
- package/dist/Model/NeuralNetworkModel.js +180 -0
- package/dist/Model/NeuralNetworkModel.js.map +1 -0
- package/dist/Model/QdaModel.d.ts +26 -0
- package/dist/Model/QdaModel.js +45 -0
- package/dist/Model/QdaModel.js.map +1 -0
- package/dist/Model/RandomModel.d.ts +16 -0
- package/dist/Model/RandomModel.js +51 -0
- package/dist/Model/RandomModel.js.map +1 -0
- package/dist/Model/TreeEnsembleModel.d.ts +21 -0
- package/dist/Model/TreeEnsembleModel.js +49 -0
- package/dist/Model/TreeEnsembleModel.js.map +1 -0
- package/dist/Model/ValidatedModel.d.ts +12 -0
- package/dist/Model/ValidatedModel.js +35 -0
- package/dist/Model/ValidatedModel.js.map +1 -0
- package/dist/Parameter/ActivationFunction.d.ts +5 -0
- package/dist/Parameter/ActivationFunction.js +20 -0
- package/dist/Parameter/ActivationFunction.js.map +1 -0
- package/dist/Parameter/BaggingParameter.d.ts +17 -0
- package/dist/Parameter/BaggingParameter.js +36 -0
- package/dist/Parameter/BaggingParameter.js.map +1 -0
- package/dist/Parameter/C45Parameter.d.ts +25 -0
- package/dist/Parameter/C45Parameter.js +46 -0
- package/dist/Parameter/C45Parameter.js.map +1 -0
- package/dist/Parameter/DeepNetworkParameter.d.ts +38 -0
- package/dist/Parameter/DeepNetworkParameter.js +60 -0
- package/dist/Parameter/DeepNetworkParameter.js.map +1 -0
- package/dist/Parameter/KMeansParameter.d.ts +18 -0
- package/dist/Parameter/KMeansParameter.js +42 -0
- package/dist/Parameter/KMeansParameter.js.map +1 -0
- package/dist/Parameter/KnnParameter.d.ts +19 -0
- package/dist/Parameter/KnnParameter.js +37 -0
- package/dist/Parameter/KnnParameter.js.map +1 -0
- package/dist/Parameter/LinearPerceptronParameter.d.ts +41 -0
- package/dist/Parameter/LinearPerceptronParameter.js +66 -0
- package/dist/Parameter/LinearPerceptronParameter.js.map +1 -0
- package/dist/Parameter/MultiLayerPerceptronParameter.d.ts +30 -0
- package/dist/Parameter/MultiLayerPerceptronParameter.js +50 -0
- package/dist/Parameter/MultiLayerPerceptronParameter.js.map +1 -0
- package/dist/Parameter/Parameter.d.ts +15 -0
- package/dist/Parameter/Parameter.js +33 -0
- package/dist/Parameter/Parameter.js.map +1 -0
- package/dist/Parameter/RandomForestParameter.d.ts +18 -0
- package/dist/Parameter/RandomForestParameter.js +37 -0
- package/dist/Parameter/RandomForestParameter.js.map +1 -0
- package/dist/Performance/ClassificationPerformance.d.ts +17 -0
- package/dist/Performance/ClassificationPerformance.js +36 -0
- package/dist/Performance/ClassificationPerformance.js.map +1 -0
- package/dist/Performance/ConfusionMatrix.d.ts +81 -0
- package/dist/Performance/ConfusionMatrix.js +178 -0
- package/dist/Performance/ConfusionMatrix.js.map +1 -0
- package/dist/Performance/DetailedClassificationPerformance.d.ts +17 -0
- package/dist/Performance/DetailedClassificationPerformance.js +35 -0
- package/dist/Performance/DetailedClassificationPerformance.js.map +1 -0
- package/dist/Performance/ExperimentPerformance.d.ts +88 -0
- package/dist/Performance/ExperimentPerformance.js +176 -0
- package/dist/Performance/ExperimentPerformance.js.map +1 -0
- package/dist/Performance/Performance.d.ts +15 -0
- package/dist/Performance/Performance.js +33 -0
- package/dist/Performance/Performance.js.map +1 -0
- package/dist/StatisticalTest/Combined5x2F.d.ts +7 -0
- package/dist/StatisticalTest/Combined5x2F.js +43 -0
- package/dist/StatisticalTest/Combined5x2F.js.map +1 -0
- package/dist/StatisticalTest/Combined5x2t.d.ts +7 -0
- package/dist/StatisticalTest/Combined5x2t.js +43 -0
- package/dist/StatisticalTest/Combined5x2t.js.map +1 -0
- package/dist/StatisticalTest/Paired5x2t.d.ts +7 -0
- package/dist/StatisticalTest/Paired5x2t.js +42 -0
- package/dist/StatisticalTest/Paired5x2t.js.map +1 -0
- package/dist/StatisticalTest/PairedTest.d.ts +6 -0
- package/dist/StatisticalTest/PairedTest.js +35 -0
- package/dist/StatisticalTest/PairedTest.js.map +1 -0
- package/dist/StatisticalTest/Pairedt.d.ts +7 -0
- package/dist/StatisticalTest/Pairedt.js +40 -0
- package/dist/StatisticalTest/Pairedt.js.map +1 -0
- package/dist/StatisticalTest/Sign.d.ts +8 -0
- package/dist/StatisticalTest/Sign.js +52 -0
- package/dist/StatisticalTest/Sign.js.map +1 -0
- package/dist/StatisticalTest/StatisticalTestResult.d.ts +9 -0
- package/dist/StatisticalTest/StatisticalTestResult.js +53 -0
- package/dist/StatisticalTest/StatisticalTestResult.js.map +1 -0
- package/dist/StatisticalTest/StatisticalTestResultType.d.ts +7 -0
- package/dist/StatisticalTest/StatisticalTestResultType.js +22 -0
- package/dist/StatisticalTest/StatisticalTestResultType.js.map +1 -0
- package/index.js +100 -0
- package/package.json +30 -0
- package/source/Attribute/Attribute.ts +6 -0
- package/source/Attribute/AttributeType.ts +18 -0
- package/source/Attribute/BinaryAttribute.ts +14 -0
- package/source/Attribute/ContinuousAttribute.ts +53 -0
- package/source/Attribute/DiscreteAttribute.ts +46 -0
- package/source/Attribute/DiscreteIndexedAttribute.ts +54 -0
- package/source/Classifier/Bagging.ts +32 -0
- package/source/Classifier/C45.ts +30 -0
- package/source/Classifier/C45Stump.ts +19 -0
- package/source/Classifier/Classifier.ts +71 -0
- package/source/Classifier/DeepNetwork.ts +22 -0
- package/source/Classifier/Dummy.ts +19 -0
- package/source/Classifier/KMeans.ts +26 -0
- package/source/Classifier/Knn.ts +21 -0
- package/source/Classifier/Lda.ts +43 -0
- package/source/Classifier/LinearPerceptron.ts +23 -0
- package/source/Classifier/MultiLayerPerceptron.ts +23 -0
- package/source/Classifier/NaiveBayes.ts +62 -0
- package/source/Classifier/Qda.ts +42 -0
- package/source/Classifier/RandomClassifier.ts +22 -0
- package/source/Classifier/RandomForest.ts +29 -0
- package/source/DataSet/DataDefinition.ts +106 -0
- package/source/DataSet/DataSet.ts +279 -0
- package/source/DistanceMetric/DistanceMetric.ts +6 -0
- package/source/DistanceMetric/EuclidianDistance.ts +32 -0
- package/source/DistanceMetric/MahalanobisDistance.ts +33 -0
- package/source/Experiment/BootstrapRun.ts +37 -0
- package/source/Experiment/Experiment.ts +57 -0
- package/source/Experiment/KFoldRun.ts +44 -0
- package/source/Experiment/KFoldRunSeparateTest.ts +50 -0
- package/source/Experiment/MultipleRun.ts +7 -0
- package/source/Experiment/MxKFoldRun.ts +37 -0
- package/source/Experiment/MxKFoldRunSeparateTest.ts +40 -0
- package/source/Experiment/SingleRun.ts +7 -0
- package/source/Experiment/SingleRunWithK.ts +39 -0
- package/source/Experiment/StratifiedKFoldRun.ts +30 -0
- package/source/Experiment/StratifiedKFoldRunSeparateTest.ts +33 -0
- package/source/Experiment/StratifiedMxKFoldRun.ts +34 -0
- package/source/Experiment/StratifiedMxKFoldRunSeparateTest.ts +40 -0
- package/source/Experiment/StratifiedSingleRunWithK.ts +33 -0
- package/source/FeatureSelection/BackwardSelection.ts +28 -0
- package/source/FeatureSelection/FeatureSubSet.ts +82 -0
- package/source/FeatureSelection/FloatingSelection.ts +27 -0
- package/source/FeatureSelection/ForwardSelection.ts +27 -0
- package/source/FeatureSelection/SubSetSelection.ts +88 -0
- package/source/Filter/DiscreteToContinuous.ts +59 -0
- package/source/Filter/DiscreteToIndexed.ts +48 -0
- package/source/Filter/FeatureFilter.ts +31 -0
- package/source/Filter/LaryFilter.ts +54 -0
- package/source/Filter/LaryToBinary.ts +57 -0
- package/source/Filter/Normalize.ts +42 -0
- package/source/Filter/Pca.ts +104 -0
- package/source/Filter/TrainedFeatureFilter.ts +17 -0
- package/source/Instance/CompositeInstance.ts +53 -0
- package/source/Instance/Instance.ts +170 -0
- package/source/InstanceList/InstanceList.ts +519 -0
- package/source/InstanceList/InstanceListOfSameClass.ts +25 -0
- package/source/InstanceList/Partition.ts +131 -0
- package/source/Model/DecisionTree/DecisionCondition.ts +74 -0
- package/source/Model/DecisionTree/DecisionNode.ts +257 -0
- package/source/Model/DecisionTree/DecisionTree.ts +71 -0
- package/source/Model/DeepNetworkModel.ts +156 -0
- package/source/Model/DummyModel.ts +40 -0
- package/source/Model/GaussianModel.ts +58 -0
- package/source/Model/KMeansModel.ts +44 -0
- package/source/Model/KnnInstance.ts +27 -0
- package/source/Model/KnnModel.ts +78 -0
- package/source/Model/LdaModel.ts +39 -0
- package/source/Model/LinearPerceptronModel.ts +55 -0
- package/source/Model/Model.ts +22 -0
- package/source/Model/MultiLayerPerceptronModel.ts +95 -0
- package/source/Model/NaiveBayesModel.ts +89 -0
- package/source/Model/NeuralNetworkModel.ts +187 -0
- package/source/Model/QdaModel.ts +39 -0
- package/source/Model/RandomModel.ts +44 -0
- package/source/Model/TreeEnsembleModel.ts +43 -0
- package/source/Model/ValidatedModel.ts +23 -0
- package/source/Parameter/ActivationFunction.ts +3 -0
- package/source/Parameter/BaggingParameter.ts +26 -0
- package/source/Parameter/C45Parameter.ts +38 -0
- package/source/Parameter/DeepNetworkParameter.ts +59 -0
- package/source/Parameter/KMeansParameter.ts +33 -0
- package/source/Parameter/KnnParameter.ts +28 -0
- package/source/Parameter/LinearPerceptronParameter.ts +66 -0
- package/source/Parameter/MultiLayerPerceptronParameter.ts +49 -0
- package/source/Parameter/Parameter.ts +22 -0
- package/source/Parameter/RandomForestParameter.ts +27 -0
- package/source/Performance/ClassificationPerformance.ts +26 -0
- package/source/Performance/ConfusionMatrix.ts +175 -0
- package/source/Performance/DetailedClassificationPerformance.ts +26 -0
- package/source/Performance/ExperimentPerformance.ts +175 -0
- package/source/Performance/Performance.ts +22 -0
- package/source/StatisticalTest/Combined5x2F.ts +33 -0
- package/source/StatisticalTest/Combined5x2t.ts +33 -0
- package/source/StatisticalTest/Paired5x2t.ts +32 -0
- package/source/StatisticalTest/PairedTest.ts +24 -0
- package/source/StatisticalTest/Pairedt.ts +30 -0
- package/source/StatisticalTest/Sign.ts +41 -0
- package/source/StatisticalTest/StatisticalTestResult.ts +42 -0
- package/source/StatisticalTest/StatisticalTestResultType.ts +6 -0
- package/source/tsconfig.json +13 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {KFoldRun} from "./KFoldRun";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
4
|
+
import {KFoldCrossValidation} from "nlptoolkit-sampling/dist/KFoldCrossValidation";
|
|
5
|
+
import {Instance} from "../Instance/Instance";
|
|
6
|
+
|
|
7
|
+
export class MxKFoldRun extends KFoldRun{
|
|
8
|
+
|
|
9
|
+
protected M: number
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Constructor for MxKFoldRun class. Basically sets K parameter of the K-fold cross-validation and M for the number of times.
|
|
13
|
+
*
|
|
14
|
+
* @param M number of cross-validation times.
|
|
15
|
+
* @param K K of the K-fold cross-validation.
|
|
16
|
+
*/
|
|
17
|
+
constructor(M: number, K: number) {
|
|
18
|
+
super(K);
|
|
19
|
+
this.M = M
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Execute the MxKFold run with the given classifier on the given data set using the given parameters.
|
|
24
|
+
*
|
|
25
|
+
* @param experiment Experiment to be run.
|
|
26
|
+
* @return An ExperimentPerformance instance.
|
|
27
|
+
*/
|
|
28
|
+
execute(experiment: Experiment): ExperimentPerformance {
|
|
29
|
+
let result = new ExperimentPerformance();
|
|
30
|
+
for (let j = 0; j < this.M; j++) {
|
|
31
|
+
let crossValidation = new KFoldCrossValidation<Instance>(experiment.getDataSet().getInstances(), this.K, experiment.getParameter().getSeed());
|
|
32
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation);
|
|
33
|
+
}
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {KFoldRunSeparateTest} from "./KFoldRunSeparateTest";
|
|
2
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
3
|
+
import {Experiment} from "./Experiment";
|
|
4
|
+
import {Partition} from "../InstanceList/Partition";
|
|
5
|
+
import {KFoldCrossValidation} from "nlptoolkit-sampling/dist/KFoldCrossValidation";
|
|
6
|
+
import {Instance} from "../Instance/Instance";
|
|
7
|
+
|
|
8
|
+
export class MxKFoldRunSeparateTest extends KFoldRunSeparateTest{
|
|
9
|
+
|
|
10
|
+
protected M: number
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructor for KFoldRunSeparateTest class. Basically sets K parameter of the K-fold cross-validation and M for
|
|
14
|
+
* the number of times.
|
|
15
|
+
*
|
|
16
|
+
* @param M number of cross-validation times.
|
|
17
|
+
* @param K K of the K-fold cross-validation.
|
|
18
|
+
*/
|
|
19
|
+
constructor(M: number, K: number) {
|
|
20
|
+
super(K);
|
|
21
|
+
this.M = M
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Execute the MxKFold run with separate test set with the given classifier on the given data set using the given parameters.
|
|
26
|
+
*
|
|
27
|
+
* @param experiment Experiment to be run.
|
|
28
|
+
* @return An ExperimentPerformance instance.
|
|
29
|
+
*/
|
|
30
|
+
execute(experiment: Experiment): ExperimentPerformance {
|
|
31
|
+
let result = new ExperimentPerformance();
|
|
32
|
+
let instanceList = experiment.getDataSet().getInstanceList();
|
|
33
|
+
let partition = new Partition(instanceList, 0.25, true);
|
|
34
|
+
for (let j = 0; j < this.M; j++) {
|
|
35
|
+
let crossValidation = new KFoldCrossValidation<Instance>(partition.get(1).getInstances(), this.K, experiment.getParameter().getSeed());
|
|
36
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation, partition.get(0));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {SingleRun} from "./SingleRun";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {KFoldCrossValidation} from "nlptoolkit-sampling/dist/KFoldCrossValidation";
|
|
4
|
+
import {Instance} from "../Instance/Instance";
|
|
5
|
+
import {Performance} from "../Performance/Performance";
|
|
6
|
+
import {InstanceList} from "../InstanceList/InstanceList";
|
|
7
|
+
import {Classifier} from "../Classifier/Classifier";
|
|
8
|
+
import {Parameter} from "../Parameter/Parameter";
|
|
9
|
+
import {CrossValidation} from "nlptoolkit-sampling/dist/CrossValidation";
|
|
10
|
+
|
|
11
|
+
export class SingleRunWithK implements SingleRun{
|
|
12
|
+
|
|
13
|
+
private K: number
|
|
14
|
+
|
|
15
|
+
constructor(K: number) {
|
|
16
|
+
this.K = K
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
runExperiment(classifier: Classifier,
|
|
20
|
+
parameter: Parameter,
|
|
21
|
+
crossValidation: CrossValidation<Instance>){
|
|
22
|
+
let trainSet = new InstanceList(crossValidation.getTrainFold(0));
|
|
23
|
+
let testSet = new InstanceList(crossValidation.getTestFold(0));
|
|
24
|
+
return classifier.singleRun(parameter, trainSet, testSet);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Execute Single K-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
29
|
+
*
|
|
30
|
+
* @param experiment Experiment to be run.
|
|
31
|
+
* @return A Performance instance
|
|
32
|
+
*/
|
|
33
|
+
execute(experiment: Experiment): Performance {
|
|
34
|
+
let crossValidation = new KFoldCrossValidation<Instance>(experiment.getDataSet().getInstances(), this.K,
|
|
35
|
+
experiment.getParameter().getSeed());
|
|
36
|
+
return this.runExperiment(experiment.getClassifier(), experiment.getParameter(), crossValidation);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {KFoldRun} from "./KFoldRun";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
4
|
+
import {StratifiedKFoldCrossValidation} from "nlptoolkit-sampling/dist/StratifiedKFoldCrossValidation";
|
|
5
|
+
import {Instance} from "../Instance/Instance";
|
|
6
|
+
|
|
7
|
+
export class StratifiedKFoldRun extends KFoldRun{
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Constructor for KFoldRun class. Basically sets K parameter of the K-fold cross-validation.
|
|
11
|
+
* @param K K of the K-fold cross-validation.
|
|
12
|
+
*/
|
|
13
|
+
constructor(K: number) {
|
|
14
|
+
super(K);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Execute Stratified K-fold cross-validation 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: Experiment): ExperimentPerformance {
|
|
24
|
+
let result = new ExperimentPerformance();
|
|
25
|
+
let crossValidation = new StratifiedKFoldCrossValidation<Instance>(experiment.getDataSet().getClassInstances(), this.K, experiment.getParameter().getSeed());
|
|
26
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation);
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {KFoldRunSeparateTest} from "./KFoldRunSeparateTest";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
4
|
+
import {Partition} from "../InstanceList/Partition";
|
|
5
|
+
import {StratifiedKFoldCrossValidation} from "nlptoolkit-sampling/dist/StratifiedKFoldCrossValidation";
|
|
6
|
+
import {Instance} from "../Instance/Instance";
|
|
7
|
+
|
|
8
|
+
export class StratifiedKFoldRunSeparateTest extends KFoldRunSeparateTest{
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Constructor for StratifiedKFoldRunSeparateTest 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: number) {
|
|
16
|
+
super(K);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Execute Stratified K-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
21
|
+
*
|
|
22
|
+
* @param experiment Experiment to be run.
|
|
23
|
+
* @return An ExperimentPerformance instance.
|
|
24
|
+
*/
|
|
25
|
+
execute(experiment: Experiment): ExperimentPerformance {
|
|
26
|
+
let result = new ExperimentPerformance();
|
|
27
|
+
let instanceList = experiment.getDataSet().getInstanceList();
|
|
28
|
+
let partition = new Partition(instanceList, 0.25, true);
|
|
29
|
+
let crossValidation = new StratifiedKFoldCrossValidation<Instance>(new Partition(partition.get(1)).getLists(), this.K, experiment.getParameter().getSeed());
|
|
30
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation, partition.get(0));
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {MxKFoldRun} from "./MxKFoldRun";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
4
|
+
import {StratifiedKFoldCrossValidation} from "nlptoolkit-sampling/dist/StratifiedKFoldCrossValidation";
|
|
5
|
+
import {Instance} from "../Instance/Instance";
|
|
6
|
+
|
|
7
|
+
export class StratifiedMxKFoldRun extends MxKFoldRun{
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Constructor for StratifiedMxKFoldRun class. Basically sets K parameter of the K-fold cross-validation and M for the number of times.
|
|
11
|
+
*
|
|
12
|
+
* @param M number of cross-validation times.
|
|
13
|
+
* @param K K of the K-fold cross-validation.
|
|
14
|
+
*/
|
|
15
|
+
constructor(M: number, K: number) {
|
|
16
|
+
super(M, K);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Execute the Stratified MxK-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
21
|
+
*
|
|
22
|
+
* @param experiment Experiment to be run.
|
|
23
|
+
* @return An ExperimentPerformance instance.
|
|
24
|
+
*/
|
|
25
|
+
execute(experiment: Experiment): ExperimentPerformance {
|
|
26
|
+
let result = new ExperimentPerformance();
|
|
27
|
+
for (let j = 0; j < this.M; j++) {
|
|
28
|
+
let crossValidation = new StratifiedKFoldCrossValidation<Instance>(experiment.getDataSet().getClassInstances(),
|
|
29
|
+
this.K, experiment.getParameter().getSeed());
|
|
30
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation);
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {StratifiedKFoldRunSeparateTest} from "./StratifiedKFoldRunSeparateTest";
|
|
2
|
+
import {Experiment} from "./Experiment";
|
|
3
|
+
import {ExperimentPerformance} from "../Performance/ExperimentPerformance";
|
|
4
|
+
import {Partition} from "../InstanceList/Partition";
|
|
5
|
+
import {Instance} from "../Instance/Instance";
|
|
6
|
+
import {StratifiedKFoldCrossValidation} from "nlptoolkit-sampling/dist/StratifiedKFoldCrossValidation";
|
|
7
|
+
|
|
8
|
+
export class StratifiedMxKFoldRunSeparateTest extends StratifiedKFoldRunSeparateTest{
|
|
9
|
+
|
|
10
|
+
protected M: number
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Constructor for StratifiedMxKFoldRunSeparateTest class. Basically sets K parameter of the K-fold cross-validation and M for the number of times.
|
|
14
|
+
*
|
|
15
|
+
* @param M number of cross-validation times.
|
|
16
|
+
* @param K K of the K-fold cross-validation.
|
|
17
|
+
*/
|
|
18
|
+
constructor(M: number, K: number) {
|
|
19
|
+
super(K);
|
|
20
|
+
this.M = M
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Execute the Stratified MxK-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
25
|
+
*
|
|
26
|
+
* @param experiment Experiment to be run.
|
|
27
|
+
* @return An ExperimentPerformance instance.
|
|
28
|
+
*/
|
|
29
|
+
execute(experiment: Experiment): ExperimentPerformance {
|
|
30
|
+
let result = new ExperimentPerformance();
|
|
31
|
+
for (let j = 0; j < this.M; j++) {
|
|
32
|
+
let instanceList = experiment.getDataSet().getInstanceList();
|
|
33
|
+
let partition = new Partition(instanceList, 0.25, true);
|
|
34
|
+
let crossValidation = new StratifiedKFoldCrossValidation<Instance>(new Partition(partition.get(1)).getLists(),
|
|
35
|
+
this.K, experiment.getParameter().getSeed());
|
|
36
|
+
this.runExperiment(experiment.getClassifier(), experiment.getParameter(), result, crossValidation, partition.get(0));
|
|
37
|
+
}
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {Experiment} from "./Experiment";
|
|
2
|
+
import {Performance} from "../Performance/Performance";
|
|
3
|
+
import {StratifiedKFoldCrossValidation} from "nlptoolkit-sampling/dist/StratifiedKFoldCrossValidation";
|
|
4
|
+
import {Instance} from "../Instance/Instance";
|
|
5
|
+
import {InstanceList} from "../InstanceList/InstanceList";
|
|
6
|
+
|
|
7
|
+
export class StratifiedSingleRunWithK {
|
|
8
|
+
|
|
9
|
+
private readonly K: number
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Constructor for StratifiedSingleRunWithK class. Basically sets K parameter of the K-fold cross-validation.
|
|
13
|
+
*
|
|
14
|
+
* @param K K of the K-fold cross-validation.
|
|
15
|
+
*/
|
|
16
|
+
constructor(K: number) {
|
|
17
|
+
this.K = K
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Execute Stratified Single K-fold cross-validation with the given classifier on the given data set using the given parameters.
|
|
22
|
+
*
|
|
23
|
+
* @param experiment Experiment to be run.
|
|
24
|
+
* @return A Performance instance.
|
|
25
|
+
*/
|
|
26
|
+
execute(experiment: Experiment): Performance{
|
|
27
|
+
let crossValidation = new StratifiedKFoldCrossValidation<Instance>(experiment.getDataSet().getClassInstances(),
|
|
28
|
+
this.K, experiment.getParameter().getSeed());
|
|
29
|
+
let trainSet = new InstanceList(crossValidation.getTrainFold(0));
|
|
30
|
+
let testSet = new InstanceList(crossValidation.getTestFold(0));
|
|
31
|
+
return experiment.getClassifier().singleRun(experiment.getParameter(), trainSet, testSet);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {SubSetSelection} from "./SubSetSelection";
|
|
2
|
+
import {FeatureSubSet} from "./FeatureSubSet";
|
|
3
|
+
|
|
4
|
+
export class BackwardSelection extends SubSetSelection{
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constructor that creates a new {@link FeatureSubSet} and initializes indexList with given number of features.
|
|
8
|
+
*
|
|
9
|
+
* @param numberOfFeatures Indicates the indices of indexList.
|
|
10
|
+
*/
|
|
11
|
+
constructor(numberOfFeatures: number) {
|
|
12
|
+
super(new FeatureSubSet(numberOfFeatures));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The operator method calls backward method which starts with all the features and removes the least significant feature at each iteration.
|
|
17
|
+
*
|
|
18
|
+
* @param current FeatureSubset that will be added to new ArrayList.
|
|
19
|
+
* @param numberOfFeatures Indicates the indices of indexList.
|
|
20
|
+
* @return ArrayList of FeatureSubSets created from backward.
|
|
21
|
+
*/
|
|
22
|
+
protected operator(current: FeatureSubSet, numberOfFeatures: number): Array<FeatureSubSet> {
|
|
23
|
+
let result = new Array<FeatureSubSet>();
|
|
24
|
+
this.backward(result, current);
|
|
25
|
+
return result;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export class FeatureSubSet {
|
|
2
|
+
|
|
3
|
+
private readonly indexList: Array<number> = new Array<number>()
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A constructor that takes number of features as input and initializes indexList with these numbers.
|
|
7
|
+
*
|
|
8
|
+
* @param numberOfFeaturesOrList Indicates the indices of indexList.
|
|
9
|
+
*/
|
|
10
|
+
constructor(numberOfFeaturesOrList?: any) {
|
|
11
|
+
if (numberOfFeaturesOrList != undefined){
|
|
12
|
+
if (typeof numberOfFeaturesOrList == "number"){
|
|
13
|
+
for (let i = 0; i < numberOfFeaturesOrList; i++) {
|
|
14
|
+
this.indexList.push(i);
|
|
15
|
+
}
|
|
16
|
+
} else {
|
|
17
|
+
this.indexList = numberOfFeaturesOrList
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The clone method creates a new ArrayList with the elements of indexList and returns it as a new FeatureSubSet.
|
|
24
|
+
*
|
|
25
|
+
* @return A new ArrayList with the elements of indexList and returns it as a new FeatureSubSet.
|
|
26
|
+
*/
|
|
27
|
+
clone(): FeatureSubSet{
|
|
28
|
+
let result = new FeatureSubSet(this.indexList.length)
|
|
29
|
+
for (let i = 0; i < this.indexList.length; i++){
|
|
30
|
+
result.add(this.indexList[i])
|
|
31
|
+
}
|
|
32
|
+
return result
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The size method returns the size of the indexList.
|
|
37
|
+
*
|
|
38
|
+
* @return The size of the indexList.
|
|
39
|
+
*/
|
|
40
|
+
size(): number{
|
|
41
|
+
return this.indexList.length
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The get method returns the item of indexList at given index.
|
|
46
|
+
*
|
|
47
|
+
* @param index Index of the indexList to be accessed.
|
|
48
|
+
* @return The item of indexList at given index.
|
|
49
|
+
*/
|
|
50
|
+
get(index: number): number{
|
|
51
|
+
return this.indexList[index]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* The contains method returns True, if indexList contains given input number and False otherwise.
|
|
56
|
+
*
|
|
57
|
+
* @param featureNo Feature number that will be checked.
|
|
58
|
+
* @return True, if indexList contains given input number.
|
|
59
|
+
*/
|
|
60
|
+
contains(featureNo: number){
|
|
61
|
+
return this.indexList.includes(featureNo)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The add method adds given Integer to the indexList.
|
|
66
|
+
*
|
|
67
|
+
* @param featureNo Integer that will be added to indexList.
|
|
68
|
+
*/
|
|
69
|
+
add(featureNo: number){
|
|
70
|
+
this.indexList.push(featureNo)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The remove method removes the item of indexList at the given index.
|
|
75
|
+
*
|
|
76
|
+
* @param index Index of the item that will be removed.
|
|
77
|
+
*/
|
|
78
|
+
remove(index: number){
|
|
79
|
+
this.indexList.splice(index, 1)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {SubSetSelection} from "./SubSetSelection";
|
|
2
|
+
import {FeatureSubSet} from "./FeatureSubSet";
|
|
3
|
+
|
|
4
|
+
export class FloatingSelection extends SubSetSelection{
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constructor that creates a new {@link FeatureSubSet}.
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super(new FeatureSubSet());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The operator method calls forward and backward methods.
|
|
15
|
+
*
|
|
16
|
+
* @param current {@link FeatureSubSet} input.
|
|
17
|
+
* @param numberOfFeatures Indicates the indices of indexList.
|
|
18
|
+
* @return ArrayList of FeatureSubSet.
|
|
19
|
+
*/
|
|
20
|
+
protected operator(current: FeatureSubSet, numberOfFeatures: number): Array<FeatureSubSet> {
|
|
21
|
+
let result = new Array<FeatureSubSet>();
|
|
22
|
+
this.forward(result, current, numberOfFeatures);
|
|
23
|
+
this.backward(result, current);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {SubSetSelection} from "./SubSetSelection";
|
|
2
|
+
import {FeatureSubSet} from "./FeatureSubSet";
|
|
3
|
+
|
|
4
|
+
export class ForwardSelection extends SubSetSelection{
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Constructor that creates a new {@link FeatureSubSet}.
|
|
8
|
+
*/
|
|
9
|
+
constructor() {
|
|
10
|
+
super(new FeatureSubSet());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The operator method calls forward method which starts with having no feature in the model. In each iteration,
|
|
15
|
+
* it keeps adding the features that are not currently listed.
|
|
16
|
+
*
|
|
17
|
+
* @param current FeatureSubset that will be added to new ArrayList.
|
|
18
|
+
* @param numberOfFeatures Indicates the indices of indexList.
|
|
19
|
+
* @return ArrayList of FeatureSubSets created from forward.
|
|
20
|
+
*/
|
|
21
|
+
protected operator(current: FeatureSubSet, numberOfFeatures: number): Array<FeatureSubSet> {
|
|
22
|
+
let result = new Array<FeatureSubSet>();
|
|
23
|
+
this.forward(result, current, numberOfFeatures);
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {FeatureSubSet} from "./FeatureSubSet";
|
|
2
|
+
import {MultipleRun} from "../Experiment/MultipleRun";
|
|
3
|
+
import {Experiment} from "../Experiment/Experiment";
|
|
4
|
+
|
|
5
|
+
export abstract class SubSetSelection {
|
|
6
|
+
|
|
7
|
+
protected initialSubSet: FeatureSubSet
|
|
8
|
+
|
|
9
|
+
protected abstract operator(current: FeatureSubSet, numberOfFeatures: number): Array<FeatureSubSet>
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A constructor that sets the initial subset with given input.
|
|
13
|
+
*
|
|
14
|
+
* @param initialSubSet {@link FeatureSubSet} input.
|
|
15
|
+
*/
|
|
16
|
+
protected constructor(initialSubSet: FeatureSubSet) {
|
|
17
|
+
this.initialSubSet = initialSubSet
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The forward method starts with having no feature in the model. In each iteration, it keeps adding the features that are not currently listed.
|
|
22
|
+
*
|
|
23
|
+
* @param currentSubSetList ArrayList to add the FeatureSubsets.
|
|
24
|
+
* @param current FeatureSubset that will be added to currentSubSetList.
|
|
25
|
+
* @param numberOfFeatures The number of features to add the subset.
|
|
26
|
+
*/
|
|
27
|
+
protected forward(currentSubSetList: Array<FeatureSubSet>, current: FeatureSubSet, numberOfFeatures: number){
|
|
28
|
+
for (let i = 0; i < numberOfFeatures; i++) {
|
|
29
|
+
if (!current.contains(i)) {
|
|
30
|
+
let candidate = current.clone();
|
|
31
|
+
candidate.add(i);
|
|
32
|
+
currentSubSetList.push(candidate);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The backward method starts with all the features and removes the least significant feature at each iteration.
|
|
39
|
+
*
|
|
40
|
+
* @param currentSubSetList ArrayList to add the FeatureSubsets.
|
|
41
|
+
* @param current FeatureSubset that will be added to currentSubSetList
|
|
42
|
+
*/
|
|
43
|
+
protected backward(currentSubSetList: Array<FeatureSubSet>, current: FeatureSubSet){
|
|
44
|
+
for (let i = 0; i < current.size(); i++) {
|
|
45
|
+
let candidate = current.clone();
|
|
46
|
+
candidate.remove(i);
|
|
47
|
+
currentSubSetList.push(candidate);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* The execute method takes an {@link Experiment} and a {@link MultipleRun} as inputs. By selecting a candidateList from given
|
|
53
|
+
* Experiment it tries to find a FeatureSubSet that gives best performance.
|
|
54
|
+
*
|
|
55
|
+
* @param multipleRun {@link MultipleRun} type input.
|
|
56
|
+
* @param experiment {@link Experiment} type input.
|
|
57
|
+
* @return FeatureSubSet that gives best performance.
|
|
58
|
+
*/
|
|
59
|
+
execute(multipleRun: MultipleRun, experiment: Experiment): FeatureSubSet{
|
|
60
|
+
let processed = new Set<FeatureSubSet>();
|
|
61
|
+
let best = this.initialSubSet;
|
|
62
|
+
processed.add(best);
|
|
63
|
+
let betterFound = true;
|
|
64
|
+
let bestPerformance = undefined, currentPerformance;
|
|
65
|
+
if (best.size() > 0){
|
|
66
|
+
bestPerformance = multipleRun.execute(experiment.featureSelectedExperiment(best));
|
|
67
|
+
}
|
|
68
|
+
while (betterFound) {
|
|
69
|
+
betterFound = false;
|
|
70
|
+
let candidateList = this.operator(best, experiment.getDataSet().getDataDefinition().attributeCount());
|
|
71
|
+
for (let candidateSubSet of candidateList) {
|
|
72
|
+
if (!processed.has(candidateSubSet)) {
|
|
73
|
+
if (candidateSubSet.size() > 0){
|
|
74
|
+
currentPerformance = multipleRun.execute(experiment.featureSelectedExperiment(candidateSubSet));
|
|
75
|
+
if (bestPerformance == null || currentPerformance.isBetter(bestPerformance)) {
|
|
76
|
+
best = candidateSubSet;
|
|
77
|
+
bestPerformance = currentPerformance;
|
|
78
|
+
betterFound = true;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
processed.add(candidateSubSet);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return best;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {LaryFilter} from "./LaryFilter";
|
|
2
|
+
import {Instance} from "../Instance/Instance";
|
|
3
|
+
import {DataSet} from "../DataSet/DataSet";
|
|
4
|
+
import {ContinuousAttribute} from "../Attribute/ContinuousAttribute";
|
|
5
|
+
import {AttributeType} from "../Attribute/AttributeType";
|
|
6
|
+
|
|
7
|
+
export class DiscreteToContinuous extends LaryFilter{
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts the data definition with discrete attributes, to data definition with continuous attributes. Basically,
|
|
11
|
+
* for each discrete attribute with L possible values, L more continuous attributes will be added.
|
|
12
|
+
*/
|
|
13
|
+
convertDataDefinition(): void {
|
|
14
|
+
let dataDefinition = this.dataSet.getDataDefinition();
|
|
15
|
+
let size = dataDefinition.attributeCount();
|
|
16
|
+
for (let i = 0; i < size; i++) {
|
|
17
|
+
if (this.attributeDistributions[i].size > 0) {
|
|
18
|
+
for (let j = 0; j < this.attributeDistributions[i].size; j++) {
|
|
19
|
+
dataDefinition.addAttribute(AttributeType.CONTINUOUS);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
this.removeDiscreteAttributesFromDataDefinition(size);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Converts discrete attributes of a single instance to continuous version using 1-of-L encoding. For example, if
|
|
28
|
+
* an attribute has values red, green, blue; this attribute will be converted to 3 continuous attributes where
|
|
29
|
+
* red will have the value 100, green will have the value 010, and blue will have the value 001.
|
|
30
|
+
*
|
|
31
|
+
* @param instance The instance to be converted.
|
|
32
|
+
*/
|
|
33
|
+
convertInstance(instance: Instance): void {
|
|
34
|
+
let size = instance.attributeSize();
|
|
35
|
+
for (let i = 0; i < size; i++) {
|
|
36
|
+
if (this.attributeDistributions[i].size > 0) {
|
|
37
|
+
let index = this.attributeDistributions[i].getIndex(instance.getAttribute(i).toString());
|
|
38
|
+
for (let j = 0; j < this.attributeDistributions[i].size; j++) {
|
|
39
|
+
if (j != index) {
|
|
40
|
+
instance.addAttribute(new ContinuousAttribute(0));
|
|
41
|
+
} else {
|
|
42
|
+
instance.addAttribute(new ContinuousAttribute(1));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
this.removeDiscreteAttributesFromInstance(instance, size);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Constructor for discrete to continuous filter.
|
|
52
|
+
*
|
|
53
|
+
* @param dataSet The dataSet whose instances whose discrete attributes will be converted to continuous attributes using
|
|
54
|
+
* 1-of-L encoding.
|
|
55
|
+
*/
|
|
56
|
+
constructor(dataSet: DataSet) {
|
|
57
|
+
super(dataSet);
|
|
58
|
+
}
|
|
59
|
+
}
|