Skip to content

Release 0.2.0 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 186 commits into from
Nov 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
dc01124
Create gaussianmixture.md
yuta-nakahara Jun 6, 2022
6b48f22
Create metatree.md
yuta-nakahara Jun 6, 2022
1e37aa3
Merge branch 'main' into develop-metatree-resume
yuta-nakahara Jun 10, 2022
01f469e
Merge branch 'main' into develop-gaussianmixture-resume
yuta-nakahara Jun 10, 2022
c416640
Basic structure of MTRF
yuta-nakahara Jun 17, 2022
b91a005
meta-tree resume
SaitoGunma Jul 8, 2022
c3701cb
Update metatree.md
SaitoGunma Jul 13, 2022
a4483d8
Update metatree.md
yuta-nakahara Jul 17, 2022
e94b8c3
Merge pull request #14 from yuta-nakahara/develop-metatree-resume
yuta-nakahara Jul 17, 2022
bdd7394
Merge branch 'develop-metatree' into develop-metatree-categorical_x
yuta-nakahara Jul 17, 2022
e7d01c9
Update MAP recursion
yuta-nakahara Jul 18, 2022
bb346cb
Update gaussianmixture.md
yuta-nakahara Jul 20, 2022
5d9c087
Create gaussianmixture_for_pdf.md
yuta-nakahara Jul 20, 2022
26b1b9e
Create hiddenmarkovnormal.md
yuta-nakahara Jul 21, 2022
3fcf9ab
Create contexttree.md
yuta-nakahara Jul 21, 2022
52d88bf
Create hiddenmarkovautoregressive.md
yuta-nakahara Jul 21, 2022
f523912
Update hiddenmarkovnormal.md
RyoheiO Jul 30, 2022
19868d1
Update hiddenmarkovnormal.md
RyoheiO Jul 30, 2022
1bd1f87
write generative model
RyoheiO Jul 30, 2022
6aeabad
Update HMM resume
RyoheiO Jul 31, 2022
b8d3942
Update hiddenmarkovnormal.md
RyoheiO Aug 2, 2022
9d4615e
Update hiddenmarkovautoregressive.md
yuta-nakahara Aug 3, 2022
276b81a
revise hparams of bernoulli
yuta-nakahara Aug 4, 2022
465eb80
revise h_params of categorical
yuta-nakahara Aug 4, 2022
9cd63b8
revise h_params of poisson
yuta-nakahara Aug 4, 2022
242818c
revise h_params of normal
yuta-nakahara Aug 4, 2022
19b4fb3
revise h_params of multivariate_normal
yuta-nakahara Aug 4, 2022
b77e0a8
revise h_params of exponential
yuta-nakahara Aug 4, 2022
6259fff
revise h_params of linearregression
yuta-nakahara Aug 4, 2022
a99eead
revise h_params of autoregressive
yuta-nakahara Aug 4, 2022
6f20685
update documents
yuta-nakahara Aug 4, 2022
1aaa6fc
Response to reviews
yuta-nakahara Aug 4, 2022
cb97d6d
Merge pull request #19 from yuta-nakahara/develop-revise_hparams
yuta-nakahara Aug 4, 2022
6d98e1d
Merge pull request #17 from yuta-nakahara/develop-hiddenmarkovnormal-…
yuta-nakahara Aug 7, 2022
be1c930
Create virtualenv.md
yuta-nakahara Aug 8, 2022
452c28e
Merge pull request #22 from yuta-nakahara/develop-doc-virtualenv
yuta-nakahara Aug 8, 2022
0ff39a8
Add pos_def_sym_mats
yuta-nakahara Aug 9, 2022
4c8237d
Merge branch 'develop' into develop-hiddenmarkovnormal
yuta-nakahara Aug 9, 2022
4b83991
Merge branch 'develop-check' into develop-hiddenmarkovnormal
yuta-nakahara Aug 9, 2022
e5915fc
Merge branch 'develop' into develop-metatree
yuta-nakahara Aug 9, 2022
1a0c961
Merge branch 'develop-check' into develop-metatree
yuta-nakahara Aug 9, 2022
1dff832
Merge branch 'develop-metatree' into develop-metatree-categorical_x
yuta-nakahara Aug 9, 2022
13fced1
レジュメの修正
1jonao Aug 11, 2022
cd82991
Merge pull request #15 from yuta-nakahara/develop-gaussianmixture-resume
1jonao Aug 11, 2022
f247c6d
Add files via upload
kkkzmwsd Aug 25, 2022
28054a1
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
5cd4b92
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
cd0ec46
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
a7b415a
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
b21e930
Create hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
2360a2f
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
f0ccfaf
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 2, 2022
4fb4c20
Update hiddenmarkovautoregressive.md
kkkzmwsd Sep 3, 2022
7d2ac37
Delete hiddenmarkovautoregressive.md
kkkzmwsd Sep 3, 2022
2008345
Merge pull request #23 from yuta-nakahara/develop-hiddenmarkovautoreg…
yuta-nakahara Sep 3, 2022
5a9ccff
init, get, set
yuta-nakahara Sep 4, 2022
7b20449
gen, visualize
yuta-nakahara Sep 4, 2022
6fbbdeb
Merge pull request #24 from yuta-nakahara/develop-gaussianmixture-gen…
yuta-nakahara Sep 4, 2022
3843027
Add float_vecs_sum_1
yuta-nakahara Sep 7, 2022
239f0a2
start my work
NJ-private Sep 11, 2022
849c69d
add params for data generation without hyper params
NJ-private Sep 11, 2022
ad521e8
add params for data generation without hyper params
NJ-private Sep 11, 2022
5191554
update posterior distribution and predictive distributio
RyoheiO Sep 17, 2022
6df9a50
make self.__init__() for hiddenmarkovautoregressive and add check dim…
NJ-private Sep 18, 2022
0708936
add set_h_params
NJ-private Sep 18, 2022
9723a6d
add new check consistency
NJ-private Sep 23, 2022
539e963
bug fix
NJ-private Sep 23, 2022
8a37e7a
some modify
NJ-private Oct 2, 2022
fbecc1b
set, get, and so on
yuta-nakahara Oct 8, 2022
a081ced
variational lower bound
yuta-nakahara Oct 8, 2022
ac6208c
some modify
NJ-private Oct 9, 2022
b564e50
updating rule of VB
yuta-nakahara Oct 9, 2022
bb82eb4
add set_params and get_params and some modify of __init__
NJ-private Oct 9, 2022
37fa84d
init function
yuta-nakahara Oct 9, 2022
8522517
Merge branch 'develop-check' into develop-hiddenmarkovnormal-initgetset
yuta-nakahara Oct 9, 2022
8a03f2c
Merge branch 'develop-hiddenmarkovautoregressive-GenModel' into devel…
yuta-nakahara Oct 9, 2022
c09204f
add set_params
NJ-private Oct 9, 2022
571a7c0
little modify
NJ-private Oct 9, 2022
df0f3f2
visualize_posterior
yuta-nakahara Oct 9, 2022
a6e6e0d
make_prediction and pred_and_update
yuta-nakahara Oct 9, 2022
d7ee395
estimate_latent_vars
yuta-nakahara Oct 9, 2022
51d4fc2
revise GenModel h_params size
yuta-nakahara Oct 10, 2022
663a432
Merge pull request #27 from yuta-nakahara/develop-gaussianmixture-Lea…
yuta-nakahara Oct 10, 2022
9cd44c2
modify set_params and add shape_consistency
NJ-private Oct 10, 2022
bd174ef
little modify and add set_h_params before eta and zeta
NJ-private Oct 10, 2022
2a1aeaa
Add shape_consistency
yuta-nakahara Oct 11, 2022
4bbe731
Revise shape_consistency
yuta-nakahara Oct 11, 2022
69d052a
little modification of shape_consistency
yuta-nakahara Oct 11, 2022
de87b59
Merge branch 'develop-check' into develop-hiddenmarkovnormal-initgetset
yuta-nakahara Oct 11, 2022
5ca3907
bug fix for checking pi_vec
yuta-nakahara Oct 11, 2022
b38b5f4
bug fix for lambda_mats initialization
yuta-nakahara Oct 11, 2022
d066598
Revise set_params and set_h_params
yuta-nakahara Oct 11, 2022
e458e3c
Added get_params and get_h_params
yuta-nakahara Oct 12, 2022
dc67df4
Add set, get, etc to LearnModel
yuta-nakahara Oct 12, 2022
f921cae
Revise reset_hn_params and overwrite_h0_params
yuta-nakahara Oct 13, 2022
b0ed3b0
Merge branch 'develop-base' into develop-hiddenmarkovnormal-initgetset
yuta-nakahara Oct 13, 2022
ff1d77e
Delete rest_hn_params and overwrite_h0_params
yuta-nakahara Oct 13, 2022
1b47a2a
Merge branch 'develop-base' into develop-gaussianmixture
yuta-nakahara Oct 13, 2022
33028ba
Delete reset_hn_params and overwrite_h0_params
yuta-nakahara Oct 13, 2022
fd91b6b
little modify
yuta-nakahara Oct 13, 2022
8bfd21a
Merge pull request #30 from yuta-nakahara/develop-hiddenmarkovnormal-…
yuta-nakahara Oct 13, 2022
76667f1
Update hiddenmarkovnormal.md
RyoheiO Oct 22, 2022
a13ad15
Revise posterior and predictive distribution
yuta-nakahara Oct 27, 2022
13cb44b
Merge pull request #25 from yuta-nakahara/develop-hiddenmarkovnormal-…
yuta-nakahara Oct 27, 2022
2985615
Merge branch 'develop-check' into develop-metatree-categorical_x
yuta-nakahara Oct 28, 2022
d9e6699
Merge pull request #32 from yuta-nakahara/develop-base
yuta-nakahara Nov 14, 2022
36c0863
Merge pull request #33 from yuta-nakahara/develop-check
yuta-nakahara Nov 14, 2022
16afc3a
Update documents
yuta-nakahara Nov 15, 2022
dc8baf8
Merge pull request #34 from yuta-nakahara/develop-devdoc
yuta-nakahara Nov 15, 2022
e75d31d
Update docstring_rule.md
yuta-nakahara Nov 15, 2022
839db19
Update docstring_rule.md
yuta-nakahara Nov 15, 2022
d0d54b8
Merge pull request #36 from yuta-nakahara/develop-devdoc
yuta-nakahara Nov 15, 2022
2b85559
Merge branch 'develop' into develop-metatree-categorical_x
yuta-nakahara Nov 15, 2022
4984f95
Revise var name of constants
yuta-nakahara Nov 15, 2022
7f5a3cc
Update development_flow.md
yuta-nakahara Nov 15, 2022
f771ec2
Merge branch 'develop' into develop-metatree-categorical_x
yuta-nakahara Nov 15, 2022
8f96057
Revise set_ functions of LearnModel
yuta-nakahara Nov 15, 2022
40aef2c
Update docstring_rule.md
yuta-nakahara Nov 15, 2022
88dee13
Update _check.py
yuta-nakahara Nov 15, 2022
549d78a
Merge branch 'develop-check' into develop-metatree-categorical_x
yuta-nakahara Nov 15, 2022
4a863ac
Update _check.py
yuta-nakahara Nov 15, 2022
94d796b
Merge branch 'develop-check' into develop-metatree-categorical_x
yuta-nakahara Nov 15, 2022
21c7e16
Add docstring for LearnModel
yuta-nakahara Nov 15, 2022
9246b55
Revise GenModel
yuta-nakahara Nov 16, 2022
d1a9410
Add dict_out option to estimate_params
yuta-nakahara Nov 16, 2022
72b0465
poisson and exponential leaf node
yuta-nakahara Nov 16, 2022
77ce7db
Merge pull request #37 from yuta-nakahara/develop-metatree-categorical_x
yuta-nakahara Nov 17, 2022
d1e199a
Merge branch 'develop' into develop-hiddenmarkovnormal-GenModel
yuta-nakahara Nov 17, 2022
8edd787
Create _gaussianmixture_for_ref.py
yuta-nakahara Nov 17, 2022
cb81f22
Add docstring
yuta-nakahara Nov 17, 2022
9b7dc1d
Add gen_ and visualize
yuta-nakahara Nov 17, 2022
6d2d639
Merge pull request #38 from yuta-nakahara/develop-hiddenmarkovnormal-…
yuta-nakahara Nov 17, 2022
bc51400
Add docstring
yuta-nakahara Nov 17, 2022
151f00a
Add calc_vl
yuta-nakahara Nov 18, 2022
904f1f8
Revise _init_subsampling
yuta-nakahara Nov 19, 2022
07ec7e4
Add VB alg
yuta-nakahara Nov 19, 2022
8ce2296
Initialization bug fix
yuta-nakahara Nov 19, 2022
9537119
Add visualize_posterior
yuta-nakahara Nov 19, 2022
757ac61
Add pred functions
yuta-nakahara Nov 19, 2022
4e1bccb
Add estimate_latent_vars
yuta-nakahara Nov 19, 2022
b3f1672
Merge pull request #39 from yuta-nakahara/develop-hiddenmarkovnormal-…
yuta-nakahara Nov 19, 2022
8e1f232
Update contexttree.md
yuta-nakahara Nov 19, 2022
0109468
Merge pull request #40 from yuta-nakahara/develop-contexttree-resume
yuta-nakahara Nov 19, 2022
ae01e36
Update contexttree.md
yuta-nakahara Nov 19, 2022
4a282f3
Merge branch 'develop' into develop-contexttree-GenModel
yuta-nakahara Nov 19, 2022
ce01ae0
Create _hiddenmarkovnormal_for_ref.py
yuta-nakahara Nov 19, 2022
bca97f0
Add init, get, set
yuta-nakahara Nov 20, 2022
61105a7
Update _metatree_x_discrete.py
yuta-nakahara Nov 20, 2022
d89d42b
Add gen and visualize
yuta-nakahara Nov 20, 2022
7ee15bb
Merge pull request #41 from yuta-nakahara/develop-contexttree-GenModel
yuta-nakahara Nov 20, 2022
6bc5ace
Remove comment out
yuta-nakahara Nov 20, 2022
fd64ba2
Add init get set
yuta-nakahara Nov 20, 2022
6bd27fa
Update gen_sample
yuta-nakahara Nov 20, 2022
460a0d2
Fix map_recursion bug
yuta-nakahara Nov 20, 2022
5f762db
Add update and visualize posterior
yuta-nakahara Nov 20, 2022
4e22358
Fix make_prediction bug
yuta-nakahara Nov 20, 2022
42b35cd
Add methods for pred dist
yuta-nakahara Nov 20, 2022
71e8816
Merge pull request #42 from yuta-nakahara/develop-contexttree-LearnModel
yuta-nakahara Nov 20, 2022
d24d01a
Update _metatree_x_discrete.py
yuta-nakahara Nov 20, 2022
0938a83
Remove unnecessary files
yuta-nakahara Nov 20, 2022
c74e32d
Merge pull request #43 from yuta-nakahara/develop-gaussianmixture
yuta-nakahara Nov 20, 2022
fc9e382
Remove unnecessary files
yuta-nakahara Nov 20, 2022
86eb7dd
Delete __init__.py
yuta-nakahara Nov 20, 2022
156ae33
Delete hiddenmarkovautoregressive.md
yuta-nakahara Nov 20, 2022
a46a031
Delete _hiddenmarkovautoregressive.py
yuta-nakahara Nov 20, 2022
bc14ef9
Merge branch 'develop-check' into develop-hiddenmarkovnormal
yuta-nakahara Nov 20, 2022
e9df92d
Update _check.py
yuta-nakahara Nov 20, 2022
ecd526a
Merge pull request #44 from yuta-nakahara/develop-hiddenmarkovnormal
yuta-nakahara Nov 20, 2022
132f30a
Remove unnecessary files
yuta-nakahara Nov 20, 2022
cc286c6
Merge branch 'develop' into develop-metatree
yuta-nakahara Nov 20, 2022
2c8d809
Merge pull request #45 from yuta-nakahara/develop-metatree
yuta-nakahara Nov 20, 2022
41fc67f
Remove unnecessary files
yuta-nakahara Nov 20, 2022
4068a05
Add an image of visualized posterior
yuta-nakahara Nov 20, 2022
5e55d55
Update _contexttree.py
yuta-nakahara Nov 20, 2022
cb49b4c
Merge pull request #46 from yuta-nakahara/develop-contexttree
yuta-nakahara Nov 20, 2022
b77ce3e
Update __init__.py
yuta-nakahara Nov 20, 2022
8e40446
Fix bugs
yuta-nakahara Nov 20, 2022
4e27add
Update README
yuta-nakahara Nov 20, 2022
d7e9638
Update README
yuta-nakahara Nov 20, 2022
1bfde55
Modification for web pages
yuta-nakahara Nov 20, 2022
e48b610
Create web pages
yuta-nakahara Nov 20, 2022
da95462
Merge branch 'main' into release
yuta-nakahara Nov 20, 2022
65b9d65
Delete _test.py
yuta-nakahara Nov 20, 2022
e2f1bf3
Update setup.py
yuta-nakahara Nov 20, 2022
7055efa
Merge branch 'release' of https://github.com/yuta-nakahara/BayesML in…
yuta-nakahara Nov 20, 2022
e1033b3
Update setup.py
yuta-nakahara Nov 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ For more details, see our [website](https://yuta-nakahara.github.io/BayesML/ "Ba

Please use the following commands to install BayesML.

``` shell
``` bash
pip install bayesml
```

Expand All @@ -33,6 +33,7 @@ The following are required.
* NumPy (>= 1.20)
* SciPy (>= 1.7)
* MatplotLib (>= 3.5)
* Scikit-learn (>= 1.1)

## Example

Expand All @@ -53,11 +54,11 @@ gen_model.visualize_model()
```

>theta:0.7
>x0:[1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1]
>x1:[1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1]
>x2:[0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1]
>x3:[1 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0]
>x4:[1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1]
>x0:[1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1]
>x1:[1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0]
>x2:[1 0 1 1 0 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1]
>x3:[1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 1]
>x4:[0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1]
>![bernoulli_example1](./doc/images/README_ex_img1.png)

After confirming that the frequency of occurrence of 1 is around `theta=0.7`, we generate a sample and store it to variable `x`.
Expand Down Expand Up @@ -99,9 +100,9 @@ print(learn_model.estimate_params(loss='abs'))
print(learn_model.estimate_params(loss='0-1'))
```

>0.6428571428571429
>0.6474720009710451
>0.6578947368421053
>0.7380952380952381
>0.7457656349087012
>0.7631578947368421

Different settings of a loss function yield different optimal estimates.

Expand All @@ -115,8 +116,12 @@ The following packages are currently available. In this library, a probabilistic
* [Normal model](https://yuta-nakahara.github.io/BayesML/bayesml.normal.html "BayesML Normal Model")
* [Multivariate normal model](https://yuta-nakahara.github.io/BayesML/bayesml.multivariate_normal.html "BayesML Multivariate Normal Model")
* [Exponential model](https://yuta-nakahara.github.io/BayesML/bayesml.exponential.html "BayesML Exponential Model")
* [Gaussian mixture model](https://yuta-nakahara.github.io/BayesML/bayesml.gaussianmixture.html "BayesML Gaussian Mixture Model")
* [Linear regression model](https://yuta-nakahara.github.io/BayesML/bayesml.linearregression.html "BayesML Lenear Regression Model")
* [Meta-tree model](https://yuta-nakahara.github.io/BayesML/bayesml.metatree.html "BayesML Meta-tree Model")
* [Autoregressive model](https://yuta-nakahara.github.io/BayesML/bayesml.autoregressive.html "BayesML Autoregressive Model")
* [Hidden Markov normal model](https://yuta-nakahara.github.io/BayesML/bayesml.hiddenmarkovnormal.html "BayesML Hidden Markov Normal Model")
* [Context tree model](https://yuta-nakahara.github.io/BayesML/bayesml.contexttree.html "BayesML Context Tree Model")

In the future, we will add packages to deal with a mixture normal model and a hidden Markov model, which are difficult to perform exact Bayesian inference, by using variational Bayes methods.

Expand All @@ -131,11 +136,8 @@ When you use BayesML for your academic work, please provide the following biblio
Plain text

```
Y. Nakahara, N. Ichijo, K. Shimada,
K. Tajima, K. Horinouchi, L. Ruan,
N. Namegaya, R. Maniwa, T. Ishiwatari,
W. Yu, Y. Iikubo, S. Saito,
K. Kazama, T. Matsushima, ``BayesML,''
Y. Nakahara, N. Ichijo, K. Shimada, Y. Iikubo,
S. Saito, K. Kazama, T. Matsushima, ``BayesML 0.2.0,''
[Online] https://github.com/yuta-nakahara/BayesML
```

Expand All @@ -144,11 +146,9 @@ BibTeX
``` bibtex
@misc{bayesml,
author = {Nakahara Yuta and Ichijo Naoki and Shimada Koshi and
Tajima Keito and Horinouchi Kohei and Ruan Luyu and
Namegaya Noboru and Maniwa Ryota and Ishiwatari Taisuke and
Yu Wenbin and Iikubo Yuji and Saito Shota and Kazama Koki and
Matsushima Toshiyasu},
title = {BayesML},
Iikubo Yuji and Saito Shota and Kazama Koki and
Matsushima Toshiyasu}
title = {BayesML 0.2.0},
howpublished = {\url{https://github.com/yuta-nakahara/BayesML}},
year = {2022}
}
Expand Down
34 changes: 17 additions & 17 deletions README_jp.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ BayesMLは以下の特徴を持っています.

以下のコマンドによりインストール可能です.

``` shell
``` bash
pip install bayesml
```

Expand All @@ -32,6 +32,7 @@ BayesMLの実行には以下が必要です.
* NumPy (>= 1.20)
* SciPy (>= 1.7)
* MatplotLib (>= 3.5)
* Scikit-learn (>= 1.1)

## 実行例

Expand All @@ -52,11 +53,11 @@ gen_model.visualize_model()
```

>theta:0.7
>x0:[1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1]
>x1:[1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1]
>x2:[0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1]
>x3:[1 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0]
>x4:[1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1]
>x0:[1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1]
>x1:[1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0]
>x2:[1 0 1 1 0 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1]
>x3:[1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 1]
>x4:[0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1]
>![bernoulli_example1](./doc/images/README_ex_img1.png)

1の出現頻度が`theta=0.7`程度であることを確認したら,サンプルを生成し変数`x`に保存します.
Expand Down Expand Up @@ -96,9 +97,9 @@ print(learn_model.estimate_params(loss='abs'))
print(learn_model.estimate_params(loss='0-1'))
```

>0.6428571428571429
>0.6474720009710451
>0.6578947368421053
>0.7380952380952381
>0.7457656349087012
>0.7631578947368421

損失関数の設定が異なると,そのもとでの最適な推定値も異なることがわかります.

Expand All @@ -112,8 +113,12 @@ print(learn_model.estimate_params(loss='0-1'))
* [正規モデル](https://yuta-nakahara.github.io/BayesML/bayesml.normal.html "BayesML Normal Model")
* [多変量正規モデル](https://yuta-nakahara.github.io/BayesML/bayesml.multivariate_normal.html "BayesML Multivariate Normal Model")
* [指数モデル](https://yuta-nakahara.github.io/BayesML/bayesml.exponential.html "BayesML Exponential Model")
* [混合正規モデル](https://yuta-nakahara.github.io/BayesML/bayesml.gaussianmixture.html "BayesML Gaussian Mixture Model")
* [線形回帰モデル](https://yuta-nakahara.github.io/BayesML/bayesml.linearregression.html "BayesML Lenear Regression Model")
* [メタツリーモデル](https://yuta-nakahara.github.io/BayesML/bayesml.metatree.html "BayesML Meta-tree Model")
* [自己回帰モデル](https://yuta-nakahara.github.io/BayesML/bayesml.autoregressive.html "BayesML Autoregressive Model")
* [隠れマルコフモデル](https://yuta-nakahara.github.io/BayesML/bayesml.hiddenmarkovnormal.html "BayesML Hidden Markov Normal Model")
* [文脈木モデル](https://yuta-nakahara.github.io/BayesML/bayesml.contexttree.html "BayesML Context Tree Model")

また,今後は混合正規モデルや隠れマルコフモデルなどの厳密なベイズ推論が困難なモデルを変分ベイズ法で学習するパッケージが追加される予定です.

Expand All @@ -128,11 +133,8 @@ BayesMLへのコントリビューションを考えてくださってありが
プレーンテキスト

```
Y. Nakahara, N. Ichijo, K. Shimada,
K. Tajima, K. Horinouchi, L. Ruan,
N. Namegaya, R. Maniwa, T. Ishiwatari,
W. Yu, Y. Iikubo, S. Saito,
K. Kazama, T. Matsushima, ``BayesML,''
Y. Nakahara, N. Ichijo, K. Shimada, Y. Iikubo,
S. Saito, K. Kazama, T. Matsushima, ``BayesML,''
[Online] https://github.com/yuta-nakahara/BayesML
```

Expand All @@ -141,9 +143,7 @@ BibTeX
``` bibtex
@misc{bayesml,
author = {Nakahara Yuta and Ichijo Naoki and Shimada Koshi and
Tajima Keito and Horinouchi Kohei and Ruan Luyu and
Namegaya Noboru and Maniwa Ryota and Ishiwatari Taisuke and
Yu Wenbin and Iikubo Yuji and Saito Shota and Kazama Koki and
Iikubo Yuji and Saito Shota and Kazama Koki and
Matsushima Toshiyasu}
title = {BayesML},
howpublished = {\url{https://github.com/yuta-nakahara/BayesML}},
Expand Down
10 changes: 9 additions & 1 deletion bayesml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
from . import multivariate_normal
from . import normal
from . import poisson
from . import metatree
from . import contexttree
from . import gaussianmixture
from . import hiddenmarkovnormal

__all__ = ['bernoulli',
'categorical',
Expand All @@ -14,5 +18,9 @@
'linearregression',
'multivariate_normal',
'normal',
'poisson'
'poisson',
'metatree',
'contexttree',
'gaussianmixture',
'hiddenmarkovnormal',
]
65 changes: 65 additions & 0 deletions bayesml/_check.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Code Author
# Yuta Nakahara <yuta.nakahara@aoni.waseda.jp>
# Yuji Iikubo <yuji-iikubo.8@fuji.waseda.jp>
# Yasushi Esaki <esakiful@gmail.com>
# Jun Nishikawa <jun.b.nishikawa@gmail.com>
import numpy as np

_EPSILON = np.sqrt(np.finfo(np.float64).eps)
Expand Down Expand Up @@ -45,12 +47,31 @@ def nonneg_ints(val,val_name,exception_class):
return val
raise(exception_class(val_name + " must be int or a numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)."))

def int_vec(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim == 1:
return val
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int."))

def nonneg_int_vec(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim == 1 and np.all(val>=0):
return val
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is int. Its values must be non-negative (including 0)."))

def nonneg_int_vecs(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(val>=0):
return val
raise(exception_class(val_name + " must be a numpy.ndarray whose ndim >= 1 and dtype is int. Its values must be non-negative (including 0)."))


def nonneg_float_vec(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.floating) and val.ndim == 1 and np.all(val>=0):
return val
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray whose dtype is float. Its values must be non-negative (including 0)."))

def int_of_01(val,val_name,exception_class):
if np.issubdtype(type(val),np.integer):
if val == 0 or val ==1:
Expand Down Expand Up @@ -100,6 +121,22 @@ def pos_def_sym_mat(val,val_name,exception_class):
pass
raise(exception_class(val_name + " must be a positive definite symmetric 2-dimensional numpy.ndarray."))

def sym_mats(val,val_name,exception_class):
if type(val) is np.ndarray:
if val.ndim >= 2 and val.shape[-1] == val.shape[-2]:
if np.allclose(val, np.swapaxes(val,-1,-2)):
return val
raise(exception_class(val_name + " must be a symmetric 2-dimensional numpy.ndarray."))

def pos_def_sym_mats(val,val_name,exception_class):
sym_mats(val,val_name,exception_class)
try:
np.linalg.cholesky(val)
return val
except np.linalg.LinAlgError:
pass
raise(exception_class(val_name + " must be a positive definite symmetric 2-dimensional numpy.ndarray."))

def float_(val,val_name,exception_class):
if np.issubdtype(type(val),np.floating):
return val
Expand Down Expand Up @@ -155,6 +192,14 @@ def float_vecs(val,val_name,exception_class):
return val
raise(exception_class(val_name + " must be a numpy.ndarray whose ndim >= 1."))

def pos_float_vecs(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(val>0):
return val.astype(float)
if np.issubdtype(val.dtype,np.floating) and val.ndim >= 1 and np.all(val>0.0):
return val
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray. Its values must be positive (not including 0)"))

def float_vec_sum_1(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim == 1 and abs(val.sum() - 1.) <= _EPSILON:
Expand All @@ -163,6 +208,14 @@ def float_vec_sum_1(val,val_name,exception_class):
return val
raise(exception_class(val_name + " must be a 1-dimensional numpy.ndarray, and the sum of its elements must equal to 1."))

def float_vecs_sum_1(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(np.abs(np.sum(val, axis=-1) - 1.) <= _EPSILON):
return val.astype(float)
if np.issubdtype(val.dtype,np.floating) and val.ndim >= 1 and np.all(np.abs(np.sum(val, axis=-1) - 1.) <= _EPSILON):
return val
raise(exception_class(val_name + " must be a numpy.ndarray whose ndim >= 1, and the sum along the last dimension must equal to 1."))

def int_(val,val_name,exception_class):
if np.issubdtype(type(val),np.integer):
return val
Expand All @@ -189,3 +242,15 @@ def onehot_vecs(val,val_name,exception_class):
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1 and np.all(val >= 0) and np.all(val.sum(axis=-1)==1):
return val
raise(exception_class(val_name + " must be a numpy.ndarray whose dtype is int and whose last axis constitutes one-hot vectors."))

def int_vecs(val,val_name,exception_class):
if type(val) is np.ndarray:
if np.issubdtype(val.dtype,np.integer) and val.ndim >= 1:
return val
raise(exception_class(val_name + " must be a numpy.ndarray whose dtype is int and ndim >= 1."))

def shape_consistency(val: int, val_name: str, correct: int, correct_name: str, exception_class):
if val != correct:
message = (f"{val_name} must coincide with {correct_name}: "
+ f"{val_name} = {val}, {correct_name} = {correct}")
raise(exception_class(message))
Loading