├── .github
├── FUNDING.yml
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ ├── custom.md
│ ├── feature_request.md
│ └── new_feature.md
├── .gitignore
├── CHANGELOG.md
├── CHANGELOG.md.meta
├── LICENSE
├── README.md
├── README.md.meta
├── Runtime.meta
├── Runtime
├── BigtreeAlgorithm.meta
├── BigtreeAlgorithm
│ ├── Bayes.meta
│ ├── Bayes
│ │ ├── BernoulliNaiveBayes.cs
│ │ ├── BernoulliNaiveBayes.cs.meta
│ │ ├── GaussianNaiveBayes.cs
│ │ ├── GaussianNaiveBayes.cs.meta
│ │ ├── MultinomiaNaiveBayes.cs
│ │ ├── MultinomiaNaiveBayes.cs.meta
│ │ ├── MultinomiaNaiveBayesModel.cs
│ │ └── MultinomiaNaiveBayesModel.cs.meta
│ ├── CNN.meta
│ ├── CNN
│ │ ├── NetworkModel.cs
│ │ └── NetworkModel.cs.meta
│ ├── CRFLite.meta
│ ├── CRFLite
│ │ ├── BaseModel.cs
│ │ ├── BaseModel.cs.meta
│ │ ├── CRFDecoder.cs
│ │ ├── CRFDecoder.cs.meta
│ │ ├── CRFEncoder.cs
│ │ ├── CRFEncoder.cs.meta
│ │ ├── CRFSharpHelper.cs
│ │ ├── CRFSharpHelper.cs.meta
│ │ ├── Decoder.meta
│ │ ├── Decoder
│ │ │ ├── CRFTermOut.cs
│ │ │ ├── CRFTermOut.cs.meta
│ │ │ ├── DecoderOptions.cs
│ │ │ ├── DecoderOptions.cs.meta
│ │ │ ├── DecoderTagger.cs
│ │ │ ├── DecoderTagger.cs.meta
│ │ │ ├── ModelReader.cs
│ │ │ ├── ModelReader.cs.meta
│ │ │ ├── ModelReaderExtensions.cs
│ │ │ └── ModelReaderExtensions.cs.meta
│ │ ├── Encoder.meta
│ │ ├── Encoder
│ │ │ ├── CRFEncoderThread.cs
│ │ │ ├── CRFEncoderThread.cs.meta
│ │ │ ├── DefaultFeatureLexicalDict.cs
│ │ │ ├── DefaultFeatureLexicalDict.cs.meta
│ │ │ ├── EncoderOptions.cs
│ │ │ ├── EncoderOptions.cs.meta
│ │ │ ├── EncoderTagger.cs
│ │ │ ├── EncoderTagger.cs.meta
│ │ │ ├── FeatureIdPair.cs
│ │ │ ├── FeatureIdPair.cs.meta
│ │ │ ├── FeatureItem.cs
│ │ │ ├── FeatureItem.cs.meta
│ │ │ ├── HugeFeatureLexicalDict.cs
│ │ │ ├── HugeFeatureLexicalDict.cs.meta
│ │ │ ├── IFeatureLexicalDict.cs
│ │ │ ├── IFeatureLexicalDict.cs.meta
│ │ │ ├── LBFGS.cs
│ │ │ ├── LBFGS.cs.meta
│ │ │ ├── Mcsrch.cs
│ │ │ ├── Mcsrch.cs.meta
│ │ │ ├── ModelWriter.cs
│ │ │ └── ModelWriter.cs.meta
│ │ ├── IGenerateFeature.cs
│ │ ├── IGenerateFeature.cs.meta
│ │ ├── Node.cs
│ │ ├── Node.cs.meta
│ │ ├── Path.cs
│ │ ├── Path.cs.meta
│ │ ├── Pool.cs
│ │ ├── Pool.cs.meta
│ │ ├── SegDecoderTagger.cs
│ │ ├── SegDecoderTagger.cs.meta
│ │ ├── Tagger.cs
│ │ ├── Tagger.cs.meta
│ │ ├── Utils.cs
│ │ ├── Utils.cs.meta
│ │ ├── Utils.meta
│ │ └── Utils
│ │ │ ├── BTreeDictionary.cs
│ │ │ ├── BTreeDictionary.cs.meta
│ │ │ ├── BigArray.cs
│ │ │ ├── BigArray.cs.meta
│ │ │ ├── DoubleArrayTrie.cs
│ │ │ ├── DoubleArrayTrie.cs.meta
│ │ │ ├── FixedBigArray.cs
│ │ │ ├── FixedBigArray.cs.meta
│ │ │ ├── LimitedConcurrencyLevelTaskScheduler.cs
│ │ │ ├── LimitedConcurrencyLevelTaskScheduler.cs.meta
│ │ │ ├── MD5.cs
│ │ │ ├── MD5.cs.meta
│ │ │ ├── VarBigArray.cs
│ │ │ ├── VarBigArray.cs.meta
│ │ │ ├── VectorQuantization.cs
│ │ │ └── VectorQuantization.cs.meta
│ ├── DecisionTree.meta
│ ├── DecisionTree
│ │ ├── DataReader.cs
│ │ ├── DataReader.cs.meta
│ │ ├── NodeAttribute.cs
│ │ ├── NodeAttribute.cs.meta
│ │ ├── README.rst
│ │ ├── README.rst.meta
│ │ ├── TrainingData.cs
│ │ ├── TrainingData.cs.meta
│ │ ├── Tree.cs
│ │ ├── Tree.cs.meta
│ │ ├── TreeNode.cs
│ │ └── TreeNode.cs.meta
│ ├── Estimators.meta
│ ├── Estimators
│ │ ├── AdditiveSmoothing.cs
│ │ ├── AdditiveSmoothing.cs.meta
│ │ ├── IEstimator.cs
│ │ └── IEstimator.cs.meta
│ ├── Extensions.meta
│ ├── Extensions
│ │ ├── Reduce.cs
│ │ ├── Reduce.cs.meta
│ │ ├── Shuffle.cs
│ │ ├── Shuffle.cs.meta
│ │ ├── Split.cs
│ │ └── Split.cs.meta
│ ├── Features.meta
│ ├── Features
│ │ ├── Feature.cs
│ │ ├── Feature.cs.meta
│ │ ├── FeaturesDistribution.cs
│ │ └── FeaturesDistribution.cs.meta
│ ├── HiddenMarkovModel.meta
│ ├── HiddenMarkovModel
│ │ ├── ForwardBackwardAlgorithm.Log.Continuous.cs
│ │ ├── ForwardBackwardAlgorithm.Log.Continuous.cs.meta
│ │ ├── ForwardBackwardAlgorithm.Log.cs
│ │ ├── ForwardBackwardAlgorithm.Log.cs.meta
│ │ ├── ForwardBackwardAlgorithm.cs
│ │ ├── ForwardBackwardAlgorithm.cs.meta
│ │ ├── Helpers.meta
│ │ ├── Helpers
│ │ │ ├── Codification.cs
│ │ │ ├── Codification.cs.meta
│ │ │ ├── DiagnosticsHelper.cs
│ │ │ ├── DiagnosticsHelper.cs.meta
│ │ │ ├── MathHelper.cs
│ │ │ ├── MathHelper.cs.meta
│ │ │ ├── ValidationHelper.cs
│ │ │ └── ValidationHelper.cs.meta
│ │ ├── HiddenMarkovClassifier.Continuous.cs
│ │ ├── HiddenMarkovClassifier.Continuous.cs.meta
│ │ ├── HiddenMarkovClassifier.cs
│ │ ├── HiddenMarkovClassifier.cs.meta
│ │ ├── HiddenMarkovModel.Continuous.cs
│ │ ├── HiddenMarkovModel.Continuous.cs.meta
│ │ ├── HiddenMarkovModel.Generate.cs
│ │ ├── HiddenMarkovModel.Generate.cs.meta
│ │ ├── HiddenMarkovModel.Predict.cs
│ │ ├── HiddenMarkovModel.Predict.cs.meta
│ │ ├── HiddenMarkovModel.cs
│ │ ├── HiddenMarkovModel.cs.meta
│ │ ├── Learning.meta
│ │ ├── Learning
│ │ │ ├── Supervised.meta
│ │ │ ├── Supervised
│ │ │ │ ├── HiddenMarkovClassifierLearning.Continuous.cs
│ │ │ │ ├── HiddenMarkovClassifierLearning.Continuous.cs.meta
│ │ │ │ ├── HiddenMarkovClassifierLearning.cs
│ │ │ │ ├── HiddenMarkovClassifierLearning.cs.meta
│ │ │ │ ├── MaximumLikelihoodLearning.Continuous.cs
│ │ │ │ ├── MaximumLikelihoodLearning.Continuous.cs.meta
│ │ │ │ ├── MaximumLikelihoodLearning.cs
│ │ │ │ └── MaximumLikelihoodLearning.cs.meta
│ │ │ ├── Unsupervised.meta
│ │ │ └── Unsupervised
│ │ │ │ ├── BaumWelchLearning.Continuous.cs
│ │ │ │ ├── BaumWelchLearning.Continuous.cs.meta
│ │ │ │ ├── BaumWelchLearning.cs
│ │ │ │ ├── BaumWelchLearning.cs.meta
│ │ │ │ ├── IUnsupervisedLearning.Continuous.cs
│ │ │ │ ├── IUnsupervisedLearning.Continuous.cs.meta
│ │ │ │ ├── IUnsupervisedLearning.cs
│ │ │ │ ├── IUnsupervisedLearning.cs.meta
│ │ │ │ ├── ViterbiLearning.Continuous.cs
│ │ │ │ ├── ViterbiLearning.Continuous.cs.meta
│ │ │ │ ├── ViterbiLearning.cs
│ │ │ │ └── ViterbiLearning.cs.meta
│ │ ├── MathHelpers.meta
│ │ ├── MathHelpers
│ │ │ ├── Factorial.cs
│ │ │ ├── Factorial.cs.meta
│ │ │ ├── Gamma.cs
│ │ │ ├── Gamma.cs.meta
│ │ │ ├── LogHelper.cs
│ │ │ ├── LogHelper.cs.meta
│ │ │ ├── MergeSort.cs
│ │ │ ├── MergeSort.cs.meta
│ │ │ ├── PolynomialHelper.cs
│ │ │ └── PolynomialHelper.cs.meta
│ │ ├── MathUtils.meta
│ │ ├── MathUtils
│ │ │ ├── Constants.cs
│ │ │ ├── Constants.cs.meta
│ │ │ ├── Distribution.meta
│ │ │ ├── Distribution
│ │ │ │ ├── Binomial.cs
│ │ │ │ ├── Binomial.cs.meta
│ │ │ │ ├── ChiSquare.cs
│ │ │ │ ├── ChiSquare.cs.meta
│ │ │ │ ├── DistributionModel.cs
│ │ │ │ ├── DistributionModel.cs.meta
│ │ │ │ ├── Erlang.cs
│ │ │ │ ├── Erlang.cs.meta
│ │ │ │ ├── Exponential.cs
│ │ │ │ ├── Exponential.cs.meta
│ │ │ │ ├── FDistribution.cs
│ │ │ │ ├── FDistribution.cs.meta
│ │ │ │ ├── Gaussian.cs
│ │ │ │ ├── Gaussian.cs.meta
│ │ │ │ ├── LogNormal.cs
│ │ │ │ ├── LogNormal.cs.meta
│ │ │ │ ├── MultivariateDistributionModel.cs
│ │ │ │ ├── MultivariateDistributionModel.cs.meta
│ │ │ │ ├── Poisson.cs
│ │ │ │ ├── Poisson.cs.meta
│ │ │ │ ├── StudentT.cs
│ │ │ │ └── StudentT.cs.meta
│ │ │ ├── LinearAlgebra.meta
│ │ │ ├── LinearAlgebra
│ │ │ │ ├── MatrixOp.cs
│ │ │ │ └── MatrixOp.cs.meta
│ │ │ ├── SpecialFunctions.meta
│ │ │ ├── SpecialFunctions
│ │ │ │ ├── ClampFunction.cs
│ │ │ │ ├── ClampFunction.cs.meta
│ │ │ │ ├── ErrorFunction.cs
│ │ │ │ ├── ErrorFunction.cs.meta
│ │ │ │ ├── GammaFunction.cs
│ │ │ │ ├── GammaFunction.cs.meta
│ │ │ │ ├── InverseErrorFunction.cs
│ │ │ │ ├── InverseErrorFunction.cs.meta
│ │ │ │ ├── InverseLogitFunction.cs
│ │ │ │ ├── InverseLogitFunction.cs.meta
│ │ │ │ ├── LogitFunction.cs
│ │ │ │ └── LogitFunction.cs.meta
│ │ │ ├── Statistics.meta
│ │ │ └── Statistics
│ │ │ │ ├── ANCOVA.cs
│ │ │ │ ├── ANCOVA.cs.meta
│ │ │ │ ├── ANCOVAv2.cs
│ │ │ │ ├── ANCOVAv2.cs.meta
│ │ │ │ ├── ANOVA.cs
│ │ │ │ ├── ANOVA.cs.meta
│ │ │ │ ├── Bootstrapping.cs
│ │ │ │ ├── Bootstrapping.cs.meta
│ │ │ │ ├── CLT.cs
│ │ │ │ ├── CLT.cs.meta
│ │ │ │ ├── ChiSquareGOFTest.cs
│ │ │ │ ├── ChiSquareGOFTest.cs.meta
│ │ │ │ ├── ChiSquareIndependenceTest.cs
│ │ │ │ ├── ChiSquareIndependenceTest.cs.meta
│ │ │ │ ├── CollectionExtensionMethods.cs
│ │ │ │ ├── CollectionExtensionMethods.cs.meta
│ │ │ │ ├── ConfidenceInterval.cs
│ │ │ │ ├── ConfidenceInterval.cs.meta
│ │ │ │ ├── Correlation.cs
│ │ │ │ ├── Correlation.cs.meta
│ │ │ │ ├── DescriptiveStatistics.cs
│ │ │ │ ├── DescriptiveStatistics.cs.meta
│ │ │ │ ├── HypothesisTesting.cs
│ │ │ │ ├── HypothesisTesting.cs.meta
│ │ │ │ ├── HypothesisTestingForProportion.cs
│ │ │ │ ├── HypothesisTestingForProportion.cs.meta
│ │ │ │ ├── LinearCombination.cs
│ │ │ │ ├── LinearCombination.cs.meta
│ │ │ │ ├── MANCOVA.cs
│ │ │ │ ├── MANCOVA.cs.meta
│ │ │ │ ├── MANOVA.cs
│ │ │ │ ├── MANOVA.cs.meta
│ │ │ │ ├── Mean.cs
│ │ │ │ ├── Mean.cs.meta
│ │ │ │ ├── Median.cs
│ │ │ │ ├── Median.cs.meta
│ │ │ │ ├── MultipleComparisons.cs
│ │ │ │ ├── MultipleComparisons.cs.meta
│ │ │ │ ├── Sample.cs
│ │ │ │ ├── Sample.cs.meta
│ │ │ │ ├── StandardError.cs
│ │ │ │ ├── StandardError.cs.meta
│ │ │ │ ├── StdDev.cs
│ │ │ │ ├── StdDev.cs.meta
│ │ │ │ ├── TwoWayANOVA.cs
│ │ │ │ └── TwoWayANOVA.cs.meta
│ │ ├── Topology.meta
│ │ ├── Topology
│ │ │ ├── Ergodic.cs
│ │ │ ├── Ergodic.cs.meta
│ │ │ ├── Forward.cs
│ │ │ ├── Forward.cs.meta
│ │ │ ├── ITopology.cs
│ │ │ └── ITopology.cs.meta
│ │ ├── Viterbi.Log.Continuous.cs
│ │ ├── Viterbi.Log.Continuous.cs.meta
│ │ ├── Viterbi.Log.cs
│ │ ├── Viterbi.Log.cs.meta
│ │ ├── Viterbi.cs
│ │ └── Viterbi.cs.meta
│ ├── KNN.meta
│ ├── KNN
│ │ ├── KnnModel.cs
│ │ ├── KnnModel.cs.meta
│ │ ├── data.meta
│ │ └── data
│ │ │ ├── train.csv
│ │ │ └── train.csv.meta
│ ├── LinearRegression.meta
│ ├── LinearRegression
│ │ ├── LinearRegressionModel.cs
│ │ ├── LinearRegressionModel.cs.meta
│ │ ├── README.md
│ │ └── README.md.meta
│ ├── MathFunctions.meta
│ ├── MathFunctions
│ │ ├── Sigmoid.cs
│ │ └── Sigmoid.cs.meta
│ ├── SVM.meta
│ ├── SVM
│ │ ├── Cache.cs
│ │ ├── Cache.cs.meta
│ │ ├── GaussianTransform.cs
│ │ ├── GaussianTransform.cs.meta
│ │ ├── IRangeTransform.cs
│ │ ├── IRangeTransform.cs.meta
│ │ ├── Kernel.cs
│ │ ├── Kernel.cs.meta
│ │ ├── Model.cs
│ │ ├── Model.cs.meta
│ │ ├── Node.cs
│ │ ├── Node.cs.meta
│ │ ├── Parameter.cs
│ │ ├── Parameter.cs.meta
│ │ ├── ParameterSelection.cs
│ │ ├── ParameterSelection.cs.meta
│ │ ├── PerformanceEvaluator.cs
│ │ ├── PerformanceEvaluator.cs.meta
│ │ ├── PrecomputedKernel.cs
│ │ ├── PrecomputedKernel.cs.meta
│ │ ├── Prediction.cs
│ │ ├── Prediction.cs.meta
│ │ ├── Problem.cs
│ │ ├── Problem.cs.meta
│ │ ├── RangeTransform.cs
│ │ ├── RangeTransform.cs.meta
│ │ ├── SVMExtensions.cs
│ │ ├── SVMExtensions.cs.meta
│ │ ├── SVMUtilities.cs
│ │ ├── SVMUtilities.cs.meta
│ │ ├── Scaling.cs
│ │ ├── Scaling.cs.meta
│ │ ├── Solver.cs
│ │ ├── Solver.cs.meta
│ │ ├── TemporaryCulture.cs
│ │ ├── TemporaryCulture.cs.meta
│ │ ├── Training.cs
│ │ └── Training.cs.meta
│ ├── Statistics.meta
│ ├── Statistics
│ │ ├── Probability.cs
│ │ └── Probability.cs.meta
│ ├── VX.AI.Runtime.BigtreeAlgorithm.asmdef
│ └── VX.AI.Runtime.BigtreeAlgorithm.asmdef.meta
├── VX.AI.Runtime.asmdef
└── VX.AI.Runtime.asmdef.meta
├── package.json
└── package.json.meta
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4 | patreon: voxelltech
5 | open_collective: # Replace with a single Open Collective username
6 | ko_fi: # Replace with a single Ko-fi username
7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9 | liberapay: # Replace with a single Liberapay username
10 | issuehunt: # Replace with a single IssueHunt username
11 | otechie: # Replace with a single Otechie username
12 | custom: ["paypal.me/voxelltechnologies"]
13 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior:
15 | 1. Go to '...'
16 | 2. Click on '....'
17 | 3. Scroll down to '....'
18 | 4. See error
19 |
20 | **Expected behavior**
21 | A clear and concise description of what you expected to happen.
22 |
23 | **Screenshots**
24 | If applicable, add screenshots to help explain your problem.
25 |
26 | **Desktop (please complete the following information):**
27 | - OS: [e.g. iOS]
28 | - Browser [e.g. chrome, safari]
29 | - Version [e.g. 22]
30 |
31 | **Smartphone (please complete the following information):**
32 | - Device: [e.g. iPhone6]
33 | - OS: [e.g. iOS8.1]
34 | - Browser [e.g. stock browser, safari]
35 | - Version [e.g. 22]
36 |
37 | **Additional context**
38 | Add any other context about the problem here.
39 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/custom.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Custom issue template
3 | about: Describe this issue template's purpose here.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/new_feature.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: New Feature
3 | about: Creating a new feature for this project.
4 | title: ''
5 | labels: ''
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Summary**
11 |
12 | A quick intro or summary on the feature you want to create.
13 |
14 | **Intended Outcome**
15 |
16 | - What is the use case of this?
17 | - How will it affect/benefit the project?
18 |
19 | **How will it work?**
20 |
21 | - How to use this feature?
22 |
23 | *finally, please assign yourself to this issue if you intend to work on this new feature thanks!*
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vscode/
2 | __pycache__/
3 | checkpoints/
4 | inference/
5 | env/
6 | temp/
7 |
8 | # This .gitignore file should be placed at the root of your Unity project directory
9 | #
10 | # Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
11 | #
12 | /[Ll]ibrary/
13 | /[Tt]emp/
14 | /[Oo]bj/
15 | /[Bb]uild/
16 | /[Bb]uilds/
17 | /[Ll]ogs/
18 | /[Uu]ser[Ss]ettings/
19 | /[Rr]ecordings/
20 | /[Rr]eleases/
21 | /[Rr]elease/
22 |
23 |
24 | # MemoryCaptures can get excessive in size.
25 | # They also could contain extremely sensitive data
26 | /[Mm]emoryCaptures/
27 |
28 | # Asset meta data should only be ignored when the corresponding asset is also ignored
29 | !/[Aa]ssets/**/*.meta
30 |
31 | # Uncomment this line if you wish to ignore the asset store tools plugin
32 | # /[Aa]ssets/AssetStoreTools*
33 |
34 | # Autogenerated Jetbrains Rider plugin
35 | /[Aa]ssets/Plugins/Editor/JetBrains*
36 |
37 | # Visual Studio cache directory
38 | .vs/
39 |
40 | # Gradle cache directory
41 | .gradle/
42 |
43 | # Autogenerated VS/MD/Consulo solution and project files
44 | ExportedObj/
45 | .consulo/
46 | *.csproj
47 | *.unityproj
48 | *.sln
49 | *.suo
50 | *.tmp
51 | *.user
52 | *.userprefs
53 | *.pidb
54 | *.booproj
55 | *.svd
56 | *.pdb
57 | *.mdb
58 | *.opendb
59 | *.VC.db
60 |
61 | # Unity3D generated meta files
62 | *.pidb.meta
63 | *.pdb.meta
64 | *.mdb.meta
65 |
66 | # Unity3D generated file on crash reports
67 | sysinfo.txt
68 |
69 | # Builds
70 | *.apk
71 | *.aab
72 | *.unitypackage
73 | *.unitypackage.meta
74 | *.exe
75 |
76 | # Crashlytics generated file
77 | crashlytics-build.properties
78 |
79 | # Packed Addressables
80 | /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*
81 |
82 | # Temporary auto-generated Android Assets
83 | /[Aa]ssets/[Ss]treamingAssets/aa.meta
84 | /[Aa]ssets/[Ss]treamingAssets/aa/*
85 |
86 | # Tensorflow trained checkpoints and weights
87 | *.h5
88 | *.h5.meta
89 | *.pbmm
90 | *.pbmm.meta
91 | *.tflite
92 | *.tflite.meta
93 |
94 | # API keys
95 | *.apikey
96 |
97 | # pycaches
98 | *.pyc
99 |
100 | # audio files
101 | AudioClips/
102 | *.mp3
103 | *.wav
104 | *.audio
105 |
106 | # license
107 | LICENSE.meta
108 |
109 | # large libraries
110 | native/
111 | tensorflow.dll
112 | tensorflow.dll.meta
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## [1.0.0]
2 |
3 | - Initial release.
4 | - Implemented BigtreeAlgorithm as the core of this package.
--------------------------------------------------------------------------------
/CHANGELOG.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a5c043eda769b7c438c23df4283d7b9a
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Unity AI
2 |
3 | The aim of this package is to provide AI related tools in Unity. This package references the [BigtreeAlgorithm](https://github.com/SciSharp/Bigtree.Algorithm) repository.
4 |
5 | ## Table of contents
6 | - [Unity AI](#unity-ai)
7 | - [Table of contents](#table-of-contents)
8 | - [Installation](#installation)
9 | - [Support the project!](#support-the-project)
10 | - [Join the community!](#join-the-community)
11 | - [License](#license)
12 | - [References](#references)
13 |
14 | ## Installation
15 |
16 | External dependencies:
17 |
18 | - VX Util ([UnityUtil](https://github.com/voxell-tech/UnityUtil))
19 |
20 | 1. Clone the [UnityUtil](https://github.com/voxell-tech/UnityUtil) repository into your `Packages` folder.
21 | 2. Clone this repository into your `Packages` folder.
22 | 3. And you are ready to go!
23 |
24 | ## Support the project!
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | ## Join the community!
35 |
36 |
37 |
38 |
39 |
40 |
41 | ## License
42 |
43 | This repository as a whole is licensed under the Apache License 2.0. Individual files may have a different, but compatible license.
44 |
45 | See [license file](./LICENSE) for details.
46 |
47 | ## References
48 |
49 | - [BigtreeAlgorithm](https://github.com/SciSharp/Bigtree.Algorithm)
--------------------------------------------------------------------------------
/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: eb06a6e06c1c77349b965aa9a5ca3b5c
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5a1fedfa6d8680048b7df5dee984c410
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b2b142ff4978b404fa6fae0b2ed0bc6b
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 45b5ca4a314b7db44b3c63f95b2d2d4d
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/BernoulliNaiveBayes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.Bayes
6 | {
7 | public class BernoulliNaiveBayes
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/BernoulliNaiveBayes.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9657055b192fefa4fa350437e4c4c5f6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/GaussianNaiveBayes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.Bayes
6 | {
7 | public class GaussianNaiveBayes
8 | {
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/GaussianNaiveBayes.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5814d97d819647f45a13f52af079acde
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/MultinomiaNaiveBayes.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Bigtree.Algorithm
3 | * Copyright (C) 2018 Haiping Chen
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using Bigtree.Algorithm.Estimators;
20 | using Bigtree.Algorithm.Features;
21 | using Bigtree.Algorithm.Statistics;
22 | using System;
23 | using System.Collections.Generic;
24 | using System.Linq;
25 | using System.Text;
26 |
27 | namespace Bigtree.Algorithm.Bayes
28 | {
29 | ///
30 | /// https://en.wikipedia.org/wiki/Bayes%27_theorem
31 | ///
32 | public class MultinomiaNaiveBayes
33 | {
34 | public List LabelDist { get; set; }
35 |
36 | public List> FeatureSet { get; set; }
37 |
38 | private double alpha { get; set; }
39 |
40 | public MultinomiaNaiveBayes(double alpha = 0.5)
41 | {
42 | this.alpha = alpha;
43 | }
44 |
45 | ///
46 | /// prior probability
47 | ///
48 | ///
49 | ///
50 | public double CalPriorProb(string Y)
51 | {
52 | int N = FeatureSet.Count;
53 | int k = LabelDist.Count;
54 | int Nyk = LabelDist.First(x => x.Value == Y).Freq;
55 |
56 | return (Nyk + alpha) / (N + k * alpha);
57 | }
58 |
59 | public double CalCondProb(int x, string Y, double feature)
60 | {
61 | // posterior probability P(X1,...,Xn|Y) = Sum(P(X1|Y) +...+ P(Xn|Y)
62 | var featuresIfY = FeatureSet.Where(fd => fd.Item1 == Y).ToList();
63 | var matrix = ConstructMatrix(featuresIfY);
64 |
65 | int freq = 0;
66 | for (int y = 0; y < featuresIfY.Count; y++)
67 | {
68 | if (matrix[y, x] == feature)
69 | {
70 | freq++;
71 | }
72 | }
73 |
74 | int Nyk = featuresIfY.Count;
75 | int n = featuresIfY.Count;
76 | int Nykx = freq;
77 |
78 | return Math.Log((Nykx + alpha) / (Nyk + n * alpha));
79 | }
80 |
81 | ///
82 | /// calculate posterior probability P(Y|X)
83 | /// X is feature set, Y is label
84 | /// P(X1,...,Xn|Y) = Sum(P(X1|Y) +...+ P(Xn|Y)
85 | /// P(X, Y) = P(Y|X)P(X) = P(X|Y)P(Y) => P(Y|X) = P(Y)P(X|Y)/P(X)
86 | ///
87 | public double CalPosteriorProb(string Y, double[] features, double priorProb, Dictionary condProbDictionary)
88 | {
89 | int featureCount = features.Length;
90 |
91 | double postProb = Math.Log(priorProb);
92 |
93 | // loop features
94 | for (int x = 0; x < featureCount; x++)
95 | {
96 | string key = $"{Y} f{x} {features[x]}";
97 | if(features[x] == 1)
98 | {
99 | postProb += condProbDictionary[key];
100 | }
101 | }
102 |
103 | return Math.Pow(2, postProb);
104 | }
105 |
106 | private double[,] ConstructMatrix(List> featuresIfY)
107 | {
108 | var featureCount = featuresIfY[0].Item2.Length;
109 |
110 | double[,] matrix = new double[featuresIfY.Count, featureCount];
111 | for (int y = 0; y < featuresIfY.Count; y++)
112 | {
113 | for (int x = 0; x < featureCount; x++)
114 | {
115 | matrix[y, x] = featuresIfY[y].Item2[x];
116 | }
117 | }
118 |
119 | return matrix;
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/MultinomiaNaiveBayes.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e64bfbf2d3f2cfa4680432a4d5a2b876
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/MultinomiaNaiveBayesModel.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.Statistics;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Bayes
7 | {
8 | public class MultinomiaNaiveBayesModel
9 | {
10 | public List LabelDist { get; set; }
11 |
12 | public Dictionary CondProbDictionary { get; set; }
13 |
14 | public List Values { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Bayes/MultinomiaNaiveBayesModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b07a98e15e3080543af9b52957ae663d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CNN.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2477d3b78ab2f284e8654130d3906767
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CNN/NetworkModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.CNN
6 | {
7 | public class NetworkModel
8 | {
9 | public int FilterSize { get; set; }
10 |
11 | public NetworkModel()
12 | {
13 | FilterSize = 5;
14 | }
15 |
16 | public void Train()
17 | {
18 | Initialize();
19 | }
20 |
21 | private void Initialize(double scale = 1.0)
22 | {
23 | var fan_in = FilterSize * FilterSize * 1; // image depth
24 | var stddev = scale * Math.Sqrt(1.0 / fan_in);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CNN/NetworkModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8116af61b70782f4e835785f589d0858
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 74e4211a593e4d24ab399f23afbe47f0
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/BaseModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 68d2e6ee169caa04fa39bf2a378c66c8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/CRFDecoder.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 932cebbc57b8089479635663dbb6a09d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/CRFEncoder.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 47abe42f99ea41945a91095591cab2cc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/CRFSharpHelper.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.CRFLite.Decoder;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite
7 | {
8 | public class SegToken
9 | {
10 | public int Offset;
11 | public int Length;
12 | public string Tag;
13 | public double Weight;
14 | };
15 |
16 | public class CRFSegOut : CRFTermOut
17 | {
18 | //Segmented token by merging raw CRF model output
19 | public int termTotalLength; // the total term length in character
20 | public List tokenList;
21 |
22 | public int Count
23 | {
24 | get { return tokenList.Count; }
25 | }
26 |
27 | public void Clear()
28 | {
29 | termTotalLength = 0;
30 | tokenList.Clear();
31 | }
32 |
33 | public CRFSegOut(int max_word_num = BaseUtils.DEFAULT_CRF_MAX_WORD_NUM):
34 | base(max_word_num)
35 | {
36 | termTotalLength = 0;
37 | tokenList = new List();
38 | }
39 | };
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/CRFSharpHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3de086647fec7724a924629927daee35
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 193cd6e6a7b7d4f44a7462b88fe2cf12
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/CRFTermOut.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Runtime.CompilerServices;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Decoder
7 | {
8 | public class CRFTermOut
9 | {
10 | //Sequence label probability
11 | public double prob;
12 |
13 | //Raw CRF model output
14 | public string[] result_;
15 | public double[] weight_;
16 |
17 | public CRFTermOut(int max_word_num = BaseUtils.DEFAULT_CRF_MAX_WORD_NUM)
18 | {
19 | prob = 0;
20 | result_ = new string[max_word_num];
21 | weight_ = new double[max_word_num];
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/CRFTermOut.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 248aa14402b6c1643b4358e520da1985
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/DecoderOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Decoder
7 | {
8 | public class DecoderOptions
9 | {
10 | ///
11 | /// Model file path
12 | ///
13 | public string ModelFileName;
14 |
15 | ///
16 | ///
17 | ///
18 | public string InputFileName;
19 |
20 | ///
21 | ///
22 | ///
23 | public int NBest;
24 |
25 | ///
26 | ///
27 | ///
28 | public int Thread;
29 |
30 | ///
31 | ///
32 | ///
33 | public int ProbLevel;
34 |
35 | ///
36 | /// Max words length in one sentence
37 | ///
38 | public int MaxWord;
39 |
40 | public DecoderOptions()
41 | {
42 | Thread = 1;
43 | NBest = 2;
44 | ProbLevel = 0;
45 | MaxWord = 128;
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/DecoderOptions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: adba149174dcd204380df6d6b2268f29
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/DecoderTagger.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39ff108f624d6934d9fe74cffeeb29e8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/ModelReader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e7c4005891b3c1549aae936f94866f0c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/ModelReaderExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.CRFLite.Decoder
8 | {
9 | internal static class ModelReaderExtensions
10 | {
11 | private static readonly string featureFileNameExtension = ".feature";
12 | private static readonly string weightFileNameExtension = ".alpha";
13 |
14 | internal static string ToMetadataModelName(this string modelName)
15 | {
16 | return modelName;
17 | }
18 |
19 | internal static string ToFeatureSetFileName(this string modelName)
20 | {
21 | return String.Concat(modelName, featureFileNameExtension);
22 | }
23 |
24 | internal static string ToFeatureWeightFileName(this string modelName)
25 | {
26 | return String.Concat(modelName, weightFileNameExtension);
27 | }
28 |
29 | internal static void ThrowIfNotExists(this string fileName)
30 | {
31 | if (String.IsNullOrWhiteSpace(fileName))
32 | throw new ArgumentNullException("fileName",
33 | "Please specify a valid model path");
34 |
35 | if (!File.Exists(fileName))
36 | throw new FileNotFoundException("fileName",
37 | "Please specify a valid model path");
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Decoder/ModelReaderExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fd48d3a1634889941aed4eb0aa20ddb7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3a649c215f8fd4745a13ff03f8ca0162
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/CRFEncoderThread.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 |
7 | namespace Bigtree.Algorithm.CRFLite.Encoder
8 | {
9 | public class CRFEncoderThread
10 | {
11 | public EncoderTagger[] x;
12 | public int start_i;
13 | public int thread_num;
14 | public int zeroone;
15 | public int err;
16 | public double obj;
17 | public Node[,] node_;
18 | short[] result_;
19 | public short max_xsize_;
20 | public LBFGS lbfgs;
21 | public int[,] merr;
22 |
23 | public void Init()
24 | {
25 | if (x.Length == 0)
26 | {
27 | return;
28 | }
29 |
30 | var ysize_ = x[0].ysize_;
31 | max_xsize_ = 0;
32 | for (var i = start_i; i < x.Length; i += thread_num)
33 | {
34 | if (max_xsize_ < x[i].word_num)
35 | {
36 | max_xsize_ = x[i].word_num;
37 | }
38 | }
39 |
40 | result_ = new short[max_xsize_];
41 | node_ = new Node[max_xsize_, ysize_];
42 | for (var i = 0; i < max_xsize_; i++)
43 | {
44 | for (var j = 0; j < ysize_; j++)
45 | {
46 | node_[i, j] = new Node();
47 | node_[i, j].x = (short)i;
48 | node_[i, j].y = (short)j;
49 | node_[i, j].lpathList = new List(ysize_);
50 | node_[i, j].rpathList = new List(ysize_);
51 | }
52 | }
53 |
54 | for (short cur = 1; cur < max_xsize_; ++cur)
55 | {
56 | for (short j = 0; j < ysize_; ++j)
57 | {
58 | for (short i = 0; i < ysize_; ++i)
59 | {
60 | var path = new Path();
61 | path.fid = -1;
62 | path.cost = 0.0;
63 | path.add(node_[cur - 1, j], node_[cur, i]);
64 | }
65 | }
66 | }
67 |
68 | merr = new int[ysize_, ysize_];
69 | }
70 |
71 | public void Run()
72 | {
73 | //Initialize thread self data structure
74 | obj = 0.0f;
75 | err = zeroone = 0;
76 | //expected.Clear();
77 | Array.Clear(merr, 0, merr.Length);
78 | for (var i = start_i; i < x.Length; i += thread_num)
79 | {
80 | x[i].Init(result_, node_);
81 | obj += x[i].gradient(lbfgs.expected);
82 | var error_num = x[i].eval(merr);
83 | err += error_num;
84 | if (error_num > 0)
85 | {
86 | ++zeroone;
87 | }
88 | }
89 | }
90 |
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/CRFEncoderThread.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e432b78b34cf6be42bb70277b63698e0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/DefaultFeatureLexicalDict.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cba7cb7c9fd426a4e944a108637aba08
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/EncoderOptions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.CRFLite.Encoder
6 | {
7 | public class EncoderOptions
8 | {
9 | ///
10 | /// Maximum iteration
11 | ///
12 | public int MaxIteration { get; set; }
13 |
14 | ///
15 | /// Minimum feature frequency, if one feature's frequency is less than this value, the feature will be dropped.
16 | ///
17 | public int MinFeatureFreq = 1;
18 |
19 | ///
20 | /// Minimum diff value, when diff less than the value consecutive 3 times, the process will be ended.
21 | ///
22 | public double MinDifference;
23 |
24 | ///
25 | /// The maximum slot usage rate threshold when building feature set.
26 | ///
27 | public double SlotUsageRateThreshold { get; set; }
28 |
29 | ///
30 | /// The amount of threads used to train model.
31 | ///
32 | public int ThreadsNum { get; set; }
33 |
34 | ///
35 | /// Regularization type
36 | ///
37 | public CRFEncoder.REG_TYPE RegType { get; set; }
38 |
39 | ///
40 | /// Template file name
41 | ///
42 | public string TemplateFileName { get; set; }
43 |
44 | ///
45 | /// Training corpus file name
46 | ///
47 | public string TrainingCorpusFileName { get; set; }
48 |
49 | ///
50 | /// Encoded model file name
51 | ///
52 | public string ModelFileName { get; set; }
53 |
54 | ///
55 | /// The model file name for re-training
56 | ///
57 | public string RetrainModelFileName { get; set; }
58 |
59 | ///
60 | /// Debug level
61 | ///
62 | public int DebugLevel { get; set; }
63 |
64 | ///
65 | ///
66 | ///
67 | public uint HugeLexMemLoad { get; set; }
68 |
69 | ///
70 | /// cost factor, too big or small value may lead encoded model over tune or under tune
71 | ///
72 | public double CostFactor { get; set; }
73 |
74 | ///
75 | /// If we build vector quantization model for feature weights
76 | ///
77 | public bool BVQ { get; set; }
78 |
79 | public EncoderOptions()
80 | {
81 | MaxIteration = 100;
82 | MinFeatureFreq = 1;
83 | MinDifference = 0.0001;
84 | SlotUsageRateThreshold = 0.95;
85 | ThreadsNum = 1;
86 | RegType = CRFEncoder.REG_TYPE.L2;
87 | CostFactor = 1.0;
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/EncoderOptions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1b86a2ec7cd7cc741bee3f89ba85fede
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/EncoderTagger.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 170a115cff3a0a14bbf279496e82ac48
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/FeatureIdPair.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Encoder
7 | {
8 | public sealed class FeatureIdPair
9 | {
10 | public long Key;
11 | public int Value;
12 |
13 | public FeatureIdPair(long key, int value)
14 | {
15 | Key = key;
16 | Value = value;
17 | }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/FeatureIdPair.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2e425ea4698068a4db7a17b8dfae4a01
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/FeatureItem.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Encoder
7 | {
8 | public sealed class FeatureItem : IComparable
9 | {
10 | public string strFeature;
11 | public FeatureIdPair feaIdPair;
12 |
13 | public FeatureItem(string s, FeatureIdPair item)
14 | {
15 | strFeature = s;
16 | feaIdPair = item;
17 | }
18 |
19 | public int CompareTo(FeatureItem fi)
20 | {
21 | return StringComparer.Ordinal.Compare(strFeature, fi.strFeature);
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/FeatureItem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f8667588a1d4a564cb5a3d4c6ebf652c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/HugeFeatureLexicalDict.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 94dc435b08c4bf64399bfd609baac9e7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/IFeatureLexicalDict.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Encoder
7 | {
8 | public interface IFeatureLexicalDict
9 | {
10 | void Shrink(int freq);
11 | long GetOrAddId(string strFeature);
12 | long RegenerateFeatureId(CRFLite.Utils.BTreeDictionary old2new, long ysize);
13 | void GenerateLexicalIdList(out IList fea, out IList val);
14 | void Clear();
15 |
16 | long Size
17 | {
18 | get;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/IFeatureLexicalDict.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f7a4861f0daed8f429ccdd93721f22e1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/LBFGS.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5afe63f4fc7c18245854a5de4c70643a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/Mcsrch.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 475583d45ae04934284fcbfa250865b2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Encoder/ModelWriter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 451b2be296f219f43a1583a2c7d4e330
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/IGenerateFeature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite
7 | {
8 | public interface IGenerateFeature
9 | {
10 | bool Initialize();
11 | List> GenerateFeature(string strText);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/IGenerateFeature.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 16e739491224ba849b71775558c13c84
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Node.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite
7 | {
8 | public class Node
9 | {
10 | public int fid;
11 | public short x;
12 | public short y;
13 | public double alpha;
14 | public double beta;
15 | public double cost;
16 | public double bestCost;
17 | public Node prev;
18 |
19 | public List lpathList;
20 | public List rpathList;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Node.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a76f35005370c894aa76e394a4209a8f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Path.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite
7 | {
8 | public class Path
9 | {
10 | public int fid;
11 | public Node rnode;
12 | public Node lnode;
13 | public double cost;
14 |
15 | public Path()
16 | {
17 | rnode = null;
18 | lnode = null;
19 | cost = 0;
20 | }
21 |
22 | public void add(Node _lnode, Node _rnode)
23 | {
24 | lnode = _lnode;
25 | rnode = _rnode;
26 |
27 | lnode.rpathList.Add(this);
28 | rnode.lpathList.Add(this);
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Path.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8d26691c2bb79304392077cfc28ae1e3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Pool.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Concurrent;
3 | using System.Threading;
4 |
5 | namespace Bigtree.Algorithm.CRFLite
6 | {
7 | ///
8 | /// Represents general purpose pool that has no restrictions (e.g. grows if it's required)
9 | ///
10 | ///
11 | internal sealed class Pool
12 | {
13 | private int _totalCount;
14 | private readonly ConcurrentStack _container = new ConcurrentStack();
15 | private readonly Func, T> _creator;
16 | private readonly Action _cleaner;
17 |
18 | ///
19 | /// Initializes a new instance of the class.
20 | ///
21 | public Pool(Func, T> creator, Action cleaner = null)
22 | {
23 | _creator = creator;
24 | _cleaner = cleaner;
25 | }
26 |
27 | ///
28 | /// Gets item from pool or creates a new item
29 | ///
30 | ///
31 | public PoolItem GetOrCreate()
32 | {
33 | T item;
34 | if (_container.TryPop(out item))
35 | {
36 | return new PoolItem(item, _cleaner, this);
37 | }
38 | var newItem = _creator(this);
39 | if (newItem == null)
40 | {
41 | throw new ApplicationException("Unable to create new pool item");
42 | }
43 | Interlocked.Increment(ref _totalCount);
44 | return new PoolItem(newItem, _cleaner, this);
45 | }
46 |
47 | ///
48 | /// Returns amount of free items in the bag
49 | ///
50 | public int FreeCount { get { return _container.Count; } }
51 |
52 | ///
53 | /// Returns amount items created by pool
54 | ///
55 | public int TotalCount { get { return _totalCount; } }
56 |
57 | private void Return(T item)
58 | {
59 | _container.Push(item);
60 | }
61 |
62 | ///
63 | /// Pool item that is return when pool request is processed
64 | ///
65 | ///
66 | internal struct PoolItem : IDisposable
67 | {
68 | ///
69 | /// Pooled item
70 | ///
71 | public readonly T1 Item;
72 | private readonly Pool _owner;
73 | private readonly Action _cleaner;
74 |
75 | ///
76 | /// Creates a new pool item
77 | ///
78 | ///
79 | ///
80 | ///
81 | internal PoolItem(T1 item, Action cleaner, Pool owner)
82 | {
83 | Item = item;
84 | _cleaner = cleaner;
85 | _owner = owner;
86 | }
87 |
88 | ///
89 | /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
90 | ///
91 | public void Dispose()
92 | {
93 | _cleaner?.Invoke(Item);
94 | _owner.Return(Item);
95 | }
96 | }
97 | }
98 | }
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Pool.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 096d02aa4d637df47a9c22bc29268c64
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/SegDecoderTagger.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 602fc9a8bbd78394a9bf8a43da2e68fe
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Tagger.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 55d1e3f7949e82f44afcf1cf59ca1582
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ff783b2a9f4bf114c9d5220492e4d02f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 06ec92e1c34f9b044af0b57b91e5a75e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/BTreeDictionary.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8ec98be7f20f21648bf3a19283f431cd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/BigArray.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b5067966b4f07e140889531201026d10
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/DoubleArrayTrie.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e18e3b9a544f57f429fc908d54574237
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/FixedBigArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Utils
7 | {
8 | public sealed class FixedBigArray : BigArray where T : IComparable
9 | {
10 | public int lowBounding_;
11 |
12 | public override T this[long i]
13 | {
14 | get
15 | {
16 | long offset = (i - lowBounding_);
17 | int nBlock = (int)(offset >> moveBit);
18 | return arrList[nBlock][offset & (sizePerBlock - 1)];
19 | }
20 | set
21 | {
22 | long offset = (i - lowBounding_);
23 | int nBlock = (int)(offset >> moveBit);
24 | arrList[nBlock][offset & (sizePerBlock - 1)] = value;
25 | }
26 | }
27 |
28 |
29 |
30 | //construct big array
31 | //size is array's default length
32 | //lowBounding is the lowest bounding of the array
33 | public FixedBigArray(long size, int lowBounding)
34 | {
35 | size_ = size;
36 | lowBounding_ = lowBounding;
37 | arrList = new List();
38 |
39 | for (long i = 0; i < size_; i += sizePerBlock)
40 | {
41 | if (i + sizePerBlock < size_)
42 | {
43 | arrList.Add(new T[sizePerBlock]);
44 | }
45 | else
46 | {
47 | arrList.Add(new T[size_ - i]);
48 | }
49 | }
50 | }
51 |
52 |
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/FixedBigArray.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 19fd28940043cb243b5d042ad5ae9549
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/LimitedConcurrencyLevelTaskScheduler.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 864e97975116c134a9e1a42861e8d283
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/MD5.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5809070fcdffc644d82e72053ab9e96e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/VarBigArray.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.CRFLite.Utils
7 | {
8 | public sealed class VarBigArray : BigArray where T : IComparable
9 | {
10 | long blockSizeInTotal_;
11 | private object ll = new object();
12 |
13 | public override T this[long offset]
14 | {
15 | get
16 | {
17 | if (offset >= size_)
18 | {
19 | //resize array size, it need to be synced,
20 | //for high performance, we use double check to avoid useless resize call and save memory
21 | lock (ll)
22 | {
23 | if (offset >= size_)
24 | {
25 | Resize(offset + 1);
26 | }
27 | }
28 | }
29 |
30 | long nBlock = offset >> moveBit;
31 | return arrList[(int)nBlock][offset & (sizePerBlock-1)];
32 | }
33 | set
34 | {
35 | if (offset >= size_)
36 | {
37 | //resize array size, it need to be synced,
38 | //for high performance, we use double check to avoid useless resize call and save memory
39 | lock (ll)
40 | {
41 | if (offset >= size_)
42 | {
43 | Resize(offset + 1);
44 | }
45 | }
46 | }
47 |
48 | long nBlock = offset >> moveBit;
49 | arrList[(int)nBlock][offset & (sizePerBlock-1)] = value;
50 | }
51 | }
52 |
53 |
54 |
55 | private void Resize(long new_size)
56 | {
57 | while (blockSizeInTotal_ <= new_size)
58 | {
59 | arrList.Add(new T[sizePerBlock]);
60 | blockSizeInTotal_ += sizePerBlock;
61 | }
62 |
63 | size_ = new_size;
64 | }
65 |
66 | //construct variable size big array
67 | //size is array's default length
68 | //lowBounding is the lowest bounding of the array
69 | //when accessing the position which is outer bounding, the big array will be extend automatically.
70 | public VarBigArray(long size)
71 | {
72 | size_ = size;
73 | arrList = new List();
74 |
75 | for (blockSizeInTotal_ = 0; blockSizeInTotal_ < size_;
76 | blockSizeInTotal_ += sizePerBlock)
77 | {
78 | arrList.Add(new T[sizePerBlock]);
79 | }
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/VarBigArray.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 48e728828b8e31d43ab24549026d6c09
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/CRFLite/Utils/VectorQuantization.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0e915f6cbc7a4c4409e08152fc8b14fa
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b1cbe92d79bb0c0419efed81041df3e1
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/DataReader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.DecisionTree
8 | {
9 | public class DataReader
10 | {
11 | public TrainingData Read(string filePath)
12 | {
13 | var data = new TrainingData { };
14 | string[] lines = File.ReadAllLines(filePath);
15 | data.Rows = new string[lines.Length - 1][];
16 |
17 | for(int rowIndex = 0; rowIndex < lines.Length; rowIndex++)
18 | {
19 | string line = lines[rowIndex];
20 | // Columns
21 | if (rowIndex == 0)
22 | {
23 | data.Columns = line.Split(';').Where(x => !String.IsNullOrEmpty(x)).ToArray();
24 | }
25 | else
26 | {
27 | data.Rows[rowIndex - 1] = line.Split(';').Where(x => !String.IsNullOrEmpty(x)).ToArray();
28 | }
29 | }
30 |
31 | return data;
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/DataReader.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4212662a664710c4699db4b7a5d851f9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/NodeAttribute.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Data;
3 | using System.Linq;
4 |
5 | namespace Bigtree.Algorithm.DecisionTree
6 | {
7 | public class NodeAttribute
8 | {
9 | public NodeAttribute(string name, List differentAttributenames)
10 | {
11 | Name = name;
12 | DifferentAttributeNames = differentAttributenames;
13 | }
14 |
15 | public string Name { get; }
16 |
17 | public List DifferentAttributeNames { get; }
18 |
19 | public double InformationGain { get; set; }
20 | }
21 | }
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/NodeAttribute.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7cde9a16f2d474c439eea2de676d402d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/README.rst:
--------------------------------------------------------------------------------
1 | The algorithm builds a decision tree from a sample of data.
2 | The training phase results in a decision trees, which will be used to classify future input data.
3 | Every leaf represents a value of the result class and a non-leaf node represents a decision node.
4 |
5 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/README.rst.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0213e18e05e975440b65bd46bd1765a6
3 | DefaultImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/TrainingData.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.DecisionTree
6 | {
7 | public class TrainingData
8 | {
9 | public String[] Columns { get; set; }
10 |
11 | public String[][] Rows { get; set; }
12 |
13 | public int Index(string column)
14 | {
15 | for(int i = 0; i < Columns.Length; i++)
16 | {
17 | if (Columns[i] == column) return i;
18 | }
19 |
20 | return -1;
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/TrainingData.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 11930b25e585e1343a38ea5f1783ec55
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/Tree.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 18067ab338386e9488f757a4d1956efa
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/TreeNode.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 | namespace Bigtree.Algorithm.DecisionTree
4 | {
5 | public class TreeNode
6 | {
7 | public TreeNode(string name, int tableIndex, NodeAttribute nodeAttribute, string edge)
8 | {
9 | Name = name;
10 | TableIndex = tableIndex;
11 | NodeAttribute = nodeAttribute;
12 | ChildNodes = new List();
13 | Edge = edge;
14 | }
15 |
16 | public TreeNode(bool isleaf, string name, string edge)
17 | {
18 | IsLeaf = isleaf;
19 | Name = name;
20 | Edge = edge;
21 | }
22 |
23 | public string Name { get; }
24 |
25 | public string Edge { get; }
26 |
27 | public NodeAttribute NodeAttribute { get; }
28 |
29 | public List ChildNodes { get; }
30 |
31 | public int TableIndex { get; }
32 |
33 | public bool IsLeaf { get; }
34 | }
35 | }
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/DecisionTree/TreeNode.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 884da29389ec59247a7ec44432934af1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Estimators.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ef81c748e3060cb439e474c90c1ed5b5
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Estimators/AdditiveSmoothing.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Bigtree.Algorithm
3 | * Copyright (C) 2018 Haiping Chen
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 | using Bigtree.Algorithm.Statistics;
20 | using System;
21 | using System.Collections.Generic;
22 | using System.Linq;
23 | using System.Text;
24 |
25 | namespace Bigtree.Algorithm.Estimators
26 | {
27 | ///
28 | /// Lidstone smoothing is a technique used to smooth categorical data.
29 | /// In statistics, it's called additive smoothing or Laplace smoothing.
30 | /// Given an observation x = (x1, …, xd) from a multinomial distribution with N trials, a "smoothed" version of the data gives the estimator.
31 | /// https://en.wikipedia.org/wiki/Additive_smoothing
32 | /// Used as Multinomial Naive Bayes
33 | ///
34 | public class AdditiveSmoothing : IEstimator
35 | {
36 | ///
37 | /// 1 > α > 0 is the smoothing parameter is Lidstone
38 | /// α = 1 is Laplace
39 | /// α = 0 no smoothing
40 | ///
41 | public double Alpha { get; set; }
42 |
43 | ///
44 | /// Probability
45 | ///
46 | /// distribution
47 | /// sample value
48 | ///
49 | public double Prob(List dist, string sample)
50 | {
51 | if(Alpha == 0)
52 | {
53 | Alpha = 0.5D;
54 | }
55 |
56 | // observation x = (x1, ..., xd)
57 | var p = dist.Find(f => f.Value == sample);
58 | int x = p == null ? 0 : p.Freq;
59 |
60 | // N trials
61 | int _N = dist.Sum(f => f.Freq);
62 |
63 | int _d = dist.Count;
64 |
65 | return (x + Alpha) / (_N + Alpha * _d);
66 | }
67 |
68 | public double Prob(List> dist, string sample)
69 | {
70 | if (Alpha == 0)
71 | {
72 | Alpha = 0.5D;
73 | }
74 |
75 | // observation x = (x1, ..., xd)
76 | var p = dist.Find(f => f.Item1 == sample);
77 | double x = p == null ? 0D : p.Item2;
78 |
79 | // N trials
80 | double _N = dist.Sum(f => f.Item2);
81 |
82 | int _d = dist.Count;
83 |
84 | return (x + Alpha) / (_N + Alpha * _d);
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Estimators/AdditiveSmoothing.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: dba047e1430ec624da6cbb0a80df0265
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Estimators/IEstimator.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.Statistics;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Estimators
7 | {
8 | public interface IEstimator
9 | {
10 | double Prob(List dist, string sample);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Estimators/IEstimator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3fe58fdfa11e9c24c8a4c66d5fee60f7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f336faa699a31274bb8d6dc1a5b88fee
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Reduce.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Extensions
7 | {
8 | public static partial class IListExtensions
9 | {
10 | ///
11 | /// equivalent reduce function in Python
12 | /// https://docs.python.org/3/library/functools.html?highlight=reduce#functools.reduce
13 | ///
14 | ///
15 | ///
16 | ///
17 | ///
18 | public static TAccumulate Reduce(this IList source, Func func)
19 | {
20 | return source.Skip(1).Aggregate(source[0], func);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Reduce.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 54df00b420d282845be494be285da001
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Shuffle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Security.Cryptography;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Extensions
7 | {
8 | public static partial class IListExtensions
9 | {
10 | public static void Shuffle(this IList list)
11 | {
12 | var rng = new Random();
13 | var count = list.Count;
14 | while (count > 1)
15 | {
16 | count--;
17 | var k = rng.Next(count + 1);
18 | var value = list[k];
19 | list[k] = list[count];
20 | list[count] = value;
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Shuffle.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3f556ba314b99de4f9ed1e65813dfb8a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Split.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Extensions
7 | {
8 | public static partial class IListExtensions
9 | {
10 | ///
11 | /// Split dataset to training and test part.
12 | ///
13 | ///
14 | ///
15 | /// must between 0 and 1
16 | ///
17 | public static Tuple, List> Split(this IList list, decimal percentage)
18 | {
19 | int boundary = int.Parse(Math.Floor(list.Count * percentage).ToString());
20 |
21 | return new Tuple, List>(list.Take(boundary).ToList(), list.Skip(boundary).ToList());
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Extensions/Split.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a91ae148408314d44ac2af6283b9998a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Features.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 90abf76c07b1fb946acab42dd0855c97
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Features/Feature.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.Features
6 | {
7 | public class Feature
8 | {
9 | public string Name { get; set; }
10 | public string Value { get; set; }
11 |
12 | public Feature(string name, string value)
13 | {
14 | Name = name;
15 | Value = value;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Features/Feature.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 953b267df3de7de41875e5d8e76943c5
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Features/FeaturesDistribution.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.Statistics;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.Features
7 | {
8 | public class FeaturesDistribution
9 | {
10 | public string Label { get; set; }
11 |
12 | public string FeatureName { get; set; }
13 |
14 | public List FeatureValues { get; set; }
15 |
16 | public override string ToString()
17 | {
18 | return $"{Label} {FeatureName} {FeatureValues.Count}";
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Features/FeaturesDistribution.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6872dfb9770cdc744b9fe82897977df4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 33a0ec96ace022540949261358b4f4cc
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/ForwardBackwardAlgorithm.Log.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3e85601b44612a24492b54b36dbc32be
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/ForwardBackwardAlgorithm.Log.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2c7690d75a2a1c443b3b631a069457aa
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/ForwardBackwardAlgorithm.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bc9e4d9e2c01f9c4d94b3057f071a796
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 84315dd9a1f5cd644a7ce46660f3b7a9
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/Codification.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Helpers
7 | {
8 | public class Codification
9 | {
10 | protected int mSymbolCount = 0;
11 | protected Dictionary mSymbolIdTable = new Dictionary();
12 | protected List mIdSymbolTable = new List();
13 |
14 | public int SymbolCount
15 | {
16 | get { return mSymbolCount; }
17 | }
18 |
19 | public Codification(string[][] phrases)
20 | {
21 | foreach (string[] row in phrases)
22 | {
23 | Parse(row);
24 | }
25 | }
26 |
27 | public string[] Translate(int[] id_list)
28 | {
29 | int N = id_list.Length;
30 | string[] phrases = new string[N];
31 | for (int i = 0; i < N; ++i)
32 | {
33 | phrases[i] = Translate(id_list[i]);
34 | }
35 | return phrases;
36 | }
37 |
38 | public string[][] Translate(int[][] id_matrix)
39 | {
40 | int N1 = id_matrix.Length;
41 | string[][] phrases = new string[N1][];
42 | for (int i = 0; i < N1; ++i)
43 | {
44 | phrases[i] = Translate(id_matrix[i]);
45 | }
46 | return phrases;
47 | }
48 |
49 | public int[] Translate(string[] phrases)
50 | {
51 | int N = phrases.Length;
52 | int[] id_list = new int[N];
53 | for (int i = 0; i < N; ++i)
54 | {
55 | id_list[i] = Translate(phrases[i]);
56 | }
57 |
58 | return id_list;
59 | }
60 |
61 | public int[][] Translate(string[][] phrases)
62 | {
63 | int N1=phrases.Length;
64 | int[][] id_matrix = new int[N1][];
65 | for (int i = 0; i < N1; ++i)
66 | {
67 | id_matrix[i] = Translate(phrases[i]);
68 | }
69 | return id_matrix;
70 | }
71 |
72 | public int Translate(string word)
73 | {
74 | if(mSymbolIdTable.ContainsKey(word))
75 | {
76 | return mSymbolIdTable[word];
77 | }
78 | else
79 | {
80 | throw new ArgumentOutOfRangeException(string.Format("Symbol {0} is not found in the codification", word));
81 | }
82 | }
83 |
84 | public string Translate(int id)
85 | {
86 | if (mIdSymbolTable.Count > id)
87 | {
88 | return mIdSymbolTable[id];
89 | }
90 | else
91 | {
92 | throw new ArgumentOutOfRangeException(string.Format("Symbol ID {0} is not found in the codification", id));
93 | }
94 | }
95 |
96 | public void Parse(string[] phrases)
97 | {
98 | foreach (string word in phrases)
99 | {
100 | if (!mSymbolIdTable.ContainsKey(word))
101 | {
102 | mSymbolIdTable[word] = mSymbolCount;
103 | mIdSymbolTable.Add(word);
104 |
105 | mSymbolCount++;
106 | }
107 | }
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/Codification.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7d3644eeb0dda3046bc37f7d96fb1422
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/DiagnosticsHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Helpers
7 | {
8 | public class DiagnosticsHelper
9 | {
10 | public static void Assert(bool condition)
11 | {
12 | System.Diagnostics.Debug.Assert(condition);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/DiagnosticsHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6a002cbfe63ce944abf9ef1726e41ef9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/MathHelper.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.Helpers
8 | {
9 | public class MathHelper
10 | {
11 | //static Random mRandom;
12 |
13 | public static void SetupGenerator(int seed)
14 | {
15 | //mRandom = new Random(seed);
16 | DistributionModel.SetSeed((uint)seed);
17 | }
18 |
19 | public static double LogProbabilityFunction(DistributionModel distrubiton, double value)
20 | {
21 | return distrubiton.LogProbabilityFunction(value);
22 | }
23 |
24 | public static double NextDouble()
25 | {
26 | //if (mRandom == null)
27 | //{
28 | // mRandom = new Random();
29 | //}
30 | //return mRandom.NextDouble();
31 | return DistributionModel.GetUniform();
32 | }
33 |
34 | public static double[] GetRow(double[,] matrix, int row_index)
35 | {
36 | int column_count = matrix.GetLength(1);
37 | double[] row = new double[column_count];
38 |
39 | for (int column_index = 0; column_index < column_count; ++column_index)
40 | {
41 | row[column_index] = matrix[row_index, column_index];
42 | }
43 | return row;
44 | }
45 |
46 | public static int Random(double[] probabilities)
47 | {
48 | double uniform = NextDouble();
49 |
50 | double cumulativeSum = 0;
51 |
52 | // Use the probabilities to partition the [0,1] interval
53 | // and check inside which range the values fall into.
54 |
55 | for (int i = 0; i < probabilities.Length; i++)
56 | {
57 | cumulativeSum += probabilities[i];
58 |
59 | if (uniform < cumulativeSum)
60 | return i;
61 | }
62 |
63 | throw new InvalidOperationException("Generated value is not between 0 and 1.");
64 | }
65 |
66 | public static T[][] Split(T[] vector, int size)
67 | {
68 | int n = vector.Length / size;
69 | T[][] r = new T[n][];
70 | for (int i = 0; i < n; i++)
71 | {
72 | T[] ri = r[i] = new T[size];
73 | for (int j = 0; j < size; j++)
74 | ri[j] = vector[j * n + i];
75 | }
76 | return r;
77 | }
78 |
79 | public static T[] Concatenate(T[][] matrix)
80 | {
81 | List vector = new List();
82 | for (int i = 0; i < matrix.Length; ++i)
83 | {
84 | T[] row = matrix[i];
85 | vector.AddRange(row);
86 | }
87 | return vector.ToArray();
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/MathHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 379d81801722bd142b73f9abc3a8540f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/ValidationHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Helpers
7 | {
8 | public class ValidationHelper
9 | {
10 | public static void ValidateObservationDb(int[][] observations_db, int inclusive_lower_bound, int exclusive_upper_bound)
11 | {
12 | int K = observations_db.Length;
13 | for (int k = 0; k < K; ++k)
14 | {
15 | int[] observations = observations_db[k];
16 | int T = observations.Length;
17 | for (int t = 0; t < T; ++t)
18 | {
19 | if (observations[t] >= exclusive_upper_bound || observations[t] < inclusive_lower_bound)
20 | {
21 | string error_message = string.Format("observation sequence contains symbol outside the range [{0}-{1})", inclusive_lower_bound, exclusive_upper_bound);
22 | throw new ArgumentOutOfRangeException("observations_db", error_message);
23 | }
24 | }
25 | }
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Helpers/ValidationHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fa11b332e6a695d49998f6c6a82fce66
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovClassifier.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0d1c2c885babe304ab4fa51b78bf7bb7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovClassifier.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 457cb7f9dae67f84299291fc2fda0264
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovModel.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: df36e0710bf9c5849ba95709c4802a99
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovModel.Generate.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
6 | using Bigtree.Algorithm.HiddenMarkovModel.MathHelpers;
7 |
8 | namespace Bigtree.Algorithm.HiddenMarkovModel
9 | {
10 | public partial class HiddenMarkovModel
11 | {
12 | public int[] Generate(int samples)
13 | {
14 | int[] path;
15 | double logLikelihood;
16 | return Generate(samples, out path, out logLikelihood);
17 | }
18 |
19 | ///
20 | /// Generates a random vector of observations from the model.
21 | ///
22 | ///
23 | /// The number of samples to generate.
24 | /// The log-likelihood of the generated observation sequence.
25 | /// The Viterbi path of the generated observation sequence.
26 | ///
27 | ///
28 | /// An usage example is available at the documentation page.
29 | ///
30 | ///
31 | /// A random vector of observations drawn from the model.
32 | ///
33 | public int[] Generate(int samples, out int[] path, out double logLikelihood)
34 | {
35 | double[] transitions = mLogProbabilityVector;
36 | double[] emissions;
37 |
38 | int[] observations = new int[samples];
39 | logLikelihood = Double.NegativeInfinity;
40 | path = new int[samples];
41 |
42 |
43 | // For each observation to be generated
44 | for (int t = 0; t < observations.Length; t++)
45 | {
46 | // Navigate randomly on one of the state transitions
47 | int state = MathHelper.Random(LogHelper.Exp(transitions));
48 |
49 | // Generate a sample for the state
50 | emissions = MathHelper.GetRow(mLogEmissionMatrix, state);
51 |
52 | int symbol = MathHelper.Random(LogHelper.Exp(emissions));
53 |
54 | // Store the sample
55 | observations[t] = symbol;
56 | path[t] = state;
57 |
58 | // Compute log-likelihood up to this point
59 | logLikelihood = LogHelper.LogSum(logLikelihood, transitions[state] + emissions[symbol]);
60 |
61 | // Continue sampling
62 | transitions = MathHelper.GetRow(mLogTransitionMatrix, state);
63 | }
64 |
65 | return observations;
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovModel.Generate.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 2944aad76a81d0e46b58536a8816d7e2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovModel.Predict.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c13271715f2cc9b48b6de7bd8a32cb99
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/HiddenMarkovModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fec3fd67bccbe77468a27283dc3c50b3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 855605ed1415fc64fa5bf375fee99350
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f784ba4024c4e9c40800630fb3e4a337
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/HiddenMarkovClassifierLearning.Continuous.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Threading;
7 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
8 | using Bigtree.Algorithm.HiddenMarkovModel.Learning.Unsupervised;
9 |
10 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Supervised
11 | {
12 | public partial class HiddenMarkovClassifierLearning
13 | {
14 | public double ComputeError(double[][] inputs, int[] outputs)
15 | {
16 | int errors = 0;
17 | Parallel.For(0, inputs.Length, i =>
18 | {
19 | int expectedOutput = outputs[i];
20 | int actualOutput = mClassifier.Compute(inputs[i]);
21 |
22 | if (expectedOutput != actualOutput)
23 | {
24 | Interlocked.Increment(ref errors);
25 | }
26 | });
27 |
28 | return errors / (double)inputs.Length;
29 | }
30 |
31 | public double Run(double[][] observations_db, int[] class_labels)
32 | {
33 | int class_count = mClassifier.ClassCount;
34 | double[] logLikelihood = new double[class_count];
35 |
36 | int K=class_labels.Length;
37 |
38 | DiagnosticsHelper.Assert(observations_db.Length==K);
39 |
40 | int[] class_label_counts = new int[class_count];
41 |
42 | Parallel.For(0, class_count, i =>
43 | {
44 | IUnsupervisedLearning teacher = mAlgorithmEntity(i);
45 |
46 | List match_record_index_set = new List();
47 | for (int k = 0; k < K; ++k)
48 | {
49 | if (class_labels[k] == i)
50 | {
51 | match_record_index_set.Add(k);
52 | }
53 | }
54 |
55 | int K2 = match_record_index_set.Count;
56 |
57 | class_label_counts[i] = K2;
58 |
59 | if (K2 != 0)
60 | {
61 | double[][] observations_subdb = new double[K2][];
62 | for (int k = 0; k < K2; ++k)
63 | {
64 | int record_index = match_record_index_set[k];
65 | observations_subdb[k] = observations_db[record_index];
66 | }
67 |
68 |
69 | logLikelihood[i] = teacher.Run(observations_subdb);
70 | }
71 |
72 | });
73 |
74 | if (mEmpirical)
75 | {
76 | for (int i = 0; i < class_count; i++)
77 | {
78 | mClassifier.Priors[i] = (double)class_label_counts[i] / K;
79 | }
80 | }
81 |
82 | //if (mRejection)
83 | //{
84 | // mClassifier.Threshold = Threshold();
85 | //}
86 |
87 | return logLikelihood.Sum();
88 | }
89 | }
90 | }
91 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/HiddenMarkovClassifierLearning.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4e4a4c206f006744c860afe0a9d14828
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/HiddenMarkovClassifierLearning.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a2448f3c6f983524ab4bfe32c71ef508
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/MaximumLikelihoodLearning.Continuous.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
6 | using Bigtree.Algorithm.HiddenMarkovModel.MathHelpers;
7 |
8 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Supervised
9 | {
10 | public partial class MaximumLikelihoodLearning
11 | {
12 | public double Run(double[][] observations_db, int[][] path_db)
13 | {
14 | int K = observations_db.Length;
15 |
16 | DiagnosticsHelper.Assert(path_db.Length == K);
17 |
18 | int N = mModel.StateCount;
19 | int M = mModel.SymbolCount;
20 |
21 | int[] initial=new int[N];
22 | int[,] transition_matrix = new int[N, N];
23 |
24 | for (int k = 0; k < K; ++k)
25 | {
26 | initial[path_db[k][0]]++;
27 | }
28 |
29 | int T = 0;
30 |
31 | for (int k = 0; k < K; ++k)
32 | {
33 | int[] path = path_db[k];
34 | double[] observations = observations_db[k];
35 |
36 | T = path.Length;
37 | for (int t = 0; t < T-1; ++t)
38 | {
39 | transition_matrix[path[t], path[t + 1]]++;
40 | }
41 | }
42 |
43 |
44 | // 3. Count emissions for each state
45 | List[] clusters = new List[N];
46 | for (int i = 0; i < N; i++)
47 | clusters[i] = new List();
48 |
49 | // Count symbol frequencies per state
50 | for (int k = 0; k < K; k++)
51 | {
52 | for (int t = 0; t < path_db[k].Length; t++)
53 | {
54 | int state = path_db[k][t];
55 | double symbol = observations_db[k][t];
56 |
57 | clusters[state].Add(symbol);
58 | }
59 | }
60 |
61 |
62 | // Estimate probability distributions
63 | for (int i = 0; i < N; i++)
64 | {
65 | if (clusters[i].Count > 0)
66 | {
67 | mModel.EmissionModels[i].Process(clusters[i].ToArray());
68 | }
69 | }
70 |
71 | if (mUseLaplaceRule)
72 | {
73 | for (int i = 0; i < N; ++i)
74 | {
75 | initial[i]++;
76 |
77 | for (int j = 0; j < N; ++j)
78 | {
79 | transition_matrix[i, j]++;
80 | }
81 | }
82 | }
83 |
84 | int initial_sum = initial.Sum();
85 | int[] transition_sum_vec = Sum(transition_matrix, 1);
86 |
87 | for (int i = 0; i < N; ++i)
88 | {
89 | mModel.LogProbabilityVector[i] = System.Math.Log(initial[i] / (double)initial_sum);
90 | }
91 |
92 | for (int i = 0; i < N; ++i)
93 | {
94 | double transition_sum = (double)transition_sum_vec[i];
95 | for (int j = 0; j < N; ++j)
96 | {
97 | mModel.LogTransitionMatrix[i, j] = System.Math.Log(transition_matrix[i, j] / transition_sum);
98 | }
99 | }
100 |
101 | double logLikelihood = double.NegativeInfinity;
102 | for (int i = 0; i < observations_db.Length; i++)
103 | logLikelihood = LogHelper.LogSum(logLikelihood, mModel.Evaluate(observations_db[i]));
104 |
105 | return logLikelihood;
106 |
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/MaximumLikelihoodLearning.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 58d1fe0138de2f4408b67712a48b1591
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Supervised/MaximumLikelihoodLearning.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4ec07b8b099c9c043bc26e1496875b23
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: da2cde465d5530d43920a17b1f46a5c8
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/BaumWelchLearning.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 07ccd1e4d508847478e1e440756bcfd8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/BaumWelchLearning.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 100bf1ebfc7231e4eac6daa9fdf1c22a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/IUnsupervisedLearning.Continuous.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Unsupervised
7 | {
8 | public partial interface IUnsupervisedLearning
9 | {
10 | double Run(double[][] observations_db);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/IUnsupervisedLearning.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4a818fd7701465e4290cf7868c025b1c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/IUnsupervisedLearning.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Unsupervised
7 | {
8 | public partial interface IUnsupervisedLearning
9 | {
10 | double Run(int[][] observations_db);
11 | HiddenMarkovModel Model
12 | {
13 | get;
14 | set;
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/IUnsupervisedLearning.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3237fa289b83b8f4aa7e9d0010f2d302
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/ViterbiLearning.Continuous.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.MathHelpers;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Unsupervised
8 | {
9 | public partial class ViterbiLearning
10 | {
11 | public double Run(double[][] observations_db)
12 | {
13 |
14 | int K = observations_db.Length;
15 |
16 | double currLogLikelihood = Double.NegativeInfinity;
17 |
18 | for (int k = 0; k < K; ++k)
19 | {
20 | currLogLikelihood = LogHelper.LogSum(currLogLikelihood, mModel.Evaluate(observations_db[k]));
21 | }
22 |
23 | double oldLogLikelihood = -1;
24 | double deltaLogLikelihood = -1;
25 | int iteration = 0;
26 | do{
27 | oldLogLikelihood=currLogLikelihood;
28 |
29 | int[][] paths_db = new int[K][];
30 | for(int k=0; k < K; ++k)
31 | {
32 | paths_db[k]=mModel.Decode(observations_db[k]);
33 | }
34 |
35 | mMaximumLikelihoodLearner.Run(observations_db, paths_db);
36 |
37 | currLogLikelihood = double.NegativeInfinity;
38 | for (int k = 0; k < K; ++k)
39 | {
40 | currLogLikelihood = LogHelper.LogSum(currLogLikelihood, mModel.Evaluate(observations_db[k]));
41 | }
42 |
43 | deltaLogLikelihood = System.Math.Abs(currLogLikelihood - oldLogLikelihood);
44 | iteration++;
45 | }while(!ShouldTerminate(deltaLogLikelihood, iteration));
46 |
47 | return currLogLikelihood;
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/ViterbiLearning.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1b38b617b90fbb74b9e1cd23a12b7829
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/ViterbiLearning.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.Learning.Supervised;
2 | using Bigtree.Algorithm.HiddenMarkovModel.MathHelpers;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Bigtree.Algorithm.HiddenMarkovModel.Learning.Unsupervised
9 | {
10 | public partial class ViterbiLearning : IUnsupervisedLearning
11 | {
12 | protected MaximumLikelihoodLearning mMaximumLikelihoodLearner;
13 | protected HiddenMarkovModel mModel;
14 | protected int mIterations = 0;
15 | protected double mTolerance = 0.001;
16 |
17 | public HiddenMarkovModel Model
18 | {
19 | get { return mModel; }
20 | set { mModel = value; }
21 | }
22 |
23 | public int Iterations
24 | {
25 | get { return mIterations; }
26 | set { mIterations = value; }
27 | }
28 |
29 | public double Tolerance
30 | {
31 | get { return mTolerance; }
32 | set { mTolerance = value; }
33 | }
34 |
35 | public bool UseLaplaceRule
36 | {
37 | get
38 | {
39 | return mMaximumLikelihoodLearner.UseLaplaceRule;
40 | }
41 | set
42 | {
43 | mMaximumLikelihoodLearner.UseLaplaceRule = value;
44 | }
45 | }
46 |
47 | public ViterbiLearning(HiddenMarkovModel hmm)
48 | {
49 | mModel = hmm;
50 | mMaximumLikelihoodLearner = new MaximumLikelihoodLearning(hmm);
51 | }
52 |
53 | public double Run(int[][] observations_db)
54 | {
55 |
56 | int K = observations_db.Length;
57 |
58 | double currLogLikelihood = Double.NegativeInfinity;
59 |
60 | for (int k = 0; k < K; ++k)
61 | {
62 | currLogLikelihood = LogHelper.LogSum(currLogLikelihood, mModel.Evaluate(observations_db[k]));
63 | }
64 |
65 | double oldLogLikelihood = -1;
66 | double deltaLogLikelihood = -1;
67 | int iteration = 0;
68 | do{
69 | oldLogLikelihood=currLogLikelihood;
70 |
71 | int[][] paths_db = new int[K][];
72 | for(int k=0; k < K; ++k)
73 | {
74 | paths_db[k]=mModel.Decode(observations_db[k]);
75 | }
76 |
77 | mMaximumLikelihoodLearner.Run(observations_db, paths_db);
78 |
79 | currLogLikelihood = double.NegativeInfinity;
80 | for (int k = 0; k < K; ++k)
81 | {
82 | currLogLikelihood = LogHelper.LogSum(currLogLikelihood, mModel.Evaluate(observations_db[k]));
83 | }
84 |
85 | deltaLogLikelihood = System.Math.Abs(currLogLikelihood - oldLogLikelihood);
86 | iteration++;
87 | }while(!ShouldTerminate(deltaLogLikelihood, iteration));
88 |
89 | return currLogLikelihood;
90 | }
91 |
92 | protected bool ShouldTerminate(double change, int iteration)
93 | {
94 | if (change <= mTolerance)
95 | {
96 | return true;
97 | }
98 |
99 | if (mIterations > 0 && mIterations <= iteration)
100 | {
101 | return true;
102 | }
103 |
104 | return false;
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Learning/Unsupervised/ViterbiLearning.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e99be529eae6c3146abdddbc666c93cc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: db5853ed9312b344daa8f58ace71ad1f
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/Factorial.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 5461abb1e20c9fe4cbfa2c15e71bbf11
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/Gamma.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: be56e91b2554aed42a0f9797c42c7530
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/LogHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a9efdd266f503274780876b8a699715d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/MergeSort.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathHelpers
7 | {
8 | ///
9 | /// Ascending sort by merge sort
10 | ///
11 | public class MergeSort
12 | {
13 | public static void Sort(double[] a)
14 | {
15 | double[] aux = new double[a.Length];
16 | int lo = 0;
17 | int hi = a.Length - 1;
18 | Sort(a, aux, lo, hi);
19 | }
20 |
21 | public static void Sort(double[] a, double[] aux, int lo, int hi)
22 | {
23 | if (hi - lo < 5)
24 | {
25 | SelectionSort(a, lo, hi);
26 | return;
27 | }
28 | int mid = (hi + lo) / 2;
29 | Sort(a, aux, lo, mid, hi);
30 | }
31 |
32 | public static void Sort(double[] a, double[] aux, int lo, int mid, int hi)
33 | {
34 | Sort(a, aux, lo, mid);
35 | Sort(a, aux, mid + 1, hi);
36 | int i = lo, j = mid + 1;
37 | for (int k = lo; k <= hi; ++k)
38 | {
39 | if (i <= mid && (j > hi || a[i] < a[j]))
40 | {
41 | aux[k] = a[i++];
42 | }
43 | else
44 | {
45 | aux[k] = a[j++];
46 | }
47 | }
48 |
49 | for (int k = lo; k <= hi; ++k)
50 | {
51 | a[k] = aux[k];
52 | }
53 |
54 | }
55 |
56 | private static void SelectionSort(double[] a, int lo, int hi)
57 | {
58 | for (int i = lo; i <= hi; ++i)
59 | {
60 | double c = a[i];
61 | int jpi = i;
62 | for (int j = i + 1; j <= hi; ++j)
63 | {
64 | if (c > a[j])
65 | {
66 | jpi = j;
67 | c = a[j];
68 | }
69 | }
70 | if (i != jpi)
71 | {
72 | double temp = a[i];
73 | a[i] = a[jpi];
74 | a[jpi] = temp;
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/MergeSort.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1c4066a48c7febb4688db494042c99db
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/PolynomialHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathHelpers
7 | {
8 | public class PolynomialHelper
9 | {
10 | ///
11 | /// Evaluates polynomial of degree N
12 | ///
13 | ///
14 | public static double Polevl(double x, double[] coef, int n)
15 | {
16 | double ans;
17 |
18 | ans = coef[0];
19 |
20 | for (int i = 1; i <= n; i++)
21 | ans = ans * x + coef[i];
22 |
23 | return ans;
24 | }
25 |
26 | ///
27 | /// Evaluates polynomial of degree N with assumption that coef[N] = 1.0
28 | ///
29 | ///
30 | public static double P1evl(double x, double[] coef, int n)
31 | {
32 | double ans;
33 |
34 | ans = x + coef[0];
35 |
36 | for (int i = 1; i < n; i++)
37 | ans = ans * x + coef[i];
38 |
39 | return ans;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathHelpers/PolynomialHelper.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f2c7e8a3b3818de49ab6ce0f2f352327
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a6a05e7c1c7959b4088458ed54186da2
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Constants.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils
7 | {
8 | public class Constants
9 | {
10 | /// Maximum log on the machine.
11 | public const double LogMax = 7.09782712893383996732E2;
12 |
13 | /// Square root of 2: sqrt(2).
14 | public const double Sqrt2 = 1.4142135623730950488016887;
15 |
16 | /// Square root of twice number pi: sqrt(2*π).
17 | public const double Sqrt2PI = 2.50662827463100050242E0;
18 |
19 |
20 | /// Log of number pi: log(pi).
21 | public const double LogPI = 1.14472988584940017414;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Constants.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b15813bc88c19024aa96f1ba9e12924b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c93b69d8abb219f4a845d00822a1606e
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/Binomial.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 41d21abeaf0aef44a9df2a5c90959c82
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/ChiSquare.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0e1903dbfe730c346b90f76453884281
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/DistributionModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3cec0924666e81f4b85480fa55cf51b3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/Erlang.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a12de36ea3289c747a334235fab6898b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/Exponential.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: feb7ada2ebd6a7a4fb84c4544292fc4e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/FDistribution.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b7e5efb89ea5d164eb9d26ce9de24a2b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/Gaussian.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 967795b2806302f4193b343db6bc697b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/LogNormal.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e5fd4aca813b5784e958dfffdcaabd73
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/MultivariateDistributionModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution
7 | {
8 | public abstract class MultivariateDistributionModel : DistributionModel
9 | {
10 | protected int mDimension = 1;
11 | public int Dimension
12 | {
13 | get { return mDimension; }
14 | set { mDimension = value; }
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/MultivariateDistributionModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cd0196c72a5c66e46909c557cc4325b5
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/Poisson.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 111309c21f61ff64c9a52d4e6ebbe727
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Distribution/StudentT.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3f0693e9fd7b0bd4c9534a9cabd8786f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/LinearAlgebra.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 59c8cb2e0695b5b4caddd144b99c2251
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/LinearAlgebra/MatrixOp.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6e1f6b0aaca6a5941a8288a88efcb8b7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 44d6dede62d356747bdd3398509bc742
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/ClampFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
7 | {
8 | public class ClampFunction
9 | {
10 | public static double Clamp(double value, double lower, double upper)
11 | {
12 | return System.Math.Min(upper, System.Math.Max(value, lower));
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/ClampFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f6019fb101fc7ba4ba0a4fd31dcc35f3
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/ErrorFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
7 | {
8 | public class ErrorFunction
9 | {
10 | // fractional error in math formula less than 1.2 * 10 ^ -7.
11 | // although subject to catastrophic cancellation when test_statistic in very close to 0
12 | // from Chebyshev fitting formula for GetErf(test_statistic) from Numerical Recipes, 6.2
13 | public static double GetErf(double z)
14 | {
15 | double t = 1.0 / (1.0 + 0.5 * System.Math.Abs(z));
16 |
17 | // use Horner's method
18 | double ans = 1 - t * System.Math.Exp(-z * z - 1.26551223 +
19 | t * (1.00002368 +
20 | t * (0.37409196 +
21 | t * (0.09678418 +
22 | t * (-0.18628806 +
23 | t * (0.27886807 +
24 | t * (-1.13520398 +
25 | t * (1.48851587 +
26 | t * (-0.82215223 +
27 | t * (0.17087277))))))))));
28 | if (z >= 0) return ans;
29 | else return -ans;
30 | }
31 |
32 | // fractional error less than x.xx * 10 ^ -4.
33 | // Algorithm 26.2.17 in Abromowitz and Stegun, Handbook of Mathematical.
34 | public static double GetErf2(double z)
35 | {
36 | double t = 1.0 / (1.0 + 0.47047 * System.Math.Abs(z));
37 | double poly = t * (0.3480242 + t * (-0.0958798 + t * (0.7478556)));
38 | double ans = 1.0 - poly * System.Math.Exp(-z * z);
39 | if (z >= 0) return ans;
40 | else return -ans;
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/ErrorFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ad7e6eff402fc804c912afda7afd1c72
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/GammaFunction.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.MathHelpers;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
8 | {
9 | public class GammaFunction
10 | {
11 | public static double GetGamma(double x)
12 | {
13 | return System.Math.Exp(Gamma.Log(x));
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/GammaFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b62619af364c4ed4e9582d2d68f6ef67
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/InverseErrorFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
7 | {
8 | public class InverseErrorFunction
9 | {
10 | ///
11 | /// \operatorname{GetErf}^{-1}(x)\approx \sgn(x) \sqrt{\sqrt{\left(\frac{2}{\pi a}+\frac{\ln(1-x^2)}{2}\right)^2 - \frac{\ln(1-x^2)}{a}}-\left(\frac{2}{\pi a}+\frac{\ln(1-x^2)}{2}\right)}.
12 | ///
13 | ///
14 | ///
15 | public static double GetInvErf(double x)
16 | {
17 | double z;
18 | double a = 0.147;
19 | double the_sign_of_x;
20 | if (0 == x)
21 | {
22 | the_sign_of_x = 0;
23 | }
24 | else if (x > 0)
25 | {
26 | the_sign_of_x = 1;
27 | }
28 | else
29 | {
30 | the_sign_of_x = -1;
31 | }
32 |
33 | if (0 != x)
34 | {
35 | var ln_1minus_x_sqrd = System.Math.Log(1 - x * x);
36 | var ln_1minusxx_by_a = ln_1minus_x_sqrd / a;
37 | var ln_1minusxx_by_2 = ln_1minus_x_sqrd / 2;
38 | var ln_etc_by2_plus2 = ln_1minusxx_by_2 + (2 / (System.Math.PI * a));
39 | var first_sqrt = System.Math.Sqrt((ln_etc_by2_plus2 * ln_etc_by2_plus2) - ln_1minusxx_by_a);
40 | var second_sqrt = System.Math.Sqrt(first_sqrt - ln_etc_by2_plus2);
41 | z = second_sqrt * the_sign_of_x;
42 | }
43 | else
44 | { // x is zero
45 | z = 0;
46 | }
47 | return z;
48 | }
49 |
50 |
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/InverseErrorFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 58294d1a43261e34c831572d0bb517ed
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/InverseLogitFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
7 | {
8 | public class InverseLogitFunction
9 | {
10 | public static double GetInvLogit(double alpha)
11 | {
12 | return 1.0 / (1.0 + System.Math.Exp(-alpha));
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/InverseLogitFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7cab1a9eaaf5b394ea7c0523170105a7
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/LogitFunction.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.SpecialFunctions
7 | {
8 | public class LogitFunction
9 | {
10 | public static double GetLogit(double p)
11 | {
12 | return System.Math.Log(p / (1 - p));
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/SpecialFunctions/LogitFunction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: a289fc453dd562b468e3b3f0281f78e4
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 14677bbd6ca8cc046827c0d7a82bed10
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ANCOVA.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f3a584bad38aa0445bc0d28369f42511
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ANCOVAv2.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 05c1a32b6f7432247b3027ed604a66b8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ANOVA.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 11358ffaefd96ba41b40a444c3bee40b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Bootstrapping.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1b0b07501a7a13a40b54ee5acb1b4202
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/CLT.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
8 | {
9 | ///
10 | /// This class represents the Central Limit Theorem.
11 | ///
12 | /// The Central Limit Theorem (CLT) states that:
13 | /// The distribution of sample statistics (e.g., sample mean) is nearly normal, centered at the population mean, and with a standard deviation equal to the population standard deviation
14 | /// divided by square root of the sample size.
15 | ///
16 | public class CLT
17 | {
18 | ///
19 | /// Estimate the normal distribution of a sample mean (for a continuous variable)
20 | ///
21 | /// The Central Limit Theorem (CLT) states that:
22 | /// The distribution of sample statistics (e.g., sample mean) is nearly normal, centered at the population mean, and with a standard deviation equal to the population standard deviation
23 | /// divided by square root of the sample size.
24 | ///
25 | /// With CTL, we can estimate the the normal distribution of a sample, given its estimated mean and stddev as well as the sample size.
26 | ///
27 | /// For the CTL to hold true for a sample, the following conditions must be met:
28 | /// 1. Independence: Sample observations must be independent.
29 | /// > random sample/assignment
30 | /// > if sampling without replacement, the sample size < 10% of the population
31 | /// 2. Sample size/skew: Either the population distribution is normal, or if the population distribution is skewed, the sample size is large (rule of thumb: sample size > 30)
32 | ///
33 | /// point estimate of sample mean
34 | /// standard deviation of a random sample
35 | /// the size of the random sample
36 | /// The normal distribution of the sample means for a random sample drawn from the population
37 | public static Gaussian EstimateSampleMeanDistribution(double sampleMean, double sampleStdDev, int sampleSize)
38 | {
39 | double SE = StandardError.GetStandardError(sampleStdDev, sampleSize);
40 | return new Gaussian(sampleMean, SE);
41 | }
42 |
43 | ///
44 | /// Estimate the normal distribution of a sample proportion (for a categorical variable with two values { "SUCCESS", "FAILURE" })
45 | ///
46 | /// The Centrl Limit Theorem (CLT) for proportions:
47 | /// The distribution of sample proportions is nearly normal, centered at the population proportion, and with a standard error inversely proportional to the sample size.
48 | ///
49 | /// Conditions for the CLT for proportions:
50 | /// 1. Independence: Sampled observations must be independent.
51 | /// > random sample/assignment
52 | /// > if sampling without replacement, n < 10% population
53 | /// 2. Sample size / skew: There should be at least 10 successes and 10 failures in the sample: np >= 10 and n(1-p) >= 10
54 | ///
55 | ///
56 | ///
57 | ///
58 | public static Gaussian EstimateSampleProportionDistribution(double p, int sampleSize)
59 | {
60 | double SE = StandardError.GetStandardErrorForProportion(p, sampleSize);
61 | return new Gaussian(p, SE);
62 | }
63 |
64 |
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/CLT.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9d3dc5b99b2e3b34782db7b8dd93bdcc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ChiSquareGOFTest.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
8 | {
9 | ///
10 | /// "Goodness of fit" test based on chi-square test.
11 | ///
12 | /// In this case, we are dealing with one categorical variable, which has more than 2 levels, (e.g., the categorical variable "animal" has many levels such as "dog", "cat", "fish", ...)
13 | ///
14 | /// We are given:
15 | /// 1. the expected distribution / percentage of each level for the categorical variable in the population
16 | /// 2. the actual count of each level for the categorical variable within the sample data
17 | /// 3. the sample data size
18 | /// The objective is to test whether the actual distribution of each level for the categorical variable in the population matches with the expected distribution of each level
19 | ///
20 | /// Hypotheses are:
21 | /// H_0 : actual distribution of each level = expected distribution of each level
22 | /// H_A : actual distribution of each level != expected distribution of each level
23 | ///
24 | /// Conditions for the test:
25 | /// 1. Independence: Sampled observations must be independent
26 | /// > random sample/assignment
27 | /// > if sampling without replacement, n < 10% of population
28 | /// > each case only contributes to one level
29 | /// 2. Sample size: each particular scenario/level in the sample data must have at least 5 counts.
30 | ///
31 | /// p-value = P(observed or more extreme mismatch of expected and actual level distribution | H_0 is true)
32 | ///
33 | /// Reject H_0 if p-value < alpha (i.e. the significance level)
34 | ///
35 | public class ChiSquareGOFTest
36 | {
37 | ///
38 | /// GOF test for one categorical variable with more than two levels.
39 | ///
40 | /// Hypotheses are:
41 | /// H_0 : actual distribution of each level = expected distribution of each level
42 | /// H_1 : actual distribution of each level != expected distribution of each level
43 | ///
44 | /// p-value = P(observed or more mismatch of expected and actual level distribution | H_0 is true)
45 | ///
46 | /// Reject H_0 if p-value < alpha
47 | ///
48 | /// The count of each level in the sample data for the categorical variable
49 | /// The expected distribution / percentage of each level in the population for the categorical variable
50 | /// p-value which is P(observed or more extreme mismatch of expected and actual level distribution | H_0 is true
51 | /// alpha
52 | /// True if H_0 is rejected; False if H_0 is failed to be rejected
53 | public bool RejectH0(int[] observedCountInEachLevel, double[] expectedPercentageOfEachLevel, out double pValue, double significance_level = 0.05)
54 | {
55 | int sampleSize = 0;
56 | int countOfLevels = observedCountInEachLevel.Length;
57 | for (int i = 0; i < countOfLevels; ++i)
58 | {
59 | sampleSize += observedCountInEachLevel[i];
60 | }
61 | int[] expectedCountInEachLevel = new int[countOfLevels];
62 |
63 | int r = sampleSize;
64 | for (int i = 0; i < countOfLevels; ++i)
65 | {
66 | expectedCountInEachLevel[i] = (int)(expectedPercentageOfEachLevel[i] * sampleSize);
67 | r -= expectedCountInEachLevel[i];
68 | }
69 | if (r > 0) expectedCountInEachLevel[0] += r;
70 |
71 | double ChiSq = 0;
72 | for (int i = 0; i < countOfLevels; ++i)
73 | {
74 | ChiSq += System.Math.Pow(observedCountInEachLevel[i] - expectedCountInEachLevel[i], 2) / expectedCountInEachLevel[i];
75 | }
76 |
77 | pValue = 1 - ChiSquare.GetPercentile(ChiSq, countOfLevels - 1);
78 | return pValue < significance_level;
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ChiSquareGOFTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4f38ae858200c90449f89bbccce20cc9
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ChiSquareIndependenceTest.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 79c2353d061701c469e01556ea9f6109
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/CollectionExtensionMethods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
7 | {
8 | public static class CollectionExtensionMethods
9 | {
10 | public static double? Average(this IEnumerable values, int precision_point)
11 | {
12 | int count = values.Count();
13 | if (count == 0) return null;
14 | return System.Math.Round(values.Average(), precision_point);
15 | }
16 |
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/CollectionExtensionMethods.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 23aea189d09864d4e86099e4047731c0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/ConfidenceInterval.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e5ffb753ed072a84ab79bc530c7accdc
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Correlation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
7 | {
8 | ///
9 | /// Correlation: strength of a linear relationship.
10 | ///
11 | /// Correleation, which always taks values between -1 and 1, describse the strength of the lienar relationship between two variables.
12 | /// We denote the correlation by R.
13 | ///
14 | /// Only when the relationship is perfectly linear is the correlation either -1 or +1.
15 | /// If the relationship is strong and positive, the correlation will be near +1
16 | /// If the relationship is strong and negative, the correlation will be near -1
17 | /// If there is no apparent linear relationship between the variables, then the correlation will be near zero.
18 | ///
19 | public class Correlation
20 | {
21 | ///
22 | /// Return the correlation for observations (x_1, y_1), (x_2, y_2), ... (x_n, y_n), where n is the sample size
23 | /// The correlation is computed as correlation(x, y) = sum_i((x_i - mu_x) * (y_i - mu_y)) / (sum_i((x_i - mu_x)^2) * sum_i((y_i - mu_y)^2))
24 | /// which can also be written as n * sum_i((x_i - mu_x) * (y_i - mu_y) / (sigma_x * sigma_y))
25 | /// where mu_x = sum_i(x_i) / n and sigma_x = sqrt(sum_i((x_i - mu_x)^2) / n)
26 | ///
27 | /// The observations (x_1, y_1), (x_2, y_2), ... (x_n, y_n), where n is the sample size
28 | /// The correlation value for variable x and y
29 | public double GetCorrelation(Tuple[] observations)
30 | {
31 | int n = observations.Length;
32 | double[] x = new double[n];
33 | double[] y = new double[n];
34 | for (int i = 0; i < n; ++i)
35 | {
36 | x[i] = observations[i].Item1;
37 | y[i] = observations[i].Item2;
38 | }
39 |
40 | double mu_x = Mean.GetMean(x);
41 | double mu_y = Mean.GetMean(y);
42 |
43 | double sigma_x = StdDev.GetStdDev(x, mu_x);
44 | double sigma_y = StdDev.GetStdDev(y, mu_y);
45 |
46 | double sum = 0;
47 | for (int i = 0; i < n; ++i)
48 | {
49 | sum += ((x[i] - mu_x) / sigma_x) * ((y[i] - mu_y) / sigma_y);
50 | }
51 | return sum / n;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Correlation.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 357acd00ee6ab2b4fabaa8479c598895
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/DescriptiveStatistics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
7 | {
8 | public class DescriptiveStatistics
9 | {
10 | protected int mCount = 0;
11 | protected double[] mSortedData = null;
12 | protected double mMinValue = double.MinValue;
13 | protected double mMaxValue = double.MaxValue;
14 | protected double mAverage;
15 | protected double mMedian;
16 | protected double mStdDev;
17 |
18 | public DescriptiveStatistics(IEnumerable values)
19 | {
20 | mCount = values.Count();
21 |
22 | mSortedData = values.OrderBy(x => x).ToArray();
23 | mMinValue = mSortedData[0];
24 | mMaxValue = mSortedData[mCount - 1];
25 |
26 | mAverage = mSortedData.Average();
27 |
28 | if (mCount % 2 == 0)
29 | {
30 | int mid_index = mCount / 2;
31 | mMedian = (mSortedData[mid_index - 1] + mSortedData[mid_index]) / 2;
32 | }
33 | else
34 | {
35 | mMedian = mSortedData[(mCount + 1) / 2];
36 | }
37 |
38 |
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/DescriptiveStatistics.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0913601c1657250409d891f35106367b
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/HypothesisTesting.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 8dea8c03ca0d07545a0e9dc7e803c7c0
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/HypothesisTestingForProportion.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f1738b5b921d99948a39e4ba5451c023
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/LinearCombination.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0c2bc1cff296ad94d9926227bbfe7943
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/MANCOVA.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d8ac3e87f21b39a4ebd2e20350861478
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/MANOVA.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b3948eb799c12014c9dda54d20948e28
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Mean.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
7 | {
8 | public class Mean
9 | {
10 | ///
11 | /// Return the sample mean averaged from multiple samples
12 | ///
13 | /// List of mean for each sample
14 | /// List of size for each sample
15 | ///
16 | public static double GetMeanForWeightedAverage(double[] sampleMeans, int[] sampleSizes)
17 | {
18 | int totalSampleSize = 0;
19 | for (int i = 0; i < sampleSizes.Length; ++i)
20 | {
21 | totalSampleSize += sampleSizes[i];
22 | }
23 | double sum = 0;
24 | for (int i = 0; i < sampleSizes.Length; ++i)
25 | {
26 | sum += (sampleSizes[i] * sampleMeans[i] / totalSampleSize);
27 | }
28 | return sum;
29 | }
30 |
31 | public static double GetMean(double[] sample)
32 | {
33 | double sum = 0;
34 | for (int i = 0; i < sample.Length; ++i)
35 | {
36 | sum += sample[i];
37 | }
38 | return sample.Length > 0 ? sum / sample.Length : 0;
39 | }
40 |
41 | public static double GetMean(IList sample)
42 | {
43 | double sum = 0;
44 | for (int i = 0; i < sample.Count; ++i)
45 | {
46 | sum += sample[i];
47 | }
48 | return sample.Count > 0 ? sum / sample.Count : 0;
49 | }
50 |
51 | ///
52 | /// Return the sample mean averaged from multiple samples
53 | ///
54 | /// List of mean for each sample
55 | /// List of size for each sample
56 | ///
57 | public static float GetMeanForWeightedAverage(float[] sampleMeans, int[] sampleSizes)
58 | {
59 | int totalSampleSize = 0;
60 | for (int i = 0; i < sampleSizes.Length; ++i)
61 | {
62 | totalSampleSize += sampleSizes[i];
63 | }
64 | float sum = 0;
65 | for (int i = 0; i < sampleSizes.Length; ++i)
66 | {
67 | sum += (sampleSizes[i] * sampleMeans[i] / totalSampleSize);
68 | }
69 | return sum;
70 | }
71 |
72 | public static float GetMean(float[] sample)
73 | {
74 | float sum = 0;
75 | for (int i = 0; i < sample.Length; ++i)
76 | {
77 | sum += sample[i];
78 | }
79 | return sample.Length > 0 ? sum / sample.Length : 0;
80 | }
81 |
82 | public static float GetMean(IList sample)
83 | {
84 | float sum = 0;
85 | int count = sample.Count;
86 | for (int i = 0; i < count; ++i)
87 | {
88 | sum += sample[i];
89 | }
90 | return count > 0 ? sum / count : 0;
91 | }
92 |
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Mean.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c68b1f783fde5854b9747ce9eba3c56e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Median.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f1c316577ec1def4da23c6b398200115
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/MultipleComparisons.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 04203489389f51e4889aae3e7bc80a86
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Sample.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
8 | {
9 | public class Sample
10 | {
11 | public static List SampleWithoutReplacement(IList data, int sampleCount)
12 | {
13 | List sample = new List();
14 | for (int i = 0; i < sampleCount; ++i)
15 | {
16 | T sampleVal = data[DistributionModel.NextInt(sampleCount)];
17 | sample.Add(sampleVal);
18 | }
19 |
20 | return sample;
21 | }
22 |
23 | public static List SampleWithReplacement(IList data, int sampleCount)
24 | {
25 | List sample = new List();
26 | List temp = data.ToList();
27 | T sampleValue;
28 | int sampleIndex;
29 | for (int i = 0; i < sampleCount; ++i)
30 | {
31 | sampleIndex = DistributionModel.NextInt(temp.Count);
32 | sampleValue = temp[sampleIndex];
33 | sample.Add(sampleValue);
34 | temp.RemoveAt(sampleIndex);
35 | }
36 | return sample;
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/Sample.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f9bbfabbb1d936b479d22dc46015a8da
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/StandardError.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4ff75f66357ea8345b4eb35d5293eaf2
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/StdDev.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Statistics
7 | {
8 | public class StdDev
9 | {
10 | public static double GetStdDev(double[] sample, double sampleMean)
11 | {
12 | double sum = 0;
13 | for (int i = 0; i < sample.Length; ++i)
14 | {
15 | sum += System.Math.Pow(sample[i] - sampleMean, 2);
16 | }
17 | return System.Math.Sqrt(sum / sample.Length);
18 | }
19 |
20 | public static double GetStdDev(IList sample, double sampleMean)
21 | {
22 | double sum = 0;
23 | for (int i = 0; i < sample.Count; ++i)
24 | {
25 | sum += System.Math.Pow(sample[i] - sampleMean, 2);
26 | }
27 | return System.Math.Sqrt(sum / sample.Count);
28 | }
29 |
30 | public static float GetStdDev(float[] sample, float sampleMean)
31 | {
32 | float sum = 0;
33 | for (int i = 0; i < sample.Length; ++i)
34 | {
35 | sum += (float)System.Math.Pow(sample[i] - sampleMean, 2);
36 | }
37 | return (float)System.Math.Sqrt(sum / sample.Length);
38 | }
39 |
40 | public static float GetStdDev(IList sample, float sampleMean)
41 | {
42 | float sum = 0;
43 | for (int i = 0; i < sample.Count; ++i)
44 | {
45 | sum += (float)System.Math.Pow(sample[i] - sampleMean, 2);
46 | }
47 | return (float)System.Math.Sqrt(sum / sample.Count);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/StdDev.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 55d1f3ea93bab0a4f8ec084ef3f1396d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/MathUtils/Statistics/TwoWayANOVA.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b16653f9de8836545a7eb0fb6148cbb8
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: c9ea871977df04e42b053b9f08c85bab
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/Ergodic.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.Topology
8 | {
9 | public class Ergodic : ITopology
10 | {
11 | protected int mStateCount = 0;
12 | protected bool mRandom = false;
13 |
14 | public Ergodic(int state_count, bool random=false)
15 | {
16 | mStateCount = state_count;
17 | mRandom = random;
18 | }
19 |
20 | public int Create(out double[,] logTransitionMatrix, out double[] logInitialState)
21 | {
22 | logTransitionMatrix = new double[mStateCount, mStateCount];
23 | logInitialState = new double[mStateCount];
24 |
25 | for (int i = 0; i < mStateCount; ++i)
26 | {
27 | logInitialState[i] = double.NegativeInfinity;
28 | }
29 | logInitialState[0] = 0.0;
30 |
31 | if (mRandom)
32 | {
33 | for (int i = 0; i < mStateCount; ++i)
34 | {
35 | double sum = 0.0;
36 | for (int j = 0; j < mStateCount; ++j)
37 | {
38 | sum += logTransitionMatrix[i, j] = MathHelper.NextDouble();
39 | }
40 | for (int j = 0; j < mStateCount; ++j)
41 | {
42 | double transition_value = logTransitionMatrix[i, j];
43 | logTransitionMatrix[i, j] = System.Math.Log(transition_value / sum);
44 | }
45 | }
46 | }
47 | else
48 | {
49 | for (int i = 0; i < mStateCount; ++i)
50 | {
51 | for (int j = 0; j < mStateCount; ++j)
52 | {
53 | logTransitionMatrix[i, j] = System.Math.Log(1.0 / mStateCount);
54 | }
55 | }
56 | }
57 |
58 | return mStateCount;
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/Ergodic.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4dc5abceb81dfd04da67bf9015e5f20f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/Forward.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel.Topology
8 | {
9 | public class Forward : ITopology
10 | {
11 | protected int mStateCount;
12 | protected int mDeepness;
13 | protected bool mRandom;
14 |
15 | public Forward(int state_count, int deepness, bool random = false)
16 | {
17 | mStateCount = state_count;
18 | mDeepness = deepness;
19 | mRandom = random;
20 | }
21 |
22 | public Forward(int state_count, bool random = false)
23 | : this(state_count, state_count, random)
24 | {
25 |
26 | }
27 |
28 | public int Create(out double[,] logTransitionMatrix, out double[] logInitialState)
29 | {
30 | logTransitionMatrix = new double[mStateCount, mStateCount];
31 | logInitialState = new double[mStateCount];
32 |
33 | for (int i = 0; i < mStateCount; ++i)
34 | {
35 | logInitialState[i] = double.NegativeInfinity;
36 | }
37 | logInitialState[0] = 0.0;
38 |
39 | if (mRandom)
40 | {
41 | for (int i = 0; i < mStateCount; ++i)
42 | {
43 | double sum = 0.0;
44 | for (int j = i; j < mDeepness; ++j)
45 | {
46 | sum += logTransitionMatrix[i, j] = MathHelper.NextDouble();
47 | }
48 | for (int j = i; j < mDeepness; ++j)
49 | {
50 | double transition_value = logTransitionMatrix[i, j];
51 | logTransitionMatrix[i, j] = transition_value / sum;
52 | }
53 | }
54 | }
55 | else
56 | {
57 | for (int i = 0; i < mStateCount; ++i)
58 | {
59 | double sum = System.Math.Min(mDeepness, mStateCount - i);
60 | for (int j = i; j < mStateCount && (j-i) < mDeepness; ++j)
61 | {
62 | logTransitionMatrix[i, j] = 1.0 / sum;
63 | }
64 | }
65 | }
66 |
67 | for (int i = 0; i < mStateCount; ++i)
68 | {
69 | for (int j = 0; j < mStateCount; ++j)
70 | {
71 | logTransitionMatrix[i, j] = System.Math.Log(logTransitionMatrix[i, j]);
72 | }
73 | }
74 |
75 | return mStateCount;
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/Forward.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 22ee2d4b74247b14dbbfcc8173f62397
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/ITopology.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.HiddenMarkovModel.Topology
7 | {
8 | public interface ITopology
9 | {
10 | int Create(out double[,] logTransitionMatrix, out double[] logInitialState);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Topology/ITopology.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: f313012205dd1fb4ab689264e4d6da88
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.Log.Continuous.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
2 | using Bigtree.Algorithm.HiddenMarkovModel.MathUtils.Distribution;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 |
8 | namespace Bigtree.Algorithm.HiddenMarkovModel
9 | {
10 | public partial class Viterbi
11 | {
12 | public int[] LogForward(double[,] logA, DistributionModel[] logB, double[] logPi, double[] observations)
13 | {
14 | double logLikelihood = 0;
15 | return LogForward(logA, logB, logPi, observations, out logLikelihood);
16 | }
17 |
18 | public static int[] LogForward(double[,] logA, DistributionModel[] probB, double[] logPi, double[] observations, out double logLikelihood)
19 | {
20 | int T = observations.Length;
21 | int N = logPi.Length;
22 |
23 | DiagnosticsHelper.Assert(logA.GetLength(0) == N);
24 | DiagnosticsHelper.Assert(logA.GetLength(1) == N);
25 | DiagnosticsHelper.Assert(probB.Length == N);
26 |
27 | int[,] V = new int[T, N];
28 |
29 | double[,] fwd = new double[T, N];
30 |
31 | for (int i = 0; i < N; ++i)
32 | {
33 | fwd[0, i] = logPi[i] + MathHelper.LogProbabilityFunction(probB[i], observations[0]);
34 | }
35 |
36 | double maxWeight = 0;
37 | int maxState = 0;
38 |
39 | for (int t = 1; t < T; ++t)
40 | {
41 | double x = observations[t];
42 | for (int i = 0; i < N; ++i)
43 | {
44 | maxWeight = fwd[t - 1, 0] + logA[0, i];
45 | maxState = 0;
46 |
47 | double weight = 0;
48 | for (int j = 1; j < N; ++j)
49 | {
50 | weight = fwd[t - 1, j] + logA[j, i];
51 | if (maxWeight < weight)
52 | {
53 | maxWeight = weight;
54 | maxState = j;
55 | }
56 | }
57 |
58 | fwd[t, i] = maxWeight + MathHelper.LogProbabilityFunction(probB[i], x);
59 | V[t, i] = maxState;
60 | }
61 | }
62 |
63 | maxState = 0;
64 | maxWeight = fwd[T - 1, 0];
65 | for (int i = 0; i < N; ++i)
66 | {
67 | if (fwd[T - 1, i] > maxWeight)
68 | {
69 | maxWeight = fwd[T - 1, i];
70 | maxState = i;
71 | }
72 | }
73 |
74 | int[] path = new int[T];
75 | path[T - 1] = maxState;
76 | for (int t = T - 2; t >= 0; --t)
77 | {
78 | path[t] = V[t + 1, path[t + 1]];
79 | }
80 |
81 | logLikelihood = maxWeight;
82 |
83 | return path;
84 |
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.Log.Continuous.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fffee67d6f704b34bb85b2ad7235dc3a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.Log.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel
8 | {
9 | public partial class Viterbi
10 | {
11 | public int[] LogForward(double[,] logA, double[,] logB, double[] logPi, int[] observations)
12 | {
13 | double logLikelihood = 0;
14 | return LogForward(logA, logB, logPi, observations, out logLikelihood);
15 | }
16 |
17 | public static int[] LogForward(double[,] logA, double[,] logB, double[] logPi, int[] observations, out double logLikelihood)
18 | {
19 | int T = observations.Length;
20 | int N = logPi.Length;
21 |
22 | DiagnosticsHelper.Assert(logA.GetLength(0) == N);
23 | DiagnosticsHelper.Assert(logA.GetLength(1) == N);
24 | DiagnosticsHelper.Assert(logB.GetLength(0) == N);
25 |
26 | int[,] V = new int[T, N];
27 |
28 | double[,] fwd = new double[T, N];
29 |
30 | for (int i = 0; i < N; ++i)
31 | {
32 | fwd[0, i] = logPi[i] + logB[i, observations[0]];
33 | }
34 |
35 | double maxWeight = 0;
36 | int maxState = 0;
37 |
38 | for (int t = 1; t < T; ++t)
39 | {
40 | for (int i = 0; i < N; ++i)
41 | {
42 | maxWeight = fwd[t - 1, 0] + logA[0, i];
43 | maxState = 0;
44 |
45 | double weight = 0;
46 | for (int j = 1; j < N; ++j)
47 | {
48 | weight = fwd[t - 1, j] + logA[j, i];
49 | if (maxWeight < weight)
50 | {
51 | maxWeight = weight;
52 | maxState = j;
53 | }
54 | }
55 |
56 | fwd[t, i] = maxWeight + logB[i, observations[t]];
57 | V[t, i] = maxState;
58 | }
59 | }
60 |
61 | maxState = 0;
62 | maxWeight = fwd[T - 1, 0];
63 | for (int i = 0; i < N; ++i)
64 | {
65 | if (fwd[T - 1, i] > maxWeight)
66 | {
67 | maxWeight = fwd[T - 1, i];
68 | maxState = i;
69 | }
70 | }
71 |
72 | int[] path = new int[T];
73 | path[T - 1] = maxState;
74 | for (int t = T - 2; t >= 0; --t)
75 | {
76 | path[t] = V[t + 1, path[t + 1]];
77 | }
78 |
79 | logLikelihood = maxWeight;
80 |
81 | return path;
82 |
83 | }
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.Log.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ac65a9fa734f5fe4396cb5018b50a387
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.cs:
--------------------------------------------------------------------------------
1 | using Bigtree.Algorithm.HiddenMarkovModel.Helpers;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Bigtree.Algorithm.HiddenMarkovModel
8 | {
9 | public partial class Viterbi
10 | {
11 | public static int[] Forward(double[,] A, double[,] B, double[] pi, int[] observations, out double logLikelihood)
12 | {
13 | int T = observations.Length;
14 | int N = pi.Length;
15 |
16 | DiagnosticsHelper.Assert(A.GetLength(0) == N);
17 | DiagnosticsHelper.Assert(A.GetLength(1) == N);
18 | DiagnosticsHelper.Assert(B.GetLength(0) == N);
19 |
20 | int[,] V = new int[T, N];
21 |
22 | double[,] fwd = new double[T, N];
23 |
24 | for (int i = 0; i < N; ++i)
25 | {
26 | fwd[0, i] = pi[i] * B[i, observations[0]];
27 | }
28 |
29 | double maxWeight = 0;
30 | int maxState = 0;
31 |
32 | for (int t = 1; t < T; ++t)
33 | {
34 | for (int i = 0; i < N; ++i)
35 | {
36 | maxWeight = fwd[t-1, 0] * A[0, i];
37 | maxState = 0;
38 |
39 | double weight = 0;
40 | for (int j = 1; j < N; ++j)
41 | {
42 | weight = fwd[t - 1, j] * A[j, i];
43 | if (maxWeight < weight)
44 | {
45 | maxWeight = weight;
46 | maxState = j;
47 | }
48 | }
49 |
50 | fwd[t, i]=maxWeight * B[i, observations[t]];
51 | V[t, i] = maxState;
52 | }
53 | }
54 |
55 | maxState = 0;
56 | maxWeight = fwd[T-1, 0];
57 | for (int i = 0; i < N; ++i)
58 | {
59 | if (fwd[T - 1, i] > maxWeight)
60 | {
61 | maxWeight = fwd[T - 1, i];
62 | maxState = i;
63 | }
64 | }
65 |
66 | int[] path = new int[T];
67 | path[T - 1] = maxState;
68 | for (int t = T - 2; t >= 0; --t)
69 | {
70 | path[t] = V[t + 1, path[t + 1]];
71 | }
72 |
73 | logLikelihood = System.Math.Log(maxWeight);
74 |
75 | return path;
76 | }
77 |
78 | public static int[] Forward(double[,] A, double[,] B, double[] pi, int[] observation)
79 | {
80 | double logLikelihood = 0;
81 | return Forward(A, B, pi, observation, out logLikelihood);
82 | }
83 |
84 |
85 |
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/HiddenMarkovModel/Viterbi.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e0b8337cfbb1c7b4a80ecd8952ddf7b1
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/KNN.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 6f9053757e09ded459b1ee6c5b7a8a83
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/KNN/KnnModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.KNN
6 | {
7 | public class KnnModel
8 | {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/KNN/KnnModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ca816d6a0f59ff4448e99f81d2a6d165
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/KNN/data.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 591a139acd6cb884ea0c083fdaa7d218
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/KNN/data/train.csv.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0f353c776d3e4ac48b7cb1195dcd7c70
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/LinearRegression.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 4b831ffdc4ca9e140afba68683540c02
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/LinearRegression/LinearRegressionModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.LinearRegression
6 | {
7 | public class LinearRegressionModel
8 | {
9 |
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/LinearRegression/LinearRegressionModel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 83f966bc7a59bde4fb461d1b4074e74f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/LinearRegression/README.md:
--------------------------------------------------------------------------------
1 | Linear regression is a method used to find a relationship between a dependent variable and a set of independent variables.
2 |
3 | https://www.cs.toronto.edu/~frossard/post/linear_regression/
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/LinearRegression/README.md.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 734281925a44ec248a873dcf97c636f3
3 | TextScriptImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/MathFunctions.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 0caf88d536059444daf95b59b12253f4
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/MathFunctions/Sigmoid.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * Bigtree.Algorithm
3 | * Copyright (C) 2018 Haiping Chen
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the Apache License 2.0 as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the Apache License 2.0
16 | * along with this program. If not, see .
17 | */
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Text;
22 |
23 | namespace Bigtree.Algorithm.MathFunctions
24 | {
25 | public partial class Function
26 | {
27 | ///
28 | /// A sigmoid function is a mathematical function having a characteristic "S"-shaped curve or sigmoid curve.
29 | ///
30 | ///
31 | ///
32 | ///
33 | public static double Sigmoid(double x, double coefficient = 1)
34 | {
35 | return 1 / (1 + Math.Exp(-x * coefficient));
36 | }
37 |
38 | public static double SigmoidDerivative(double y)
39 | {
40 | return y * (1 - y);
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/MathFunctions/Sigmoid.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 902292706aa8d5346980e68559158f53
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 28900acc10149764f95e1695056c4720
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Cache.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e1b49361435dd7a42954d83635b22a41
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/GaussianTransform.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: e18859d9c023ebc4483c954f70c083fd
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/IRangeTransform.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * SVM.NET Library
3 | * Copyright (C) 2008 Matthew Johnson
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 |
20 | namespace Bigtree.Algorithm.SVM
21 | {
22 | ///
23 | /// Interface implemented by range transforms.
24 | ///
25 | public interface IRangeTransform
26 | {
27 | ///
28 | /// Transform the input value using the transform stored for the provided index.
29 | ///
30 | /// Input value
31 | /// Index of the transform to use
32 | /// The transformed value
33 | double Transform(double input, int index);
34 | ///
35 | /// Transforms the input array.
36 | ///
37 | /// The array to transform
38 | /// The transformed array
39 | Node[] Transform(Node[] input);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/IRangeTransform.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 1cbda9113eb66d04689f19bd9cf2f00a
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Kernel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cbfea5c2ea62a344abbf506f9a80fef6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Model.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: ec10cb595dbf67b49b5f1b10e9b34521
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Node.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * SVM.NET Library
3 | * Copyright (C) 2008 Matthew Johnson
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 |
20 | using System;
21 |
22 | namespace Bigtree.Algorithm.SVM
23 | {
24 | ///
25 | /// Encapsulates a node in a Problem vector, with an index and a value (for more efficient representation
26 | /// of sparse data.
27 | ///
28 | [Serializable]
29 | public class Node : IComparable
30 | {
31 | internal int _index;
32 | internal double _value;
33 |
34 | ///
35 | /// Default Constructor.
36 | ///
37 | public Node()
38 | {
39 | }
40 | ///
41 | /// Constructor.
42 | ///
43 | /// The index of the value.
44 | /// The value to store.
45 | public Node(int index, double value)
46 | {
47 | _index = index;
48 | _value = value;
49 | }
50 |
51 | ///
52 | /// Index of this Node.
53 | ///
54 | public int Index
55 | {
56 | get
57 | {
58 | return _index;
59 | }
60 | set
61 | {
62 | _index = value;
63 | }
64 | }
65 | ///
66 | /// Value at Index.
67 | ///
68 | public double Value
69 | {
70 | get
71 | {
72 | return _value;
73 | }
74 | set
75 | {
76 | _value = value;
77 | }
78 | }
79 |
80 | ///
81 | /// String representation of this Node as {index}:{value}.
82 | ///
83 | /// {index}:{value}
84 | public override string ToString()
85 | {
86 | return string.Format("{0}:{1}", _index, _value.Truncate());
87 | }
88 |
89 | public override bool Equals(object obj)
90 | {
91 | Node other = obj as Node;
92 | if(other == null)
93 | return false;
94 |
95 | return _index == other._index && _value.Truncate() == other._value.Truncate();
96 | }
97 |
98 | public override int GetHashCode()
99 | {
100 | return _index.GetHashCode() + _value.GetHashCode();
101 | }
102 |
103 | #region IComparable Members
104 |
105 | ///
106 | /// Compares this node with another.
107 | ///
108 | /// The node to compare to
109 | /// A positive number if this node is greater, a negative number if it is less than, or 0 if equal
110 | public int CompareTo(Node other)
111 | {
112 | return _index.CompareTo(other._index);
113 | }
114 |
115 | #endregion
116 | }
117 | }
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Node.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 30d3d4e46155935439b255ea6cea2824
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Parameter.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 627f69d7a2f039742a8a9118b5d78596
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/ParameterSelection.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 64700ed64a019f74d9104c033d8f78db
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/PerformanceEvaluator.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: b9e04b5e3d211704ea2e01023680109e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/PrecomputedKernel.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: d6aa334b7513c4548b2aad9e81e6da37
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Prediction.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 3b5a8b608c711b3478a9e75942e65fea
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Problem.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 9075a7f192843034a97a8b3bbdc4ebad
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/RangeTransform.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: cc456ba918331fd49ba9131d5d9a6e8c
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/SVMExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Bigtree.Algorithm.SVM
7 | {
8 | internal static class SVMExtensions
9 | {
10 | private const double PRECISION = 1000000.0;
11 |
12 | public static double Truncate(this double x)
13 | {
14 | return Math.Round(x * PRECISION) / PRECISION;
15 | }
16 |
17 | public static void SwapIndex(this T[] list, int i, int j)
18 | {
19 | T tmp = list[i];
20 | list[i] = list[j];
21 | list[j] = tmp;
22 | }
23 |
24 | public static bool IsEqual(this T[][] lhs, T[][] rhs)
25 | {
26 | if (lhs.Length != rhs.Length)
27 | return false;
28 |
29 | for (int i = 0; i < lhs.Length; i++)
30 | {
31 | if (!lhs[i].IsEqual(rhs[i]))
32 | return false;
33 | }
34 |
35 | return true;
36 | }
37 |
38 | public static bool IsEqual(this T[] lhs, T[] rhs)
39 | {
40 | if (lhs.Length != rhs.Length)
41 | return false;
42 | for (int i = 0; i < lhs.Length; i++)
43 | if (!lhs[i].Equals(rhs[i]))
44 | return false;
45 | return true;
46 | }
47 |
48 | public static bool IsEqual(this double[] lhs, double[] rhs)
49 | {
50 | if (lhs.Length != rhs.Length)
51 | return false;
52 | for (int i = 0; i < lhs.Length; i++)
53 | {
54 | double x = lhs[i].Truncate();
55 | double y = rhs[i].Truncate();
56 | if (x != y)
57 | return false;
58 | }
59 | return true;
60 | }
61 |
62 | public static bool IsEqual(this double[][] lhs, double[][] rhs)
63 | {
64 | if (lhs.Length != rhs.Length)
65 | return false;
66 | for (int i = 0; i < lhs.Length; i++)
67 | if (!lhs[i].IsEqual(rhs[i]))
68 | return false;
69 | return true;
70 | }
71 |
72 | public static int ComputeHashcode(this T[] array)
73 | {
74 | return array.Sum(o => o.GetHashCode());
75 | }
76 |
77 | public static int ComputeHashcode(this T[][] array)
78 | {
79 | return array.Sum(o => o.ComputeHashcode());
80 | }
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/SVMExtensions.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 163dbb55c81eb6d48ad56cfb305a4f6f
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/SVMUtilities.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: bb2edab30cc8fc5419b74babe9b68afa
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Scaling.cs:
--------------------------------------------------------------------------------
1 | /*
2 | * SVM.NET Library
3 | * Copyright (C) 2008 Matthew Johnson
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, either version 3 of the License, or
8 | * (at your option) any later version.
9 | *
10 | * This program is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | * GNU General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 |
19 |
20 | using System;
21 |
22 | namespace Bigtree.Algorithm.SVM
23 | {
24 | ///
25 | /// Deals with the scaling of Problems so they have uniform ranges across all dimensions in order to
26 | /// result in better SVM performance.
27 | ///
28 | public static class Scaling
29 | {
30 | ///
31 | /// Scales a problem using the provided range. This will not affect the parameter.
32 | ///
33 | /// The problem to scale
34 | /// The Range transform to use in scaling
35 | /// The Scaled problem
36 | public static Problem Scale(this IRangeTransform range, Problem prob)
37 | {
38 | Problem scaledProblem = new Problem(prob.Count, new double[prob.Count], new Node[prob.Count][], prob.MaxIndex);
39 | for (int i = 0; i < scaledProblem.Count; i++)
40 | {
41 | scaledProblem.X[i] = new Node[prob.X[i].Length];
42 | for (int j = 0; j < scaledProblem.X[i].Length; j++)
43 | scaledProblem.X[i][j] = new Node(prob.X[i][j].Index, range.Transform(prob.X[i][j].Value, prob.X[i][j].Index));
44 | scaledProblem.Y[i] = prob.Y[i];
45 | }
46 | return scaledProblem;
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Scaling.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: de42402920e0740418cd18827784a57d
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Solver.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fcdc5b250df945242806d625a40d91e6
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/TemporaryCulture.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Globalization;
6 | using System.Threading;
7 |
8 | namespace Bigtree.Algorithm.SVM
9 | {
10 | internal static class TemporaryCulture
11 | {
12 | private static CultureInfo _culture;
13 |
14 | public static void Start()
15 | {
16 | _culture = Thread.CurrentThread.CurrentCulture;
17 | Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
18 | }
19 |
20 | public static void Stop()
21 | {
22 | Thread.CurrentThread.CurrentCulture = _culture;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/TemporaryCulture.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 22a7b11050ec30241b8a9e79d6d97367
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/SVM/Training.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: fad5b32e76a3a3b4dbfa0944fc7a9f99
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Statistics.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 39ca57e4c790970438267d99a2cb4817
3 | folderAsset: yes
4 | DefaultImporter:
5 | externalObjects: {}
6 | userData:
7 | assetBundleName:
8 | assetBundleVariant:
9 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Statistics/Probability.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace Bigtree.Algorithm.Statistics
6 | {
7 | ///
8 | /// In probability theory and statistics, a probability distribution is a mathematical function
9 | /// that provides the probabilities of occurrence of different possible outcomes in an experiment.
10 | /// https://en.wikipedia.org/wiki/Probability_distribution
11 | ///
12 | public class Probability
13 | {
14 | ///
15 | /// one value of all samples
16 | ///
17 | public string Value { get; set; }
18 |
19 | ///
20 | /// the number of times that something happens within a particular period of time
21 | ///
22 | public int Freq { get; set; }
23 |
24 | ///
25 | /// how likely something is, sometimes calculated in a mathematical way
26 | ///
27 | public double Prob { get; set; }
28 |
29 | public override string ToString()
30 | {
31 | return $"{Value} {Freq} {Prob}";
32 | }
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/Statistics/Probability.cs.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 306060ef0d612014086fb4a25c78c69e
3 | MonoImporter:
4 | externalObjects: {}
5 | serializedVersion: 2
6 | defaultReferences: []
7 | executionOrder: 0
8 | icon: {instanceID: 0}
9 | userData:
10 | assetBundleName:
11 | assetBundleVariant:
12 |
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/VX.AI.Runtime.BigtreeAlgorithm.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VX.AI.Runtime.BigtreeAlgorithm",
3 | "rootNamespace": "",
4 | "references": [],
5 | "includePlatforms": [],
6 | "excludePlatforms": [],
7 | "allowUnsafeCode": false,
8 | "overrideReferences": false,
9 | "precompiledReferences": [],
10 | "autoReferenced": true,
11 | "defineConstraints": [],
12 | "versionDefines": [],
13 | "noEngineReferences": false
14 | }
--------------------------------------------------------------------------------
/Runtime/BigtreeAlgorithm/VX.AI.Runtime.BigtreeAlgorithm.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 72163bce151732d47ae6c627dcb5e477
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/Runtime/VX.AI.Runtime.asmdef:
--------------------------------------------------------------------------------
1 | {
2 | "name": "VX.AI.Runtime",
3 | "rootNamespace": "",
4 | "references": [],
5 | "includePlatforms": [],
6 | "excludePlatforms": [],
7 | "allowUnsafeCode": false,
8 | "overrideReferences": false,
9 | "precompiledReferences": [],
10 | "autoReferenced": true,
11 | "defineConstraints": [],
12 | "versionDefines": [],
13 | "noEngineReferences": false
14 | }
--------------------------------------------------------------------------------
/Runtime/VX.AI.Runtime.asmdef.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 7ae4ce4d8e4e49d4a92d13182b6377ed
3 | AssemblyDefinitionImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "voxell.ai",
3 | "displayName": "VX AI",
4 | "author": "Nixon",
5 | "description": "AI intergration in Unity.",
6 | "keywords": [
7 | "AI",
8 | "artificial intelligence",
9 | "voxell"
10 | ],
11 | "license": "Apache 2.0",
12 | "unity": "2019.4",
13 | "unityRelease": "0f1",
14 | "version": "1.0.0"
15 | }
--------------------------------------------------------------------------------
/package.json.meta:
--------------------------------------------------------------------------------
1 | fileFormatVersion: 2
2 | guid: 599ff17882929a64199e9cb7d2fe86b8
3 | PackageManifestImporter:
4 | externalObjects: {}
5 | userData:
6 | assetBundleName:
7 | assetBundleVariant:
8 |
--------------------------------------------------------------------------------