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,99 @@
|
|
|
1
|
+
import { ValidatedModel } from "./ValidatedModel";
|
|
2
|
+
import { Vector } from "nlptoolkit-math/dist/Vector";
|
|
3
|
+
import { InstanceList } from "../InstanceList/InstanceList";
|
|
4
|
+
import { Matrix } from "nlptoolkit-math/dist/Matrix";
|
|
5
|
+
import { Instance } from "../Instance/Instance";
|
|
6
|
+
import { ActivationFunction } from "../Parameter/ActivationFunction";
|
|
7
|
+
export declare abstract class NeuralNetworkModel extends ValidatedModel {
|
|
8
|
+
protected classLabels: Array<string>;
|
|
9
|
+
protected K: number;
|
|
10
|
+
protected d: number;
|
|
11
|
+
protected x: Vector;
|
|
12
|
+
protected y: Vector;
|
|
13
|
+
protected r: Vector;
|
|
14
|
+
protected abstract calculateOutput(): void;
|
|
15
|
+
/**
|
|
16
|
+
* Constructor that sets the class labels, their sizes as K and the size of the continuous attributes as d.
|
|
17
|
+
*
|
|
18
|
+
* @param trainSet {@link InstanceList} to use as train set.
|
|
19
|
+
*/
|
|
20
|
+
protected constructor(trainSet: InstanceList);
|
|
21
|
+
/**
|
|
22
|
+
* The allocateLayerWeights method returns a new {@link Matrix} with random weights.
|
|
23
|
+
*
|
|
24
|
+
* @param row Number of rows.
|
|
25
|
+
* @param column Number of columns.
|
|
26
|
+
* @return Matrix with random weights.
|
|
27
|
+
*/
|
|
28
|
+
protected allocateLayerWeights(row: number, column: number): Matrix;
|
|
29
|
+
/**
|
|
30
|
+
* The normalizeOutput method takes an input {@link Vector} o, gets the result for e^o of each element of o,
|
|
31
|
+
* then sums them up. At the end, divides each e^o by the summation.
|
|
32
|
+
*
|
|
33
|
+
* @param o Vector to normalize.
|
|
34
|
+
* @return Normalized vector.
|
|
35
|
+
*/
|
|
36
|
+
protected normalizeOutput(o: Vector): Vector;
|
|
37
|
+
/**
|
|
38
|
+
* The createInputVector method takes an {@link Instance} as an input. It converts given Instance to the {@link Vector}
|
|
39
|
+
* and insert 1.0 to the first element.
|
|
40
|
+
*
|
|
41
|
+
* @param instance Instance to insert 1.0.
|
|
42
|
+
*/
|
|
43
|
+
protected createInputVector(instance: Instance): void;
|
|
44
|
+
/**
|
|
45
|
+
* The calculateHidden method takes a {@link Vector} input and {@link Matrix} weights, It multiplies the weights
|
|
46
|
+
* Matrix with given input Vector than applies the sigmoid function and returns the result.
|
|
47
|
+
*
|
|
48
|
+
* @param input Vector to multiply weights.
|
|
49
|
+
* @param weights Matrix is multiplied with input Vector.
|
|
50
|
+
* @param activationFunction Activation function.
|
|
51
|
+
* @return Result of sigmoid function.
|
|
52
|
+
*/
|
|
53
|
+
protected calculateHidden(input: Vector, weights: Matrix, activationFunction: ActivationFunction): Vector;
|
|
54
|
+
/**
|
|
55
|
+
* The calculateOneMinusHidden method takes a {@link Vector} as input. It creates a Vector of ones and
|
|
56
|
+
* returns the difference between given Vector.
|
|
57
|
+
*
|
|
58
|
+
* @param hidden Vector to find difference.
|
|
59
|
+
* @return Returns the difference between one's Vector and input Vector.
|
|
60
|
+
*/
|
|
61
|
+
protected calculateOneMinusHidden(hidden: Vector): Vector;
|
|
62
|
+
/**
|
|
63
|
+
* The calculateForwardSingleHiddenLayer method takes two matrices W and V. First it multiplies W with x, then
|
|
64
|
+
* multiplies V with the result of the previous multiplication.
|
|
65
|
+
*
|
|
66
|
+
* @param W Matrix to multiply with x.
|
|
67
|
+
* @param V Matrix to multiply.
|
|
68
|
+
* @param activationFunction Activation function.
|
|
69
|
+
*/
|
|
70
|
+
protected calculateForwardSingleHiddenLayer(W: Matrix, V: Matrix, activationFunction: ActivationFunction): void;
|
|
71
|
+
/**
|
|
72
|
+
* The calculateRMinusY method creates a new {@link Vector} with given Instance, then it multiplies given
|
|
73
|
+
* input Vector with given weights Matrix. After normalizing the output, it returns the difference between the newly created
|
|
74
|
+
* Vector and normalized output.
|
|
75
|
+
*
|
|
76
|
+
* @param instance Instance is used to get class labels.
|
|
77
|
+
* @param input Vector to multiply weights.
|
|
78
|
+
* @param weights Matrix of weights/
|
|
79
|
+
* @return Difference between newly created Vector and normalized output.
|
|
80
|
+
*/
|
|
81
|
+
protected calculateRMinusY(instance: Instance, input: Vector, weights: Matrix): Vector;
|
|
82
|
+
/**
|
|
83
|
+
* The predictWithCompositeInstance method takes an ArrayList possibleClassLabels. It returns the class label
|
|
84
|
+
* which has the maximum value of y.
|
|
85
|
+
*
|
|
86
|
+
* @param possibleClassLabels ArrayList that has the class labels.
|
|
87
|
+
* @return The class label which has the maximum value of y.
|
|
88
|
+
*/
|
|
89
|
+
protected predictWithCompositeInstance(possibleClassLabels: Array<string>): string;
|
|
90
|
+
/**
|
|
91
|
+
* The predict method takes an {@link Instance} as an input, converts it to a Vector and calculates the {@link Matrix} y by
|
|
92
|
+
* multiplying Matrix W with {@link Vector} x. Then it returns the class label which has the maximum y value.
|
|
93
|
+
*
|
|
94
|
+
* @param instance Instance to predict.
|
|
95
|
+
* @return The class label which has the maximum y.
|
|
96
|
+
*/
|
|
97
|
+
predict(instance: Instance): string;
|
|
98
|
+
predictProbability(instance: Instance): Map<string, number>;
|
|
99
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
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", "./ValidatedModel", "nlptoolkit-math/dist/Vector", "nlptoolkit-math/dist/Matrix", "../Parameter/ActivationFunction", "../Instance/CompositeInstance"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.NeuralNetworkModel = void 0;
|
|
13
|
+
const ValidatedModel_1 = require("./ValidatedModel");
|
|
14
|
+
const Vector_1 = require("nlptoolkit-math/dist/Vector");
|
|
15
|
+
const Matrix_1 = require("nlptoolkit-math/dist/Matrix");
|
|
16
|
+
const ActivationFunction_1 = require("../Parameter/ActivationFunction");
|
|
17
|
+
const CompositeInstance_1 = require("../Instance/CompositeInstance");
|
|
18
|
+
class NeuralNetworkModel extends ValidatedModel_1.ValidatedModel {
|
|
19
|
+
/**
|
|
20
|
+
* Constructor that sets the class labels, their sizes as K and the size of the continuous attributes as d.
|
|
21
|
+
*
|
|
22
|
+
* @param trainSet {@link InstanceList} to use as train set.
|
|
23
|
+
*/
|
|
24
|
+
constructor(trainSet) {
|
|
25
|
+
super();
|
|
26
|
+
this.classLabels = trainSet.getDistinctClassLabels();
|
|
27
|
+
this.K = this.classLabels.length;
|
|
28
|
+
this.d = trainSet.get(0).continuousAttributeSize();
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The allocateLayerWeights method returns a new {@link Matrix} with random weights.
|
|
32
|
+
*
|
|
33
|
+
* @param row Number of rows.
|
|
34
|
+
* @param column Number of columns.
|
|
35
|
+
* @return Matrix with random weights.
|
|
36
|
+
*/
|
|
37
|
+
allocateLayerWeights(row, column) {
|
|
38
|
+
return new Matrix_1.Matrix(row, column, -0.01, +0.01);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The normalizeOutput method takes an input {@link Vector} o, gets the result for e^o of each element of o,
|
|
42
|
+
* then sums them up. At the end, divides each e^o by the summation.
|
|
43
|
+
*
|
|
44
|
+
* @param o Vector to normalize.
|
|
45
|
+
* @return Normalized vector.
|
|
46
|
+
*/
|
|
47
|
+
normalizeOutput(o) {
|
|
48
|
+
let sum = 0.0;
|
|
49
|
+
let values = new Array();
|
|
50
|
+
for (let i = 0; i < values.length; i++) {
|
|
51
|
+
sum += Math.exp(o.getValue(i));
|
|
52
|
+
}
|
|
53
|
+
for (let i = 0; i < values.length; i++) {
|
|
54
|
+
values.push(Math.exp(o.getValue(i)) / sum);
|
|
55
|
+
}
|
|
56
|
+
return new Vector_1.Vector(values);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The createInputVector method takes an {@link Instance} as an input. It converts given Instance to the {@link Vector}
|
|
60
|
+
* and insert 1.0 to the first element.
|
|
61
|
+
*
|
|
62
|
+
* @param instance Instance to insert 1.0.
|
|
63
|
+
*/
|
|
64
|
+
createInputVector(instance) {
|
|
65
|
+
this.x = instance.toVector();
|
|
66
|
+
this.x.insert(0, 1.0);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The calculateHidden method takes a {@link Vector} input and {@link Matrix} weights, It multiplies the weights
|
|
70
|
+
* Matrix with given input Vector than applies the sigmoid function and returns the result.
|
|
71
|
+
*
|
|
72
|
+
* @param input Vector to multiply weights.
|
|
73
|
+
* @param weights Matrix is multiplied with input Vector.
|
|
74
|
+
* @param activationFunction Activation function.
|
|
75
|
+
* @return Result of sigmoid function.
|
|
76
|
+
*/
|
|
77
|
+
calculateHidden(input, weights, activationFunction) {
|
|
78
|
+
let z = weights.multiplyWithVectorFromRight(input);
|
|
79
|
+
switch (activationFunction) {
|
|
80
|
+
case ActivationFunction_1.ActivationFunction.SIGMOID:
|
|
81
|
+
default:
|
|
82
|
+
z.sigmoid();
|
|
83
|
+
break;
|
|
84
|
+
case ActivationFunction_1.ActivationFunction.TANH:
|
|
85
|
+
z.tanh();
|
|
86
|
+
break;
|
|
87
|
+
case ActivationFunction_1.ActivationFunction.RELU:
|
|
88
|
+
z.relu();
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
return z;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* The calculateOneMinusHidden method takes a {@link Vector} as input. It creates a Vector of ones and
|
|
95
|
+
* returns the difference between given Vector.
|
|
96
|
+
*
|
|
97
|
+
* @param hidden Vector to find difference.
|
|
98
|
+
* @return Returns the difference between one's Vector and input Vector.
|
|
99
|
+
*/
|
|
100
|
+
calculateOneMinusHidden(hidden) {
|
|
101
|
+
let one = new Vector_1.Vector(hidden.size(), 1.0);
|
|
102
|
+
return one.difference(hidden);
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* The calculateForwardSingleHiddenLayer method takes two matrices W and V. First it multiplies W with x, then
|
|
106
|
+
* multiplies V with the result of the previous multiplication.
|
|
107
|
+
*
|
|
108
|
+
* @param W Matrix to multiply with x.
|
|
109
|
+
* @param V Matrix to multiply.
|
|
110
|
+
* @param activationFunction Activation function.
|
|
111
|
+
*/
|
|
112
|
+
calculateForwardSingleHiddenLayer(W, V, activationFunction) {
|
|
113
|
+
let hidden = this.calculateHidden(this.x, W, activationFunction);
|
|
114
|
+
let hiddenBiased = hidden.biased();
|
|
115
|
+
this.y = V.multiplyWithVectorFromRight(hiddenBiased);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The calculateRMinusY method creates a new {@link Vector} with given Instance, then it multiplies given
|
|
119
|
+
* input Vector with given weights Matrix. After normalizing the output, it returns the difference between the newly created
|
|
120
|
+
* Vector and normalized output.
|
|
121
|
+
*
|
|
122
|
+
* @param instance Instance is used to get class labels.
|
|
123
|
+
* @param input Vector to multiply weights.
|
|
124
|
+
* @param weights Matrix of weights/
|
|
125
|
+
* @return Difference between newly created Vector and normalized output.
|
|
126
|
+
*/
|
|
127
|
+
calculateRMinusY(instance, input, weights) {
|
|
128
|
+
this.r = new Vector_1.Vector(this.K, this.classLabels.indexOf(instance.getClassLabel()), 1.0);
|
|
129
|
+
let o = weights.multiplyWithVectorFromRight(input);
|
|
130
|
+
this.y = this.normalizeOutput(o);
|
|
131
|
+
return this.r.difference(this.y);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The predictWithCompositeInstance method takes an ArrayList possibleClassLabels. It returns the class label
|
|
135
|
+
* which has the maximum value of y.
|
|
136
|
+
*
|
|
137
|
+
* @param possibleClassLabels ArrayList that has the class labels.
|
|
138
|
+
* @return The class label which has the maximum value of y.
|
|
139
|
+
*/
|
|
140
|
+
predictWithCompositeInstance(possibleClassLabels) {
|
|
141
|
+
let predictedClass = possibleClassLabels[0];
|
|
142
|
+
let maxY = Number.NEGATIVE_INFINITY;
|
|
143
|
+
for (let i = 0; i < this.classLabels.length; i++) {
|
|
144
|
+
if (possibleClassLabels.includes(this.classLabels[i]) && this.y.getValue(i) > maxY) {
|
|
145
|
+
maxY = this.y.getValue(i);
|
|
146
|
+
predictedClass = this.classLabels[i];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return predictedClass;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* The predict method takes an {@link Instance} as an input, converts it to a Vector and calculates the {@link Matrix} y by
|
|
153
|
+
* multiplying Matrix W with {@link Vector} x. Then it returns the class label which has the maximum y value.
|
|
154
|
+
*
|
|
155
|
+
* @param instance Instance to predict.
|
|
156
|
+
* @return The class label which has the maximum y.
|
|
157
|
+
*/
|
|
158
|
+
predict(instance) {
|
|
159
|
+
this.createInputVector(instance);
|
|
160
|
+
this.calculateOutput();
|
|
161
|
+
if (instance instanceof CompositeInstance_1.CompositeInstance) {
|
|
162
|
+
return this.predictWithCompositeInstance(instance.getPossibleClassLabels());
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return this.classLabels[this.y.maxIndex()];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
predictProbability(instance) {
|
|
169
|
+
this.createInputVector(instance);
|
|
170
|
+
this.calculateOutput();
|
|
171
|
+
let result = new Map();
|
|
172
|
+
for (let i = 0; i < this.classLabels.length; i++) {
|
|
173
|
+
result.set(this.classLabels[i], this.y.getValue(i));
|
|
174
|
+
}
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
exports.NeuralNetworkModel = NeuralNetworkModel;
|
|
179
|
+
});
|
|
180
|
+
//# sourceMappingURL=NeuralNetworkModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NeuralNetworkModel.js","sourceRoot":"","sources":["../../source/Model/NeuralNetworkModel.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { LdaModel } from "./LdaModel";
|
|
2
|
+
import { Matrix } from "nlptoolkit-math/dist/Matrix";
|
|
3
|
+
import { DiscreteDistribution } from "nlptoolkit-math/dist/DiscreteDistribution";
|
|
4
|
+
import { Vector } from "nlptoolkit-math/dist/Vector";
|
|
5
|
+
import { Instance } from "../Instance/Instance";
|
|
6
|
+
export declare class QdaModel extends LdaModel {
|
|
7
|
+
private W;
|
|
8
|
+
/**
|
|
9
|
+
* The constructor which sets the priorDistribution, w w1 and HashMap of String Matrix.
|
|
10
|
+
*
|
|
11
|
+
* @param priorDistribution {@link DiscreteDistribution} input.
|
|
12
|
+
* @param W {@link HashMap} of String and Matrix.
|
|
13
|
+
* @param w {@link HashMap} of String and Vectors.
|
|
14
|
+
* @param w0 {@link HashMap} of String and Double.
|
|
15
|
+
*/
|
|
16
|
+
constructor(priorDistribution: DiscreteDistribution, W: Map<string, Matrix>, w: Map<string, Vector>, w0: Map<string, number>);
|
|
17
|
+
/**
|
|
18
|
+
* The calculateMetric method takes an {@link Instance} and a String as inputs. It multiplies Matrix Wi with Vector xi
|
|
19
|
+
* then calculates the dot product of it with xi. Then, again it finds the dot product of wi and xi and returns the summation with w0i.
|
|
20
|
+
*
|
|
21
|
+
* @param instance {@link Instance} input.
|
|
22
|
+
* @param Ci String input.
|
|
23
|
+
* @return The result of Wi.multiplyWithVectorFromLeft(xi).dotProduct(xi) + wi.dotProduct(xi) + w0i.
|
|
24
|
+
*/
|
|
25
|
+
calculateMetric(instance: Instance, Ci: string): number;
|
|
26
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
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", "./LdaModel"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.QdaModel = void 0;
|
|
13
|
+
const LdaModel_1 = require("./LdaModel");
|
|
14
|
+
class QdaModel extends LdaModel_1.LdaModel {
|
|
15
|
+
/**
|
|
16
|
+
* The constructor which sets the priorDistribution, w w1 and HashMap of String Matrix.
|
|
17
|
+
*
|
|
18
|
+
* @param priorDistribution {@link DiscreteDistribution} input.
|
|
19
|
+
* @param W {@link HashMap} of String and Matrix.
|
|
20
|
+
* @param w {@link HashMap} of String and Vectors.
|
|
21
|
+
* @param w0 {@link HashMap} of String and Double.
|
|
22
|
+
*/
|
|
23
|
+
constructor(priorDistribution, W, w, w0) {
|
|
24
|
+
super(priorDistribution, w, w0);
|
|
25
|
+
this.W = W;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The calculateMetric method takes an {@link Instance} and a String as inputs. It multiplies Matrix Wi with Vector xi
|
|
29
|
+
* then calculates the dot product of it with xi. Then, again it finds the dot product of wi and xi and returns the summation with w0i.
|
|
30
|
+
*
|
|
31
|
+
* @param instance {@link Instance} input.
|
|
32
|
+
* @param Ci String input.
|
|
33
|
+
* @return The result of Wi.multiplyWithVectorFromLeft(xi).dotProduct(xi) + wi.dotProduct(xi) + w0i.
|
|
34
|
+
*/
|
|
35
|
+
calculateMetric(instance, Ci) {
|
|
36
|
+
let xi = instance.toVector();
|
|
37
|
+
let Wi = this.W.get(Ci);
|
|
38
|
+
let wi = this.w.get(Ci);
|
|
39
|
+
let w0i = this.w0.get(Ci);
|
|
40
|
+
return Wi.multiplyWithVectorFromLeft(xi).dotProduct(xi) + wi.dotProduct(xi) + w0i;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.QdaModel = QdaModel;
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=QdaModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"QdaModel.js","sourceRoot":"","sources":["../../source/Model/QdaModel.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,yCAAoC;IAMpC,MAAa,QAAS,SAAQ,mBAAQ;QAIlC;;;;;;;WAOG;QACH,YAAY,iBAAuC,EAAE,CAAsB,EAAE,CAAsB,EAAE,EAAuB;YACxH,KAAK,CAAC,iBAAiB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAChC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACd,CAAC;QAED;;;;;;;WAOG;QACH,eAAe,CAAC,QAAkB,EAAE,EAAU;YAC1C,IAAI,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAC;YAC7B,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACxB,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACxB,IAAI,GAAG,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC1B,OAAO,EAAE,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC;QACtF,CAAC;KACJ;IAhCD,4BAgCC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Model } from "./Model";
|
|
2
|
+
import { Instance } from "../Instance/Instance";
|
|
3
|
+
export declare class RandomModel extends Model {
|
|
4
|
+
private classLabels;
|
|
5
|
+
private seed;
|
|
6
|
+
constructor(classLabels: Array<string>, seed: number);
|
|
7
|
+
/**
|
|
8
|
+
* The predict method gets an Instance as an input and retrieves the possible class labels as an ArrayList. Then selects a
|
|
9
|
+
* random number as an index and returns the class label at this selected index.
|
|
10
|
+
*
|
|
11
|
+
* @param instance {@link Instance} to make prediction.
|
|
12
|
+
* @return The class label at the randomly selected index.
|
|
13
|
+
*/
|
|
14
|
+
predict(instance: Instance): string;
|
|
15
|
+
predictProbability(instance: Instance): Map<string, number>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
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", "./Model", "../Instance/CompositeInstance"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RandomModel = void 0;
|
|
13
|
+
const Model_1 = require("./Model");
|
|
14
|
+
const CompositeInstance_1 = require("../Instance/CompositeInstance");
|
|
15
|
+
class RandomModel extends Model_1.Model {
|
|
16
|
+
constructor(classLabels, seed) {
|
|
17
|
+
super();
|
|
18
|
+
this.classLabels = classLabels;
|
|
19
|
+
this.seed = seed;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The predict method gets an Instance as an input and retrieves the possible class labels as an ArrayList. Then selects a
|
|
23
|
+
* random number as an index and returns the class label at this selected index.
|
|
24
|
+
*
|
|
25
|
+
* @param instance {@link Instance} to make prediction.
|
|
26
|
+
* @return The class label at the randomly selected index.
|
|
27
|
+
*/
|
|
28
|
+
predict(instance) {
|
|
29
|
+
if ((instance instanceof CompositeInstance_1.CompositeInstance)) {
|
|
30
|
+
let possibleClassLabels = instance.getPossibleClassLabels();
|
|
31
|
+
let size = possibleClassLabels.length;
|
|
32
|
+
let index = Math.floor(Math.random() * size);
|
|
33
|
+
return possibleClassLabels[index];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
let size = this.classLabels.length;
|
|
37
|
+
let index = Math.floor(Math.random() * size);
|
|
38
|
+
return this.classLabels[index];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
predictProbability(instance) {
|
|
42
|
+
let result = new Map();
|
|
43
|
+
for (let classLabel of this.classLabels) {
|
|
44
|
+
result.set(classLabel, 1.0 / this.classLabels.length);
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.RandomModel = RandomModel;
|
|
50
|
+
});
|
|
51
|
+
//# sourceMappingURL=RandomModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RandomModel.js","sourceRoot":"","sources":["../../source/Model/RandomModel.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,mCAA8B;IAE9B,qEAAgE;IAEhE,MAAa,WAAY,SAAQ,aAAK;QAKlC,YAAY,WAA0B,EAAE,IAAY;YAChD,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;YAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QACpB,CAAC;QAED;;;;;;WAMG;QACH,OAAO,CAAC,QAAkB;YACtB,IAAI,CAAC,QAAQ,YAAY,qCAAiB,CAAC,EAAE;gBACzC,IAAI,mBAAmB,GAAwB,QAAS,CAAC,sBAAsB,EAAE,CAAC;gBAClF,IAAI,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC;gBACtC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7C,OAAO,mBAAmB,CAAC,KAAK,CAAC,CAAC;aACrC;iBAAM;gBACH,IAAI,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;gBACnC,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;gBAC7C,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAClC;QACL,CAAC;QAED,kBAAkB,CAAC,QAAkB;YACjC,IAAI,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;YACvC,KAAK,IAAI,UAAU,IAAI,IAAI,CAAC,WAAW,EAAC;gBACpC,MAAM,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;aACzD;YACD,OAAO,MAAM,CAAC;QAClB,CAAC;KAEJ;IAvCD,kCAuCC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Model } from "./Model";
|
|
2
|
+
import { Instance } from "../Instance/Instance";
|
|
3
|
+
import { DecisionTree } from "./DecisionTree/DecisionTree";
|
|
4
|
+
export declare class TreeEnsembleModel extends Model {
|
|
5
|
+
private forest;
|
|
6
|
+
/**
|
|
7
|
+
* A constructor which sets the {@link Array} of {@link DecisionTree} with given input.
|
|
8
|
+
*
|
|
9
|
+
* @param forest An {@link Array} of {@link DecisionTree}.
|
|
10
|
+
*/
|
|
11
|
+
constructor(forest: Array<DecisionTree>);
|
|
12
|
+
/**
|
|
13
|
+
* The predict method takes an {@link Instance} as an input and loops through the {@link ArrayList} of {@link DecisionTree}s.
|
|
14
|
+
* Makes prediction for the items of that ArrayList and returns the maximum item of that ArrayList.
|
|
15
|
+
*
|
|
16
|
+
* @param instance Instance to make prediction.
|
|
17
|
+
* @return The maximum prediction of a given Instance.
|
|
18
|
+
*/
|
|
19
|
+
predict(instance: Instance): string;
|
|
20
|
+
predictProbability(instance: Instance): Map<string, number>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
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", "./Model", "nlptoolkit-math/dist/DiscreteDistribution"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TreeEnsembleModel = void 0;
|
|
13
|
+
const Model_1 = require("./Model");
|
|
14
|
+
const DiscreteDistribution_1 = require("nlptoolkit-math/dist/DiscreteDistribution");
|
|
15
|
+
class TreeEnsembleModel extends Model_1.Model {
|
|
16
|
+
/**
|
|
17
|
+
* A constructor which sets the {@link Array} of {@link DecisionTree} with given input.
|
|
18
|
+
*
|
|
19
|
+
* @param forest An {@link Array} of {@link DecisionTree}.
|
|
20
|
+
*/
|
|
21
|
+
constructor(forest) {
|
|
22
|
+
super();
|
|
23
|
+
this.forest = forest;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The predict method takes an {@link Instance} as an input and loops through the {@link ArrayList} of {@link DecisionTree}s.
|
|
27
|
+
* Makes prediction for the items of that ArrayList and returns the maximum item of that ArrayList.
|
|
28
|
+
*
|
|
29
|
+
* @param instance Instance to make prediction.
|
|
30
|
+
* @return The maximum prediction of a given Instance.
|
|
31
|
+
*/
|
|
32
|
+
predict(instance) {
|
|
33
|
+
let distribution = new DiscreteDistribution_1.DiscreteDistribution();
|
|
34
|
+
for (let tree of this.forest) {
|
|
35
|
+
distribution.addItem(tree.predict(instance));
|
|
36
|
+
}
|
|
37
|
+
return distribution.getMaxItem();
|
|
38
|
+
}
|
|
39
|
+
predictProbability(instance) {
|
|
40
|
+
let distribution = new DiscreteDistribution_1.DiscreteDistribution();
|
|
41
|
+
for (let tree of this.forest) {
|
|
42
|
+
distribution.addItem(tree.predict(instance));
|
|
43
|
+
}
|
|
44
|
+
return distribution.getProbabilityDistribution();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.TreeEnsembleModel = TreeEnsembleModel;
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=TreeEnsembleModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TreeEnsembleModel.js","sourceRoot":"","sources":["../../source/Model/TreeEnsembleModel.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,mCAA8B;IAG9B,oFAA+E;IAE/E,MAAa,iBAAkB,SAAQ,aAAK;QAIxC;;;;WAIG;QACH,YAAY,MAA2B;YACnC,KAAK,EAAE,CAAC;YACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACxB,CAAC;QAED;;;;;;WAMG;QACH,OAAO,CAAC,QAAkB;YACtB,IAAI,YAAY,GAAG,IAAI,2CAAoB,EAAE,CAAC;YAC9C,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC1B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChD;YACD,OAAO,YAAY,CAAC,UAAU,EAAE,CAAC;QACrC,CAAC;QAED,kBAAkB,CAAC,QAAkB;YACjC,IAAI,YAAY,GAAG,IAAI,2CAAoB,EAAE,CAAC;YAC9C,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC1B,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;aAChD;YACD,OAAO,YAAY,CAAC,0BAA0B,EAAE,CAAC;QACrD,CAAC;KAEJ;IArCD,8CAqCC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Model } from "./Model";
|
|
2
|
+
import { InstanceList } from "../InstanceList/InstanceList";
|
|
3
|
+
import { ClassificationPerformance } from "../Performance/ClassificationPerformance";
|
|
4
|
+
export declare abstract class ValidatedModel extends Model {
|
|
5
|
+
/**
|
|
6
|
+
* The testClassifier method takes an {@link InstanceList} as an input and returns an accuracy value as {@link ClassificationPerformance}.
|
|
7
|
+
*
|
|
8
|
+
* @param data {@link InstanceList} to test.
|
|
9
|
+
* @return Accuracy value as {@link ClassificationPerformance}.
|
|
10
|
+
*/
|
|
11
|
+
testClassifier(data: InstanceList): ClassificationPerformance;
|
|
12
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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", "./Model", "../Performance/ClassificationPerformance"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ValidatedModel = void 0;
|
|
13
|
+
const Model_1 = require("./Model");
|
|
14
|
+
const ClassificationPerformance_1 = require("../Performance/ClassificationPerformance");
|
|
15
|
+
class ValidatedModel extends Model_1.Model {
|
|
16
|
+
/**
|
|
17
|
+
* The testClassifier method takes an {@link InstanceList} as an input and returns an accuracy value as {@link ClassificationPerformance}.
|
|
18
|
+
*
|
|
19
|
+
* @param data {@link InstanceList} to test.
|
|
20
|
+
* @return Accuracy value as {@link ClassificationPerformance}.
|
|
21
|
+
*/
|
|
22
|
+
testClassifier(data) {
|
|
23
|
+
let total = data.size();
|
|
24
|
+
let count = 0;
|
|
25
|
+
for (let i = 0; i < data.size(); i++) {
|
|
26
|
+
if (data.get(i).getClassLabel().toLowerCase() == this.predict(data.get(i)).toLowerCase()) {
|
|
27
|
+
count++;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return new ClassificationPerformance_1.ClassificationPerformance(count / total);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.ValidatedModel = ValidatedModel;
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=ValidatedModel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidatedModel.js","sourceRoot":"","sources":["../../source/Model/ValidatedModel.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,mCAA8B;IAE9B,wFAAmF;IAEnF,MAAsB,cAAe,SAAQ,aAAK;QAE9C;;;;;WAKG;QACH,cAAc,CAAC,IAAkB;YAC7B,IAAI,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACxB,IAAI,KAAK,GAAG,CAAC,CAAC;YACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;gBAClC,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE;oBACtF,KAAK,EAAE,CAAC;iBACX;aACJ;YACD,OAAO,IAAI,qDAAyB,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC;QACxD,CAAC;KACJ;IAlBD,wCAkBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
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"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ActivationFunction = void 0;
|
|
13
|
+
var ActivationFunction;
|
|
14
|
+
(function (ActivationFunction) {
|
|
15
|
+
ActivationFunction[ActivationFunction["SIGMOID"] = 0] = "SIGMOID";
|
|
16
|
+
ActivationFunction[ActivationFunction["TANH"] = 1] = "TANH";
|
|
17
|
+
ActivationFunction[ActivationFunction["RELU"] = 2] = "RELU";
|
|
18
|
+
})(ActivationFunction = exports.ActivationFunction || (exports.ActivationFunction = {}));
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=ActivationFunction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActivationFunction.js","sourceRoot":"","sources":["../../source/Parameter/ActivationFunction.ts"],"names":[],"mappings":";;;;;;;;;;;;IAAA,IAAY,kBAEX;IAFD,WAAY,kBAAkB;QAC1B,iEAAO,CAAA;QAAE,2DAAI,CAAA;QAAE,2DAAI,CAAA;IACvB,CAAC,EAFW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAE7B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Parameter } from "./Parameter";
|
|
2
|
+
export declare class BaggingParameter extends Parameter {
|
|
3
|
+
protected ensembleSize: number;
|
|
4
|
+
/**
|
|
5
|
+
* Parameters of the bagging trees algorithm.
|
|
6
|
+
*
|
|
7
|
+
* @param seed Seed is used for random number generation.
|
|
8
|
+
* @param ensembleSize The number of trees in the bagged forest.
|
|
9
|
+
*/
|
|
10
|
+
constructor(seed: number, ensembleSize: number);
|
|
11
|
+
/**
|
|
12
|
+
* Accessor for the ensemble size.
|
|
13
|
+
*
|
|
14
|
+
* @return The ensemble size.
|
|
15
|
+
*/
|
|
16
|
+
getEnsembleSize(): number;
|
|
17
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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", "./Parameter"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
"use strict";
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BaggingParameter = void 0;
|
|
13
|
+
const Parameter_1 = require("./Parameter");
|
|
14
|
+
class BaggingParameter extends Parameter_1.Parameter {
|
|
15
|
+
/**
|
|
16
|
+
* Parameters of the bagging trees algorithm.
|
|
17
|
+
*
|
|
18
|
+
* @param seed Seed is used for random number generation.
|
|
19
|
+
* @param ensembleSize The number of trees in the bagged forest.
|
|
20
|
+
*/
|
|
21
|
+
constructor(seed, ensembleSize) {
|
|
22
|
+
super(seed);
|
|
23
|
+
this.ensembleSize = ensembleSize;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Accessor for the ensemble size.
|
|
27
|
+
*
|
|
28
|
+
* @return The ensemble size.
|
|
29
|
+
*/
|
|
30
|
+
getEnsembleSize() {
|
|
31
|
+
return this.ensembleSize;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.BaggingParameter = BaggingParameter;
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=BaggingParameter.js.map
|