Buckets:
| import matplotlib.pyplot as plt | |
| import seaborn as sns | |
| from typing import List, Dict, Tuple, Any, Optional | |
| class ProofVisualizer: | |
| def __init__(self, figsize=(12, 8)): | |
| self.figsize = figsize | |
| def visualize_proof_tree( | |
| self, | |
| proof_steps: List[str], | |
| confidence_scores: List[float] = None, | |
| save_path: Optional[str] = None, | |
| ) -> plt.Figure: | |
| fig, ax = plt.subplots(1, 1, figsize=self.figsize) | |
| y_positions = np.linspace(0.9, 0.1, len(proof_steps)) | |
| for i, (step, y) in enumerate(zip(proof_steps, y_positions)): | |
| if confidence_scores and i < len(confidence_scores): | |
| color = plt.cm.RdYlGn(confidence_scores[i]) | |
| else: | |
| color = "lightblue" | |
| circle = plt.Circle((0.5, y), 0.05, color=color, alpha=0.7) | |
| ax.add_patch(circle) | |
| ax.text( | |
| 0.6, y, f"Step {i+1}: {step}", fontsize=10, verticalalignment="center" | |
| ) | |
| if i < len(proof_steps) - 1: | |
| ax.plot( | |
| [0.5, 0.5], | |
| [y - 0.05, y_positions[i + 1] + 0.05], | |
| "k-", | |
| alpha=0.5, | |
| linewidth=1, | |
| ) | |
| ax.set_xlim(0, 1) | |
| ax.set_ylim(0, 1) | |
| ax.set_title("Proof Structure", fontsize=14, fontweight="bold") | |
| ax.axis("off") | |
| if save_path: | |
| plt.savefig(save_path, dpi=300, bbox_inches="tight") | |
| return fig | |
| def visualize_reasoning_flow( | |
| self, | |
| strategies: List[str], | |
| success_rates: List[float], | |
| save_path: Optional[str] = None, | |
| ) -> plt.Figure: | |
| fig, ax = plt.subplots(1, 1, figsize=self.figsize) | |
| x_positions = np.linspace(0.1, 0.9, len(strategies)) | |
| for i, (strategy, x) in enumerate(zip(strategies, x_positions)): | |
| size = 200 * success_rates[i] if i < len(success_rates) else 100 | |
| color = ( | |
| plt.cm.RdYlGn(success_rates[i]) if i < len(success_rates) else "gray" | |
| ) | |
| ax.scatter(x, 0.5, s=size, c=[color], alpha=0.7, edgecolors="black") | |
| ax.text( | |
| x, | |
| 0.3, | |
| strategy.replace("_", " ").title(), | |
| ha="center", | |
| va="top", | |
| fontsize=10, | |
| fontweight="bold", | |
| ) | |
| ax.text( | |
| x, | |
| 0.7, | |
| f"{success_rates[i]:.1%}" if i < len(success_rates) else "N/A", | |
| ha="center", | |
| va="bottom", | |
| fontsize=9, | |
| ) | |
| for i in range(len(strategies) - 1): | |
| ax.annotate( | |
| "", | |
| xy=(x_positions[i + 1], 0.5), | |
| xytext=(x_positions[i], 0.5), | |
| arrowprops=dict(arrowstyle="->", lw=2, alpha=0.7), | |
| ) | |
| ax.set_xlim(0, 1) | |
| ax.set_ylim(0, 1) | |
| ax.set_title("Reasoning Strategy Flow", fontsize=14, fontweight="bold") | |
| ax.axis("off") | |
| if save_path: | |
| plt.savefig(save_path, dpi=300, bbox_inches="tight") | |
| return fig | |
| def create_proof_explanation_chart( | |
| self, proof_data: Dict[str, Any], save_path: Optional[str] = None | |
| ) -> plt.Figure: | |
| fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=self.figsize) | |
| steps = proof_data.get("steps", []) | |
| step_numbers = list(range(1, len(steps) + 1)) | |
| ax1.plot(step_numbers, step_numbers, "o-", color="blue", alpha=0.7) | |
| ax1.set_title("Proof Steps Timeline") | |
| ax1.set_xlabel("Step Number") | |
| ax1.set_ylabel("Cumulative Progress") | |
| ax1.grid(True, alpha=0.3) | |
| theorems = proof_data.get("theorems_used", []) | |
| if theorems: | |
| theorem_counts = {} | |
| for theorem in theorems: | |
| theorem_counts[theorem] = theorem_counts.get(theorem, 0) + 1 | |
| ax2.bar(range(len(theorem_counts)), list(theorem_counts.values())) | |
| ax2.set_title("Theorem Usage") | |
| ax2.set_xlabel("Theorems") | |
| ax2.set_ylabel("Frequency") | |
| ax2.set_xticks(range(len(theorem_counts))) | |
| ax2.set_xticklabels(list(theorem_counts.keys()), rotation=45, ha="right") | |
| confidence = proof_data.get("confidence", 0) | |
| ax3.bar(["Overall"], [confidence], color="green", alpha=0.7) | |
| ax3.set_title("Proof Confidence") | |
| ax3.set_ylabel("Confidence Score") | |
| ax3.set_ylim(0, 1) | |
| strategy = proof_data.get("strategy", "unknown") | |
| strategies = ["neural", "coordinate", "synthetic", "hybrid"] | |
| strategy_scores = [0.8, 0.7, 0.6, 0.9] | |
| colors = ["red" if s == strategy else "lightgray" for s in strategies] | |
| ax4.bar(strategies, strategy_scores, color=colors, alpha=0.7) | |
| ax4.set_title("Strategy Performance") | |
| ax4.set_ylabel("Success Rate") | |
| ax4.set_ylim(0, 1) | |
| plt.tight_layout() | |
| if save_path: | |
| plt.savefig(save_path, dpi=300, bbox_inches="tight") | |
| return fig | |
Xet Storage Details
- Size:
- 5.13 kB
- Xet hash:
- cc0d86ff615f8d049752add86b7dbd751f7d9c746307941d4d061b3fe001960d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.