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,12 @@
|
|
|
1
|
+
import { Classifier } from "./Classifier";
|
|
2
|
+
import { InstanceList } from "../InstanceList/InstanceList";
|
|
3
|
+
import { Parameter } from "../Parameter/Parameter";
|
|
4
|
+
export declare class RandomClassifier extends Classifier {
|
|
5
|
+
/**
|
|
6
|
+
* Training algorithm for random classifier.
|
|
7
|
+
*
|
|
8
|
+
* @param trainSet Training data given to the algorithm.
|
|
9
|
+
* @param parameters -
|
|
10
|
+
*/
|
|
11
|
+
train(trainSet: InstanceList, parameters: Parameter): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Classifier", "../Model/RandomModel"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RandomClassifier = void 0;
|
|
13
|
+
const Classifier_1 = require("./Classifier");
|
|
14
|
+
const RandomModel_1 = require("../Model/RandomModel");
|
|
15
|
+
class RandomClassifier extends Classifier_1.Classifier {
|
|
16
|
+
/**
|
|
17
|
+
* Training algorithm for random classifier.
|
|
18
|
+
*
|
|
19
|
+
* @param trainSet Training data given to the algorithm.
|
|
20
|
+
* @param parameters -
|
|
21
|
+
*/
|
|
22
|
+
train(trainSet, parameters) {
|
|
23
|
+
let result = new Array();
|
|
24
|
+
for (let s of trainSet.classDistribution().keys()) {
|
|
25
|
+
result.push(s);
|
|
26
|
+
}
|
|
27
|
+
this.model = new RandomModel_1.RandomModel(result, parameters.getSeed());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.RandomClassifier = RandomClassifier;
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=RandomClassifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RandomClassifier.js","sourceRoot":"","sources":["../../source/Classifier/RandomClassifier.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6CAAwC;IAGxC,sDAAiD;IAEjD,MAAa,gBAAiB,SAAQ,uBAAU;QAE5C;;;;;WAKG;QACH,KAAK,CAAC,QAAsB,EAAE,UAAqB;YAC/C,IAAI,MAAM,GAAG,IAAI,KAAK,EAAU,CAAA;YAChC,KAAK,IAAI,CAAC,IAAI,QAAQ,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAC;gBAC9C,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;aACjB;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,yBAAW,CAAC,MAAM,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,CAAC;KAEJ;IAhBD,4CAgBC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Classifier } from "./Classifier";
|
|
2
|
+
import { InstanceList } from "../InstanceList/InstanceList";
|
|
3
|
+
import { Parameter } from "../Parameter/Parameter";
|
|
4
|
+
export declare class RandomForest extends Classifier {
|
|
5
|
+
/**
|
|
6
|
+
* Training algorithm for random forest classifier. Basically the algorithm creates K distinct decision trees from
|
|
7
|
+
* K bootstrap samples of the original training set.
|
|
8
|
+
*
|
|
9
|
+
* @param trainSet Training data given to the algorithm
|
|
10
|
+
* @param parameters Parameters of the bagging trees algorithm. ensembleSize returns the number of trees in the random forest.
|
|
11
|
+
*/
|
|
12
|
+
train(trainSet: InstanceList, parameters: Parameter): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./Classifier", "../InstanceList/InstanceList", "../Model/DecisionTree/DecisionTree", "../Model/DecisionTree/DecisionNode", "../Model/TreeEnsembleModel"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RandomForest = void 0;
|
|
13
|
+
const Classifier_1 = require("./Classifier");
|
|
14
|
+
const InstanceList_1 = require("../InstanceList/InstanceList");
|
|
15
|
+
const DecisionTree_1 = require("../Model/DecisionTree/DecisionTree");
|
|
16
|
+
const DecisionNode_1 = require("../Model/DecisionTree/DecisionNode");
|
|
17
|
+
const TreeEnsembleModel_1 = require("../Model/TreeEnsembleModel");
|
|
18
|
+
class RandomForest extends Classifier_1.Classifier {
|
|
19
|
+
/**
|
|
20
|
+
* Training algorithm for random forest classifier. Basically the algorithm creates K distinct decision trees from
|
|
21
|
+
* K bootstrap samples of the original training set.
|
|
22
|
+
*
|
|
23
|
+
* @param trainSet Training data given to the algorithm
|
|
24
|
+
* @param parameters Parameters of the bagging trees algorithm. ensembleSize returns the number of trees in the random forest.
|
|
25
|
+
*/
|
|
26
|
+
train(trainSet, parameters) {
|
|
27
|
+
let forestSize = parameters.getEnsembleSize();
|
|
28
|
+
let forest = new Array();
|
|
29
|
+
for (let i = 0; i < forestSize; i++) {
|
|
30
|
+
let bootstrap = trainSet.bootstrap(i);
|
|
31
|
+
let tree = new DecisionTree_1.DecisionTree(new DecisionNode_1.DecisionNode(new InstanceList_1.InstanceList(bootstrap.getSample()), undefined, parameters, false));
|
|
32
|
+
forest.push(tree);
|
|
33
|
+
}
|
|
34
|
+
this.model = new TreeEnsembleModel_1.TreeEnsembleModel(forest);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.RandomForest = RandomForest;
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=RandomForest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RandomForest.js","sourceRoot":"","sources":["../../source/Classifier/RandomForest.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,6CAAwC;IACxC,+DAA0D;IAG1D,qEAAgE;IAChE,qEAAgE;IAChE,kEAA6D;IAE7D,MAAa,YAAa,SAAQ,uBAAU;QAExC;;;;;;WAMG;QACH,KAAK,CAAC,QAAsB,EAAE,UAAqB;YAC/C,IAAI,UAAU,GAA4B,UAAW,CAAC,eAAe,EAAE,CAAC;YACxE,IAAI,MAAM,GAAG,IAAI,KAAK,EAAgB,CAAC;YACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,EAAE,CAAC,EAAE,EAAC;gBAChC,IAAI,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAI,IAAI,GAAG,IAAI,2BAAY,CAAC,IAAI,2BAAY,CAAC,IAAI,2BAAY,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC,EAAE,SAAS,EAA0B,UAAU,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC7I,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACrB;YACD,IAAI,CAAC,KAAK,GAAG,IAAI,qCAAiB,CAAC,MAAM,CAAC,CAAC;QAC/C,CAAC;KAEJ;IApBD,oCAoBC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { AttributeType } from "../Attribute/AttributeType";
|
|
2
|
+
import { FeatureSubSet } from "../FeatureSelection/FeatureSubSet";
|
|
3
|
+
export declare class DataDefinition {
|
|
4
|
+
private attributeTypes;
|
|
5
|
+
/**
|
|
6
|
+
* Constructor for creating a new {@link DataDefinition} with given attribute types.
|
|
7
|
+
*
|
|
8
|
+
* @param attributeTypes Attribute types of the data definition.
|
|
9
|
+
*/
|
|
10
|
+
constructor(attributeTypes?: Array<AttributeType>);
|
|
11
|
+
/**
|
|
12
|
+
* Returns the number of attribute types.
|
|
13
|
+
*
|
|
14
|
+
* @return Number of attribute types.
|
|
15
|
+
*/
|
|
16
|
+
attributeCount(): number;
|
|
17
|
+
/**
|
|
18
|
+
* Counts the occurrences of binary and discrete type attributes.
|
|
19
|
+
*
|
|
20
|
+
* @return Count of binary and discrete type attributes.
|
|
21
|
+
*/
|
|
22
|
+
discreteAttributeCount(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Counts the occurrences of binary and continuous type attributes.
|
|
25
|
+
*
|
|
26
|
+
* @return Count of of binary and continuous type attributes.
|
|
27
|
+
*/
|
|
28
|
+
continuousAttributeCount(): number;
|
|
29
|
+
/**
|
|
30
|
+
* Returns the attribute type of the corresponding item at given index.
|
|
31
|
+
*
|
|
32
|
+
* @param index Index of the attribute type.
|
|
33
|
+
* @return Attribute type of the corresponding item at given index.
|
|
34
|
+
*/
|
|
35
|
+
getAttributeType(index: number): AttributeType;
|
|
36
|
+
/**
|
|
37
|
+
* Adds an attribute type to the list of attribute types.
|
|
38
|
+
*
|
|
39
|
+
* @param attributeType Attribute type to add to the list of attribute types.
|
|
40
|
+
*/
|
|
41
|
+
addAttribute(attributeType: AttributeType): void;
|
|
42
|
+
/**
|
|
43
|
+
* Removes the attribute type at given index from the list of attributes.
|
|
44
|
+
*
|
|
45
|
+
* @param index Index to remove attribute type from list.
|
|
46
|
+
*/
|
|
47
|
+
removeAttribute(index: number): void;
|
|
48
|
+
/**
|
|
49
|
+
* Clears all the attribute types from list.
|
|
50
|
+
*/
|
|
51
|
+
removeAllAttributes(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Generates new subset of attribute types by using given feature subset.
|
|
54
|
+
*
|
|
55
|
+
* @param featureSubSet {@link FeatureSubSet} input.
|
|
56
|
+
* @return DataDefinition with new subset of attribute types.
|
|
57
|
+
*/
|
|
58
|
+
getSubSetOfFeatures(featureSubSet: FeatureSubSet): DataDefinition;
|
|
59
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../Attribute/AttributeType"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DataDefinition = void 0;
|
|
13
|
+
const AttributeType_1 = require("../Attribute/AttributeType");
|
|
14
|
+
class DataDefinition {
|
|
15
|
+
/**
|
|
16
|
+
* Constructor for creating a new {@link DataDefinition} with given attribute types.
|
|
17
|
+
*
|
|
18
|
+
* @param attributeTypes Attribute types of the data definition.
|
|
19
|
+
*/
|
|
20
|
+
constructor(attributeTypes) {
|
|
21
|
+
if (attributeTypes != undefined) {
|
|
22
|
+
this.attributeTypes = attributeTypes;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns the number of attribute types.
|
|
27
|
+
*
|
|
28
|
+
* @return Number of attribute types.
|
|
29
|
+
*/
|
|
30
|
+
attributeCount() {
|
|
31
|
+
return this.attributeTypes.length;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Counts the occurrences of binary and discrete type attributes.
|
|
35
|
+
*
|
|
36
|
+
* @return Count of binary and discrete type attributes.
|
|
37
|
+
*/
|
|
38
|
+
discreteAttributeCount() {
|
|
39
|
+
let count = 0;
|
|
40
|
+
for (let attributeType of this.attributeTypes) {
|
|
41
|
+
if (attributeType == AttributeType_1.AttributeType.DISCRETE || attributeType == AttributeType_1.AttributeType.BINARY) {
|
|
42
|
+
count++;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return count;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Counts the occurrences of binary and continuous type attributes.
|
|
49
|
+
*
|
|
50
|
+
* @return Count of of binary and continuous type attributes.
|
|
51
|
+
*/
|
|
52
|
+
continuousAttributeCount() {
|
|
53
|
+
let count = 0;
|
|
54
|
+
for (let attributeType of this.attributeTypes) {
|
|
55
|
+
if (attributeType == AttributeType_1.AttributeType.CONTINUOUS) {
|
|
56
|
+
count++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return count;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns the attribute type of the corresponding item at given index.
|
|
63
|
+
*
|
|
64
|
+
* @param index Index of the attribute type.
|
|
65
|
+
* @return Attribute type of the corresponding item at given index.
|
|
66
|
+
*/
|
|
67
|
+
getAttributeType(index) {
|
|
68
|
+
return this.attributeTypes[index];
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Adds an attribute type to the list of attribute types.
|
|
72
|
+
*
|
|
73
|
+
* @param attributeType Attribute type to add to the list of attribute types.
|
|
74
|
+
*/
|
|
75
|
+
addAttribute(attributeType) {
|
|
76
|
+
this.attributeTypes.push(attributeType);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Removes the attribute type at given index from the list of attributes.
|
|
80
|
+
*
|
|
81
|
+
* @param index Index to remove attribute type from list.
|
|
82
|
+
*/
|
|
83
|
+
removeAttribute(index) {
|
|
84
|
+
this.attributeTypes.splice(index, 1);
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Clears all the attribute types from list.
|
|
88
|
+
*/
|
|
89
|
+
removeAllAttributes() {
|
|
90
|
+
this.attributeTypes = new Array();
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Generates new subset of attribute types by using given feature subset.
|
|
94
|
+
*
|
|
95
|
+
* @param featureSubSet {@link FeatureSubSet} input.
|
|
96
|
+
* @return DataDefinition with new subset of attribute types.
|
|
97
|
+
*/
|
|
98
|
+
getSubSetOfFeatures(featureSubSet) {
|
|
99
|
+
let newAttributeTypes = new Array();
|
|
100
|
+
for (let i = 0; i < featureSubSet.size(); i++) {
|
|
101
|
+
newAttributeTypes.push(this.attributeTypes[featureSubSet.get(i)]);
|
|
102
|
+
}
|
|
103
|
+
return new DataDefinition(newAttributeTypes);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
exports.DataDefinition = DataDefinition;
|
|
107
|
+
});
|
|
108
|
+
//# sourceMappingURL=DataDefinition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataDefinition.js","sourceRoot":"","sources":["../../source/DataSet/DataDefinition.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,8DAAyD;IAGzD,MAAa,cAAc;QAIvB;;;;WAIG;QACH,YAAY,cAAqC;YAC7C,IAAI,cAAc,IAAI,SAAS,EAAC;gBAC5B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;aACvC;QACL,CAAC;QAED;;;;WAIG;QACH,cAAc;YACV,OAAO,IAAI,CAAC,cAAc,CAAC,MAAM,CAAA;QACrC,CAAC;QAED;;;;WAIG;QACH,sBAAsB;YAClB,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,aAAa,IAAI,IAAI,CAAC,cAAc,EAAE;gBAC3C,IAAI,aAAa,IAAI,6BAAa,CAAC,QAAQ,IAAI,aAAa,IAAI,6BAAa,CAAC,MAAM,EAAE;oBAClF,KAAK,EAAE,CAAC;iBACX;aACJ;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QAED;;;;WAIG;QACH,wBAAwB;YACpB,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,aAAa,IAAI,IAAI,CAAC,cAAc,EAAE;gBAC3C,IAAI,aAAa,IAAI,6BAAa,CAAC,UAAU,EAAE;oBAC3C,KAAK,EAAE,CAAC;iBACX;aACJ;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;QAED;;;;;WAKG;QACH,gBAAgB,CAAC,KAAa;YAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,CAAA;QACrC,CAAC;QAED;;;;WAIG;QACH,YAAY,CAAC,aAA4B;YACrC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QAC3C,CAAC;QAED;;;;WAIG;QACH,eAAe,CAAC,KAAa;YACzB,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACxC,CAAC;QAED;;WAEG;QACH,mBAAmB;YACf,IAAI,CAAC,cAAc,GAAG,IAAI,KAAK,EAAiB,CAAA;QACpD,CAAC;QAED;;;;;WAKG;QACH,mBAAmB,CAAC,aAA4B;YAC5C,IAAI,iBAAiB,GAAG,IAAI,KAAK,EAAiB,CAAC;YACnD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;gBAC3C,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;aACrE;YACD,OAAO,IAAI,cAAc,CAAC,iBAAiB,CAAC,CAAC;QACjD,CAAC;KACJ;IAtGD,wCAsGC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { InstanceList } from "../InstanceList/InstanceList";
|
|
2
|
+
import { DataDefinition } from "./DataDefinition";
|
|
3
|
+
import { Instance } from "../Instance/Instance";
|
|
4
|
+
import { FeatureSubSet } from "../FeatureSelection/FeatureSubSet";
|
|
5
|
+
export declare class DataSet {
|
|
6
|
+
private instances;
|
|
7
|
+
private definition;
|
|
8
|
+
/**
|
|
9
|
+
* Constructor for generating a new {@link DataSet} with given {@link DataDefinition}.
|
|
10
|
+
*
|
|
11
|
+
* @param definition Data definition of the data set.
|
|
12
|
+
* @param separator Separator character which separates the attribute values in the data file.
|
|
13
|
+
* @param fileName Name of the data set file.
|
|
14
|
+
*/
|
|
15
|
+
constructor(definition?: any, separator?: string, fileName?: string);
|
|
16
|
+
/**
|
|
17
|
+
* Checks the correctness of the attribute type, for instance, if the attribute of given instance is a Binary attribute,
|
|
18
|
+
* and the attribute type of the corresponding item of the data definition is also a Binary attribute, it then
|
|
19
|
+
* returns true, and false otherwise.
|
|
20
|
+
*
|
|
21
|
+
* @param instance {@link Instance} to checks the attribute type.
|
|
22
|
+
* @return true if attribute types of given {@link Instance} and data definition matches.
|
|
23
|
+
*/
|
|
24
|
+
private checkDefinition;
|
|
25
|
+
/**
|
|
26
|
+
* Adds the attribute types according to given {@link Instance}. For instance, if the attribute type of given {@link Instance}
|
|
27
|
+
* is a Discrete type, it than adds a discrete attribute type to the list of attribute types.
|
|
28
|
+
*
|
|
29
|
+
* @param instance {@link Instance} input.
|
|
30
|
+
*/
|
|
31
|
+
private setDefinition;
|
|
32
|
+
/**
|
|
33
|
+
* Returns the size of the {@link InstanceList}.
|
|
34
|
+
*
|
|
35
|
+
* @return Size of the {@link InstanceList}.
|
|
36
|
+
*/
|
|
37
|
+
sampleSize(): number;
|
|
38
|
+
/**
|
|
39
|
+
* Returns the size of the class label distribution of {@link InstanceList}.
|
|
40
|
+
*
|
|
41
|
+
* @return Size of the class label distribution of {@link InstanceList}.
|
|
42
|
+
*/
|
|
43
|
+
classCount(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the number of attribute types at {@link DataDefinition} list.
|
|
46
|
+
*
|
|
47
|
+
* @return The number of attribute types at {@link DataDefinition} list.
|
|
48
|
+
*/
|
|
49
|
+
attributeCount(): number;
|
|
50
|
+
/**
|
|
51
|
+
* Returns the number of discrete attribute types at {@link DataDefinition} list.
|
|
52
|
+
*
|
|
53
|
+
* @return The number of discrete attribute types at {@link DataDefinition} list.
|
|
54
|
+
*/
|
|
55
|
+
discreteAttributeCount(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Returns the number of continuous attribute types at {@link DataDefinition} list.
|
|
58
|
+
*
|
|
59
|
+
* @return The number of continuous attribute types at {@link DataDefinition} list.
|
|
60
|
+
*/
|
|
61
|
+
continuousAttributeCount(): number;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the accumulated {@link String} of class labels of the {@link InstanceList}.
|
|
64
|
+
*
|
|
65
|
+
* @return The accumulated {@link String} of class labels of the {@link InstanceList}.
|
|
66
|
+
*/
|
|
67
|
+
getClasses(): string;
|
|
68
|
+
/**
|
|
69
|
+
* Adds a new instance to the {@link InstanceList}.
|
|
70
|
+
*
|
|
71
|
+
* @param current {@link Instance} to add.
|
|
72
|
+
*/
|
|
73
|
+
addInstance(current: Instance): void;
|
|
74
|
+
/**
|
|
75
|
+
* Adds all the instances of given instance list to the {@link InstanceList}.
|
|
76
|
+
*
|
|
77
|
+
* @param instanceList {@link InstanceList} to add instances from.
|
|
78
|
+
*/
|
|
79
|
+
addInstanceList(instanceList: Array<Instance>): void;
|
|
80
|
+
/**
|
|
81
|
+
* Returns the instances of {@link InstanceList}.
|
|
82
|
+
*
|
|
83
|
+
* @return The instances of {@link InstanceList}.
|
|
84
|
+
*/
|
|
85
|
+
getInstances(): Array<Instance>;
|
|
86
|
+
/**
|
|
87
|
+
* Returns instances of the items at the list of instance lists from the partitions.
|
|
88
|
+
*
|
|
89
|
+
* @return Instances of the items at the list of instance lists from the partitions.
|
|
90
|
+
*/
|
|
91
|
+
getClassInstances(): Array<Array<Instance>>;
|
|
92
|
+
/**
|
|
93
|
+
* Accessor for the {@link InstanceList}.
|
|
94
|
+
*
|
|
95
|
+
* @return The {@link InstanceList}.
|
|
96
|
+
*/
|
|
97
|
+
getInstanceList(): InstanceList;
|
|
98
|
+
/**
|
|
99
|
+
* Accessor for the data definition.
|
|
100
|
+
*
|
|
101
|
+
* @return The data definition.
|
|
102
|
+
*/
|
|
103
|
+
getDataDefinition(): DataDefinition;
|
|
104
|
+
/**
|
|
105
|
+
* Return a subset generated via the given {@link FeatureSubSet}.
|
|
106
|
+
*
|
|
107
|
+
* @param featureSubSet {@link FeatureSubSet} input.
|
|
108
|
+
* @return Subset generated via the given {@link FeatureSubSet}.
|
|
109
|
+
*/
|
|
110
|
+
getSubSetOfFeatures(featureSubSet: FeatureSubSet): DataSet;
|
|
111
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../InstanceList/InstanceList", "./DataDefinition", "fs", "../Attribute/AttributeType", "../Instance/Instance", "../Instance/CompositeInstance", "../Attribute/ContinuousAttribute", "../Attribute/DiscreteAttribute", "../Attribute/BinaryAttribute", "../Attribute/DiscreteIndexedAttribute", "../InstanceList/Partition"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.DataSet = void 0;
|
|
13
|
+
const InstanceList_1 = require("../InstanceList/InstanceList");
|
|
14
|
+
const DataDefinition_1 = require("./DataDefinition");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const AttributeType_1 = require("../Attribute/AttributeType");
|
|
17
|
+
const Instance_1 = require("../Instance/Instance");
|
|
18
|
+
const CompositeInstance_1 = require("../Instance/CompositeInstance");
|
|
19
|
+
const ContinuousAttribute_1 = require("../Attribute/ContinuousAttribute");
|
|
20
|
+
const DiscreteAttribute_1 = require("../Attribute/DiscreteAttribute");
|
|
21
|
+
const BinaryAttribute_1 = require("../Attribute/BinaryAttribute");
|
|
22
|
+
const DiscreteIndexedAttribute_1 = require("../Attribute/DiscreteIndexedAttribute");
|
|
23
|
+
const Partition_1 = require("../InstanceList/Partition");
|
|
24
|
+
class DataSet {
|
|
25
|
+
/**
|
|
26
|
+
* Constructor for generating a new {@link DataSet} with given {@link DataDefinition}.
|
|
27
|
+
*
|
|
28
|
+
* @param definition Data definition of the data set.
|
|
29
|
+
* @param separator Separator character which separates the attribute values in the data file.
|
|
30
|
+
* @param fileName Name of the data set file.
|
|
31
|
+
*/
|
|
32
|
+
constructor(definition, separator, fileName) {
|
|
33
|
+
this.instances = new InstanceList_1.InstanceList();
|
|
34
|
+
this.definition = undefined;
|
|
35
|
+
if (definition != undefined) {
|
|
36
|
+
if (definition instanceof DataDefinition_1.DataDefinition) {
|
|
37
|
+
this.definition = definition;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
if (separator == undefined) {
|
|
41
|
+
let data = fs.readFileSync(fileName, 'utf8');
|
|
42
|
+
let i = 0;
|
|
43
|
+
let lines = data.split("\n");
|
|
44
|
+
for (let line of lines) {
|
|
45
|
+
let attributes = line.split(",");
|
|
46
|
+
if (i == 0) {
|
|
47
|
+
for (let j = 0; j < attributes.length - 1; j++) {
|
|
48
|
+
if (Number.isNaN(attributes[j])) {
|
|
49
|
+
definition.addAttribute(AttributeType_1.AttributeType.DISCRETE);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
Number.parseFloat(attributes[j]);
|
|
53
|
+
definition.addAttribute(AttributeType_1.AttributeType.CONTINUOUS);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
if (attributes.length != definition.attributeCount() + 1) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
let instance;
|
|
63
|
+
if (!attributes[attributes.length - 1].includes(";")) {
|
|
64
|
+
instance = new Instance_1.Instance(attributes[attributes.length - 1]);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
let labels = attributes[attributes.length - 1].split(";");
|
|
68
|
+
instance = new CompositeInstance_1.CompositeInstance(labels[0]);
|
|
69
|
+
instance.setPossibleClassLabels(labels.slice(1));
|
|
70
|
+
}
|
|
71
|
+
for (let j = 0; j < attributes.length - 1; j++) {
|
|
72
|
+
switch (definition.getAttributeType(j)) {
|
|
73
|
+
case AttributeType_1.AttributeType.CONTINUOUS:
|
|
74
|
+
instance.addAttribute(new ContinuousAttribute_1.ContinuousAttribute(Number.parseFloat(attributes[j])));
|
|
75
|
+
break;
|
|
76
|
+
case AttributeType_1.AttributeType.DISCRETE:
|
|
77
|
+
instance.addAttribute(new DiscreteAttribute_1.DiscreteAttribute(attributes[j]));
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (instance.attributeSize() == definition.attributeCount()) {
|
|
82
|
+
this.instances.add(instance);
|
|
83
|
+
}
|
|
84
|
+
i++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
this.definition = definition;
|
|
89
|
+
this.instances = new InstanceList_1.InstanceList(definition, separator, fileName);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Checks the correctness of the attribute type, for instance, if the attribute of given instance is a Binary attribute,
|
|
96
|
+
* and the attribute type of the corresponding item of the data definition is also a Binary attribute, it then
|
|
97
|
+
* returns true, and false otherwise.
|
|
98
|
+
*
|
|
99
|
+
* @param instance {@link Instance} to checks the attribute type.
|
|
100
|
+
* @return true if attribute types of given {@link Instance} and data definition matches.
|
|
101
|
+
*/
|
|
102
|
+
checkDefinition(instance) {
|
|
103
|
+
for (let i = 0; i < instance.attributeSize(); i++) {
|
|
104
|
+
if (instance.getAttribute(i) instanceof BinaryAttribute_1.BinaryAttribute) {
|
|
105
|
+
if (this.definition.getAttributeType(i) != AttributeType_1.AttributeType.BINARY)
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
if (instance.getAttribute(i) instanceof DiscreteIndexedAttribute_1.DiscreteIndexedAttribute) {
|
|
110
|
+
if (this.definition.getAttributeType(i) != AttributeType_1.AttributeType.DISCRETE_INDEXED)
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
if (instance.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute) {
|
|
115
|
+
if (this.definition.getAttributeType(i) != AttributeType_1.AttributeType.DISCRETE)
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
if (instance.getAttribute(i) instanceof ContinuousAttribute_1.ContinuousAttribute) {
|
|
120
|
+
if (this.definition.getAttributeType(i) != AttributeType_1.AttributeType.CONTINUOUS)
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return true;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Adds the attribute types according to given {@link Instance}. For instance, if the attribute type of given {@link Instance}
|
|
131
|
+
* is a Discrete type, it than adds a discrete attribute type to the list of attribute types.
|
|
132
|
+
*
|
|
133
|
+
* @param instance {@link Instance} input.
|
|
134
|
+
*/
|
|
135
|
+
setDefinition(instance) {
|
|
136
|
+
let attributeTypes = new Array();
|
|
137
|
+
for (let i = 0; i < instance.attributeSize(); i++) {
|
|
138
|
+
if (instance.getAttribute(i) instanceof BinaryAttribute_1.BinaryAttribute) {
|
|
139
|
+
attributeTypes.push(AttributeType_1.AttributeType.BINARY);
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (instance.getAttribute(i) instanceof DiscreteIndexedAttribute_1.DiscreteIndexedAttribute) {
|
|
143
|
+
attributeTypes.push(AttributeType_1.AttributeType.DISCRETE_INDEXED);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
if (instance.getAttribute(i) instanceof DiscreteAttribute_1.DiscreteAttribute) {
|
|
147
|
+
attributeTypes.push(AttributeType_1.AttributeType.DISCRETE);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
if (instance.getAttribute(i) instanceof ContinuousAttribute_1.ContinuousAttribute) {
|
|
151
|
+
attributeTypes.push(AttributeType_1.AttributeType.CONTINUOUS);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.definition = new DataDefinition_1.DataDefinition(attributeTypes);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Returns the size of the {@link InstanceList}.
|
|
161
|
+
*
|
|
162
|
+
* @return Size of the {@link InstanceList}.
|
|
163
|
+
*/
|
|
164
|
+
sampleSize() {
|
|
165
|
+
return this.instances.size();
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Returns the size of the class label distribution of {@link InstanceList}.
|
|
169
|
+
*
|
|
170
|
+
* @return Size of the class label distribution of {@link InstanceList}.
|
|
171
|
+
*/
|
|
172
|
+
classCount() {
|
|
173
|
+
return this.instances.classDistribution().size;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Returns the number of attribute types at {@link DataDefinition} list.
|
|
177
|
+
*
|
|
178
|
+
* @return The number of attribute types at {@link DataDefinition} list.
|
|
179
|
+
*/
|
|
180
|
+
attributeCount() {
|
|
181
|
+
return this.definition.attributeCount();
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Returns the number of discrete attribute types at {@link DataDefinition} list.
|
|
185
|
+
*
|
|
186
|
+
* @return The number of discrete attribute types at {@link DataDefinition} list.
|
|
187
|
+
*/
|
|
188
|
+
discreteAttributeCount() {
|
|
189
|
+
return this.definition.discreteAttributeCount();
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the number of continuous attribute types at {@link DataDefinition} list.
|
|
193
|
+
*
|
|
194
|
+
* @return The number of continuous attribute types at {@link DataDefinition} list.
|
|
195
|
+
*/
|
|
196
|
+
continuousAttributeCount() {
|
|
197
|
+
return this.definition.continuousAttributeCount();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Returns the accumulated {@link String} of class labels of the {@link InstanceList}.
|
|
201
|
+
*
|
|
202
|
+
* @return The accumulated {@link String} of class labels of the {@link InstanceList}.
|
|
203
|
+
*/
|
|
204
|
+
getClasses() {
|
|
205
|
+
let classLabels = this.instances.getDistinctClassLabels();
|
|
206
|
+
let result = classLabels[0];
|
|
207
|
+
for (let i = 1; i < classLabels.length; i++) {
|
|
208
|
+
result = result + ";" + classLabels[i];
|
|
209
|
+
}
|
|
210
|
+
return result;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Adds a new instance to the {@link InstanceList}.
|
|
214
|
+
*
|
|
215
|
+
* @param current {@link Instance} to add.
|
|
216
|
+
*/
|
|
217
|
+
addInstance(current) {
|
|
218
|
+
if (this.definition == undefined) {
|
|
219
|
+
this.setDefinition(current);
|
|
220
|
+
this.instances.add(current);
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (this.checkDefinition(current)) {
|
|
224
|
+
this.instances.add(current);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Adds all the instances of given instance list to the {@link InstanceList}.
|
|
230
|
+
*
|
|
231
|
+
* @param instanceList {@link InstanceList} to add instances from.
|
|
232
|
+
*/
|
|
233
|
+
addInstanceList(instanceList) {
|
|
234
|
+
for (let instance of instanceList) {
|
|
235
|
+
this.addInstance(instance);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Returns the instances of {@link InstanceList}.
|
|
240
|
+
*
|
|
241
|
+
* @return The instances of {@link InstanceList}.
|
|
242
|
+
*/
|
|
243
|
+
getInstances() {
|
|
244
|
+
return this.instances.getInstances();
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Returns instances of the items at the list of instance lists from the partitions.
|
|
248
|
+
*
|
|
249
|
+
* @return Instances of the items at the list of instance lists from the partitions.
|
|
250
|
+
*/
|
|
251
|
+
getClassInstances() {
|
|
252
|
+
return new Partition_1.Partition(this.instances).getLists();
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Accessor for the {@link InstanceList}.
|
|
256
|
+
*
|
|
257
|
+
* @return The {@link InstanceList}.
|
|
258
|
+
*/
|
|
259
|
+
getInstanceList() {
|
|
260
|
+
return this.instances;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Accessor for the data definition.
|
|
264
|
+
*
|
|
265
|
+
* @return The data definition.
|
|
266
|
+
*/
|
|
267
|
+
getDataDefinition() {
|
|
268
|
+
return this.definition;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Return a subset generated via the given {@link FeatureSubSet}.
|
|
272
|
+
*
|
|
273
|
+
* @param featureSubSet {@link FeatureSubSet} input.
|
|
274
|
+
* @return Subset generated via the given {@link FeatureSubSet}.
|
|
275
|
+
*/
|
|
276
|
+
getSubSetOfFeatures(featureSubSet) {
|
|
277
|
+
let result = new DataSet(this.definition.getSubSetOfFeatures(featureSubSet));
|
|
278
|
+
for (let i = 0; i < this.instances.size(); i++) {
|
|
279
|
+
result.addInstance(this.instances.get(i).getSubSetOfFeatures(featureSubSet));
|
|
280
|
+
}
|
|
281
|
+
return result;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
exports.DataSet = DataSet;
|
|
285
|
+
});
|
|
286
|
+
//# sourceMappingURL=DataSet.js.map
|