Skip to content

Commit 04cab6a

Browse files
committed
Revise visualize_model
1 parent 8b4e35c commit 04cab6a

File tree

4 files changed

+21
-26
lines changed

4 files changed

+21
-26
lines changed

bayesml/metatree/_metatree.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def __init__(
125125
self,
126126
c_dim_continuous,
127127
c_dim_categorical,
128-
c_max_depth=10,
128+
c_max_depth=2,
129129
c_num_children_vec=2,
130130
c_num_assignment_vec=None,
131131
c_ranges=None,
@@ -1002,26 +1002,20 @@ def visualize_model(self,filename=None,format=None,sample_size=100):
10021002
format : str, optional
10031003
Rendering output format (``\"pdf\"``, ``\"png\"``, ...).
10041004
sample_size : int, optional
1005-
A positive integer, by default 10
1005+
A positive integer, by default 100
10061006
10071007
Examples
10081008
--------
10091009
>>> from bayesml import metatree
1010-
>>> model = metatree.GenModel(c_k=3,h_g=0.75)
1010+
>>> model = metatree.GenModel(
1011+
>>> c_dim_continuous=1,
1012+
>>> c_dim_categorical=1)
1013+
>>> model.gen_params(threshold_type='random')
10111014
>>> model.visualize_model()
1012-
[[1 1 0]
1013-
[1 0 0]
1014-
[0 0 0]
1015-
[1 0 0]
1016-
[1 1 1]
1017-
[0 0 1]
1018-
[1 1 1]
1019-
[1 0 1]
1020-
[0 1 1]
1021-
[0 1 0]]
1022-
[0 1 0 1 0 0 0 1 0 0]
1023-
1024-
.. image:: ./images/metatree_example.png
1015+
1016+
.. image:: ./images/metatree_example1.png
1017+
1018+
.. image:: ./images/metatree_example2.png
10251019
10261020
See Also
10271021
--------

bayesml/metatree/metatree_test.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
from bayesml.metatree import GenModel
2-
from bayesml.metatree import LearnModel
1+
from bayesml import metatree
32
from bayesml import normal
43
from bayesml import poisson
54
from bayesml import bernoulli
65
import numpy as np
76
import copy
87

9-
gen_model = GenModel(1,1,2,h_g=0.75)
10-
gen_model.gen_params(threshold_type='random')
11-
gen_model.visualize_model('tree.pdf')
8+
model = metatree.GenModel(
9+
c_dim_continuous=1,
10+
c_dim_categorical=1)
11+
model.gen_params(threshold_type='random')
12+
model.visualize_model(format='png')
1213

13-
params = gen_model.get_params()
14-
constants = gen_model.get_constants()
14+
# params = gen_model.get_params()
15+
# constants = gen_model.get_constants()
1516

16-
gen_model2 = GenModel(**constants)
17-
gen_model2.set_params(**params)
18-
gen_model.visualize_model('tree2.pdf')
17+
# gen_model2 = GenModel(**constants)
18+
# gen_model2.set_params(**params)
19+
# gen_model.visualize_model('tree2.pdf')
1920

2021
# x_continuous,x_categorical,y = gen_model.gen_sample(3)
2122
# print(x_continuous)

doc/images/metatree_example1.png

25.4 KB
Loading

doc/images/metatree_example2.png

36 KB
Loading

0 commit comments

Comments
 (0)