Skip to content

Visualize

pyggdrasil.visualize.plot_tree(tree, save_name, save_dir, print_options, rename_labels=None)

Plot a tree and save it to a file.

Parameters:

Name Type Description Default
tree TreeNode

TreeNode tree to plot, given the root node tree.data: may contain info to print for tree / node e.g. "log-likelihood": float likelihood of the tree tree.name: name of tree, may use a title of plot

required
save_name str

str name of the file to save the plot to

required
save_dir Path

Path directory to save the plot to

required
print_options dict

dict options for printing the tree "title": bool whether to print the name/title of the tree/root "data_tree": dict what attributes to print of the tree

required
rename_labels Optional[dict[str, NodeLabel]]

dict dictionary of labels to rename {0:1, 1:2, 3:"IPC4", 4:"IPC5"} {old_label:new_label, ...} pass empty dict to not rename labels

None

Returns: None

Note

see tests/visualize/test_tree.py for example usage

pyggdrasil.visualize.save_metric_iteration(iteration, distances, metric_name, out_fp)

Save plot of distance to true tree vs iteration number to disk.

Parameters:

Name Type Description Default
iteration list[int]

list[int] Iteration numbers, 1-indexed.

required
out_fp Path

Path Output file path.

required
distances list[float]

ndarray Distances to true tree for each iteration.

required
metric_name str

str Name of distance metric.

required

pyggdrasil.visualize.save_log_p_iteration(iterations, log_probs, output_fp)

Save plot of log probability vs iteration number to disk.

Parameters:

Name Type Description Default
output_dir

Path Output directory to save the plot.

required
iterations list[int]

list[int] Iteration numbers, 1-indexed.

required
log_probs list[float]

list[float] Log probabilities.

required

pyggdrasil.visualize.plot_tree_mcmc_sample(sample, save_dir, save_name='')

Takes input of get_sample of PureMcmcData and , Plot a tree and save it to a file with just its iteration number and log probability, in the savename.

pyggdrasil.visualize.plot_tree_no_print(tree, save_name, save_dir)

Takes input of get_sample of PureMcmcData and , Plot a tree and save it to a file with just its iteration number and log probability, in the savename.

pyggdrasil.visualize.save_top_trees_plots(data, output_dir)

Save plots of top three trees by log probability to disk, with accompanying json to node the iterations.

Parameters:

Name Type Description Default
data

mcmc samples

required
output_dir

path to output directory

required

Returns:

Type Description
None

None

Saves

top_tree_1.svg top_tree_2.svg top_tree_3.svg top_trees_iterations.json

pyggdrasil.visualize.save_rhat_iteration(iteration, rhats, out_fp)

Save plot of rhat vs iteration number to disk.

Parameters:

Name Type Description Default
iteration list[int]

list[int] Iteration numbers.

required
out_fp Path

Path Output file path.

required
rhats list[float]

ndarray R hat values for each iteration.

required

pyggdrasil.visualize.save_rhat_iteration_AD_DL(iteration, rhats_AD, rhats_DL, out_fp)

Save plot of rhat vs iteration number to disk.

Parameters:

Name Type Description Default
iteration list[int]

list[int] Iteration numbers.

required
out_fp Path

Path Output file path.

required
rhats_AD list[float]

ndarray R hat values for each iteration for AD.

required
rhats_DL list[float]

ndarray R hat values for each iteration for DL.

required

pyggdrasil.visualize.save_ess_iteration_AD_DL(iteration, ess_bulk_AD, ess_bulk_DL, ess_tail_AD, ess_tail_DL, out_fp)

Save plot of ess vs iteration number to disk.

Parameters:

Name Type Description Default
iteration list[int]

list[int] Iteration numbers.

required
out_fp Path

Path Output file path.

required
TODO

add description

required