算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
statistical-visualizations【设计与创意】Build and troubleshoot ManimML statistical, probability, decision-tree, MCMC, Gaussian, and matplotlib-image visualizations with safe CPU-first recipes.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this sub-skill when a task asks for ManimML scenes or helper code involving statistical or probability visualizations:
DecisionTreeClassifier.tree_.ImageMobject objects.Route neural-network layer diagrams, forward-pass animations, dropout, and CNN/image-layer workflows to the neural-network-visualization sub-skill instead.
The target Python environment should import Manim Community, ManimML, NumPy, Pillow, SciPy, matplotlib, seaborn, scikit-learn, and tqdm. These workflows are CPU workflows. Full video rendering is optional and may additionally require the usual Manim system rendering stack.
For headless execution, set matplotlib to the Agg backend before creating figures:
import matplotlib
matplotlib.use("Agg", force=True)
Run the bundled helper from this sub-skill directory to verify package-level construction without rendering:
python scripts/build_statistical_visualizations.py --help
python scripts/build_statistical_visualizations.py --example sampler --iterations 12
python scripts/build_statistical_visualizations.py --example decision-tree --max-depth 2
--example all runs the compact sampler, decision-tree, MCMC axes, Gaussian, and matplotlib-image construction checks. These checks synthesize their own tiny data or icons and do not require repository example assets.
| Need | Use | Details |
|---|---|---|
| Fitted scikit-learn tree diagram | DecisionTreeDiagram(sklearn_tree, feature_names=..., class_images_paths=...) | Leaves require image paths in the current implementation. Use generated temporary icons or caller-provided class images. |
| Decision areas over a 2-D feature plane | compute_decision_areas(tree_classifier, maxrange, x=0, y=1, n_features=2) | Compute rectangles first; only build a Manim surface after confirming finite ranges and compatible axes. |
| Iris-style dataset scatter | IrisDatasetPlot(iris) | Designed for sklearn's iris object and the first two features. Treat full rendering as optional. |
| Metropolis-Hastings sampler | metropolis_hastings_sampler(...) | Required smoke path. Returns samples, an empty warm-up array, and proposals. |
| MCMC axes/animations | MCMCAxes(...) | Construct axes and proposal/chain animations with tiny iteration counts before rendering. |
| Gaussian probability overlay | GaussianDistribution(axes, mean=..., cov=..., dist_theme="gaussian") | Use 2-D mean/covariance matching the axes. |
| Matplotlib figure as Manim image | convert_matplotlib_figure_to_image_mobject(fig, dpi=...) | Use Agg, close figures after conversion, and avoid remote datasets. |
DecisionTreeSurface and IrisDatasetPlot from manim_ml.decision_tree.decision_tree_surface; do not rely on outdated re-export assumptions.true_samples if calling visualize_metropolis_hastings_chain_sampling; it builds a background density image.-ql) or still-image (-s) flags for first renders.references/api-reference.md - public API signatures, return expectations, and source limitations.references/workflows.md - self-contained decision-tree, MCMC, Gaussian, and matplotlib recipes.references/troubleshooting.md - common errors and recovery steps.scripts/build_statistical_visualizations.py - CPU-first smoke helper with no default render step.