Skip to content

Commit 4e27add

Browse files
committed
Update README
1 parent 8e40446 commit 4e27add

File tree

6 files changed

+45
-38
lines changed

6 files changed

+45
-38
lines changed

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ gen_model.visualize_model()
5353
```
5454

5555
>theta:0.7
56-
>x0:[1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1]
57-
>x1:[1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1]
58-
>x2:[0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1]
59-
>x3:[1 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0]
60-
>x4:[1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1]
56+
>x0:[1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1]
57+
>x1:[1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0]
58+
>x2:[1 0 1 1 0 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1]
59+
>x3:[1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 1]
60+
>x4:[0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1]
6161
>![bernoulli_example1](./doc/images/README_ex_img1.png)
6262
6363
After confirming that the frequency of occurrence of 1 is around `theta=0.7`, we generate a sample and store it to variable `x`.
@@ -99,9 +99,9 @@ print(learn_model.estimate_params(loss='abs'))
9999
print(learn_model.estimate_params(loss='0-1'))
100100
```
101101

102-
>0.6428571428571429
103-
>0.6474720009710451
104-
>0.6578947368421053
102+
>0.7380952380952381
103+
>0.7457656349087012
104+
>0.7631578947368421
105105
106106
Different settings of a loss function yield different optimal estimates.
107107

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

121125
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.
122126

@@ -131,11 +135,8 @@ When you use BayesML for your academic work, please provide the following biblio
131135
Plain text
132136

133137
```
134-
Y. Nakahara, N. Ichijo, K. Shimada,
135-
K. Tajima, K. Horinouchi, L. Ruan,
136-
N. Namegaya, R. Maniwa, T. Ishiwatari,
137-
W. Yu, Y. Iikubo, S. Saito,
138-
K. Kazama, T. Matsushima, ``BayesML,''
138+
Y. Nakahara, N. Ichijo, K. Shimada, Y. Iikubo,
139+
S. Saito, K. Kazama, T. Matsushima, ``BayesML,''
139140
[Online] https://github.com/yuta-nakahara/BayesML
140141
```
141142

@@ -144,9 +145,7 @@ BibTeX
144145
``` bibtex
145146
@misc{bayesml,
146147
author = {Nakahara Yuta and Ichijo Naoki and Shimada Koshi and
147-
Tajima Keito and Horinouchi Kohei and Ruan Luyu and
148-
Namegaya Noboru and Maniwa Ryota and Ishiwatari Taisuke and
149-
Yu Wenbin and Iikubo Yuji and Saito Shota and Kazama Koki and
148+
Iikubo Yuji and Saito Shota and Kazama Koki and
150149
Matsushima Toshiyasu}
151150
title = {BayesML},
152151
howpublished = {\url{https://github.com/yuta-nakahara/BayesML}},

README_jp.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ gen_model.visualize_model()
5252
```
5353

5454
>theta:0.7
55-
>x0:[1 1 1 1 1 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1]
56-
>x1:[1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1]
57-
>x2:[0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 1 1 1]
58-
>x3:[1 0 1 1 1 1 1 0 0 0 1 0 0 1 0 1 1 0 1 0]
59-
>x4:[1 1 0 1 0 1 1 1 0 1 1 1 0 0 1 1 1 1 1 1]
55+
>x0:[1 1 1 0 1 1 1 0 1 1 1 1 1 1 0 1 1 1 0 1]
56+
>x1:[1 1 0 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 0]
57+
>x2:[1 0 1 1 0 1 1 1 0 1 1 1 1 1 0 0 1 1 1 1]
58+
>x3:[1 1 1 0 1 1 0 1 0 0 0 0 1 0 1 1 1 1 1 1]
59+
>x4:[0 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1]
6060
>![bernoulli_example1](./doc/images/README_ex_img1.png)
6161
6262
1の出現頻度が`theta=0.7`程度であることを確認したら,サンプルを生成し変数`x`に保存します.
@@ -96,9 +96,9 @@ print(learn_model.estimate_params(loss='abs'))
9696
print(learn_model.estimate_params(loss='0-1'))
9797
```
9898

99-
>0.6428571428571429
100-
>0.6474720009710451
101-
>0.6578947368421053
99+
>0.7380952380952381
100+
>0.7457656349087012
101+
>0.7631578947368421
102102
103103
損失関数の設定が異なると,そのもとでの最適な推定値も異なることがわかります.
104104

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

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

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

130134
```
131-
Y. Nakahara, N. Ichijo, K. Shimada,
132-
K. Tajima, K. Horinouchi, L. Ruan,
133-
N. Namegaya, R. Maniwa, T. Ishiwatari,
134-
W. Yu, Y. Iikubo, S. Saito,
135-
K. Kazama, T. Matsushima, ``BayesML,''
135+
Y. Nakahara, N. Ichijo, K. Shimada, Y. Iikubo,
136+
S. Saito, K. Kazama, T. Matsushima, ``BayesML,''
136137
[Online] https://github.com/yuta-nakahara/BayesML
137138
```
138139

@@ -141,9 +142,7 @@ BibTeX
141142
``` bibtex
142143
@misc{bayesml,
143144
author = {Nakahara Yuta and Ichijo Naoki and Shimada Koshi and
144-
Tajima Keito and Horinouchi Kohei and Ruan Luyu and
145-
Namegaya Noboru and Maniwa Ryota and Ishiwatari Taisuke and
146-
Yu Wenbin and Iikubo Yuji and Saito Shota and Kazama Koki and
145+
Iikubo Yuji and Saito Shota and Kazama Koki and
147146
Matsushima Toshiyasu}
148147
title = {BayesML},
149148
howpublished = {\url{https://github.com/yuta-nakahara/BayesML}},

bayesml/_test.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
from bayesml import contexttree
1+
from bayesml import bernoulli
2+
3+
gen_model = bernoulli.GenModel(theta=0.7)
24

3-
gen_model = contexttree.GenModel(c_k=2,c_d_max=3,h_g=0.75)
4-
gen_model.gen_params()
55
gen_model.visualize_model()
6-
x = gen_model.gen_sample(500)
7-
learn_model = contexttree.LearnModel(c_k=2,c_d_max=3)
6+
7+
x = gen_model.gen_sample(sample_size=20)
8+
9+
learn_model = bernoulli.LearnModel()
10+
11+
learn_model.visualize_posterior()
12+
813
learn_model.update_posterior(x)
9-
# learn_model.visualize_posterior()
14+
learn_model.visualize_posterior()
15+
16+
print(learn_model.estimate_params(loss='squared'))
17+
print(learn_model.estimate_params(loss='abs'))
18+
print(learn_model.estimate_params(loss='0-1'))

doc/images/README_ex_img1.png

4.62 KB
Loading

doc/images/README_ex_img2.png

5.89 KB
Loading

doc/images/README_ex_img3.png

3.84 KB
Loading

0 commit comments

Comments
 (0)