File size: 1,221 Bytes
484e3bc |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
"""
Visualization utilities for GeoBotv1
"""
import numpy as np
from typing import Optional
import matplotlib.pyplot as plt
def plot_scenario_distribution(
scenarios: list,
feature: str,
output_path: Optional[str] = None
) -> None:
"""
Plot distribution of scenarios for a feature.
Parameters
----------
scenarios : list
List of scenarios
feature : str
Feature to plot
output_path : str, optional
Path to save plot
"""
values = [s.features.get(feature, [0])[0] for s in scenarios]
probabilities = [s.probability for s in scenarios]
plt.figure(figsize=(10, 6))
plt.hist(values, weights=probabilities, bins=30, alpha=0.7, edgecolor='black')
plt.xlabel(feature)
plt.ylabel('Probability')
plt.title(f'Distribution of {feature}')
plt.grid(True, alpha=0.3)
if output_path:
plt.savefig(output_path)
else:
plt.show()
def plot_causal_graph(graph, output_path: Optional[str] = None) -> None:
"""
Plot causal graph.
Parameters
----------
graph : CausalGraph
Graph to plot
output_path : str, optional
Path to save plot
"""
graph.visualize(output_path)
|