@mechane-ai/elements 0.46.0 → 0.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +590 -34
- package/bin/mechane-elements-catalog.mjs +104 -12
- package/dist/ai.js +4 -4
- package/dist/article-BXZr10QQ.js +1904 -0
- package/dist/article.js +1 -0
- package/dist/catalog.json +3696 -33
- package/dist/categorical-values-BpVq8cFj.js +107 -0
- package/dist/cells-xVmnQ9oQ.js +384 -0
- package/dist/chart-link-AE_xuxiP.js +35 -0
- package/dist/chart-tones-ei3BC2AL.js +27 -0
- package/dist/charts/cartesian.js +1 -2958
- package/dist/charts/cells.js +1 -0
- package/dist/charts/comparison.js +1 -0
- package/dist/charts/distribution.js +1 -781
- package/dist/charts/figure.js +3404 -0
- package/dist/charts/graph.js +1 -655
- package/dist/charts/hierarchy.js +1 -121
- package/dist/charts/image.js +1 -0
- package/dist/charts/matrix.js +4 -644
- package/dist/charts/plot.js +15 -0
- package/dist/charts/relationship.js +1 -0
- package/dist/charts/text.js +1 -0
- package/dist/charts/timeline.js +1 -266
- package/dist/charts/transforms.js +677 -0
- package/dist/charts/trend.js +1 -0
- package/dist/charts.js +8 -3
- package/dist/clock-DSm5lkNE.js +16 -0
- package/dist/collections.js +1 -2195
- package/dist/color-legend-CIo7DhXB.js +62 -0
- package/dist/dates-Cww8UR_n.js +810 -0
- package/dist/describe-lesson-BmREzDpt.js +175 -0
- package/dist/dumbbell-plot-DQdTxDeO.js +509 -0
- package/dist/embedding-map-CF-J-8JW.js +1929 -0
- package/dist/feedback.js +1 -1
- package/dist/figure-format-B8kRZMlo.js +36 -0
- package/dist/figure-frame-BJ3REgTA.js +270 -0
- package/dist/forms/dates.js +1 -810
- package/dist/forms.js +1 -1
- package/dist/heatmap-scale-Zte6Ya-g.js +20 -0
- package/dist/image-grid-Dl2sjIMB.js +598 -0
- package/dist/kits/evaluation.js +431 -0
- package/dist/kits/interpretability.js +1033 -0
- package/dist/kits/operations.js +239 -0
- package/dist/kits/training.js +335 -0
- package/dist/label-place-Z0fryBZb.js +42 -0
- package/dist/lesson/agent.js +811 -0
- package/dist/lesson/spec.js +661 -0
- package/dist/lesson.js +5 -0
- package/dist/locate-Bcg3QcP4.js +11 -0
- package/dist/mdx.js +227 -0
- package/dist/packages/charts/src/cartesian/bar-chart.d.ts +40 -21
- package/dist/packages/charts/src/cartesian/bar-data.d.ts +15 -4
- package/dist/packages/charts/src/cartesian/bar-overlays.d.ts +7 -3
- package/dist/packages/charts/src/cartesian/breakdown-bar.d.ts +10 -8
- package/dist/packages/charts/src/cartesian/bridge-chart.d.ts +20 -16
- package/dist/packages/charts/src/cartesian/bridge-data.d.ts +5 -4
- package/dist/packages/charts/src/cartesian/composition-bars.d.ts +8 -4
- package/dist/packages/charts/src/cartesian/index.d.ts +5 -5
- package/dist/packages/charts/src/cartesian/reference-lines.d.ts +25 -18
- package/dist/packages/charts/src/cartesian/scatter-plot.d.ts +30 -25
- package/dist/packages/charts/src/cartesian/sparkline.d.ts +14 -2
- package/dist/packages/charts/src/cartesian/time-series-bands.d.ts +3 -2
- package/dist/packages/charts/src/cartesian/time-series-data.d.ts +12 -2
- package/dist/packages/charts/src/cartesian/time-series-line.d.ts +2 -2
- package/dist/packages/charts/src/cartesian/time-series-overlays.d.ts +6 -4
- package/dist/packages/charts/src/cartesian/time-series.d.ts +60 -36
- package/dist/packages/charts/src/cartesian/value-labels.d.ts +22 -0
- package/dist/packages/charts/src/categorical-values.d.ts +1 -1
- package/dist/packages/charts/src/cells/bar-cell.d.ts +13 -0
- package/dist/packages/charts/src/cells/cell-layout.d.ts +81 -0
- package/dist/packages/charts/src/cells/change-cell.d.ts +17 -0
- package/dist/packages/charts/src/cells/heat-cell.d.ts +19 -0
- package/dist/packages/charts/src/cells/index.d.ts +11 -0
- package/dist/packages/charts/src/cells/interval-cell.d.ts +16 -0
- package/dist/packages/charts/src/cells/spark-cell.d.ts +22 -0
- package/dist/packages/charts/src/chart-frame.d.ts +14 -7
- package/dist/packages/charts/src/chart-grid.d.ts +19 -0
- package/dist/packages/charts/src/chart-input.d.ts +1 -9
- package/dist/packages/charts/src/chart-link.d.ts +56 -0
- package/dist/packages/charts/src/chart.d.ts +0 -8
- package/dist/packages/charts/src/comparison/bullet-bar.d.ts +34 -0
- package/dist/packages/charts/src/comparison/comparison-plot.d.ts +54 -0
- package/dist/packages/charts/src/comparison/dot-plot.d.ts +41 -0
- package/dist/packages/charts/src/comparison/dumbbell-plot.d.ts +33 -0
- package/dist/packages/charts/src/comparison/index.d.ts +6 -0
- package/dist/packages/charts/src/distribution/box-plot.d.ts +40 -0
- package/dist/packages/charts/src/distribution/distribution-input.d.ts +5 -3
- package/dist/packages/charts/src/distribution/distribution-plot.d.ts +28 -161
- package/dist/packages/charts/src/distribution/ecdf.d.ts +16 -15
- package/dist/packages/charts/src/distribution/group-plot-input.d.ts +35 -0
- package/dist/packages/charts/src/distribution/group-plot-layout.d.ts +79 -0
- package/dist/packages/charts/src/distribution/group-plot.d.ts +73 -0
- package/dist/packages/charts/src/distribution/histogram.d.ts +16 -16
- package/dist/packages/charts/src/distribution/index.d.ts +11 -0
- package/dist/packages/charts/src/distribution/interval-plot.d.ts +16 -13
- package/dist/packages/charts/src/distribution/ranked-bars.d.ts +17 -14
- package/dist/packages/charts/src/distribution/ridgeline.d.ts +34 -0
- package/dist/packages/charts/src/distribution/strip-plot.d.ts +37 -0
- package/dist/packages/charts/src/distribution/violin-plot.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-format.d.ts +34 -0
- package/dist/packages/charts/src/figure/figure-frame.d.ts +47 -0
- package/dist/packages/charts/src/figure/figure-props.d.ts +54 -0
- package/dist/packages/charts/src/figure/tone-scope.d.ts +32 -0
- package/dist/packages/charts/src/graph/attribution-graph.d.ts +62 -0
- package/dist/packages/charts/src/graph/attribution-layout.d.ts +88 -0
- package/dist/packages/charts/src/graph/flow-diagram.d.ts +14 -15
- package/dist/packages/charts/src/graph/flow-layout.d.ts +4 -2
- package/dist/packages/charts/src/graph/graph-canvas.d.ts +33 -0
- package/dist/packages/charts/src/graph/index.d.ts +6 -2
- package/dist/packages/charts/src/graph/relation-graph.d.ts +24 -13
- package/dist/packages/charts/src/graph/tree-diagram.d.ts +41 -0
- package/dist/packages/charts/src/graph/tree-layout.d.ts +71 -0
- package/dist/packages/charts/src/hierarchy/area-mark.d.ts +17 -0
- package/dist/packages/charts/src/hierarchy/icicle.d.ts +35 -0
- package/dist/packages/charts/src/hierarchy/index.d.ts +2 -0
- package/dist/packages/charts/src/hierarchy/partition-layout.d.ts +25 -0
- package/dist/packages/charts/src/hierarchy/treemap-layout.d.ts +26 -0
- package/dist/packages/charts/src/hierarchy/treemap.d.ts +11 -9
- package/dist/packages/charts/src/image/attribution-legend.d.ts +13 -0
- package/dist/packages/charts/src/image/attribution-overlay.d.ts +50 -0
- package/dist/packages/charts/src/image/attribution-ramp.d.ts +16 -0
- package/dist/packages/charts/src/image/image-atlas.d.ts +37 -0
- package/dist/packages/charts/src/image/image-fill.d.ts +9 -0
- package/dist/packages/charts/src/image/image-grid.d.ts +26 -0
- package/dist/packages/charts/src/image/image-input.d.ts +27 -0
- package/dist/packages/charts/src/image/image-tile.d.ts +27 -0
- package/dist/packages/charts/src/image/index.d.ts +7 -0
- package/dist/packages/charts/src/index.d.ts +15 -1
- package/dist/packages/charts/src/matrix/attention-matrix.d.ts +41 -0
- package/dist/packages/charts/src/matrix/calendar-heatmap.d.ts +37 -0
- package/dist/packages/charts/src/matrix/color-legend.d.ts +9 -2
- package/dist/packages/charts/src/matrix/confusion-matrix.d.ts +36 -0
- package/dist/packages/charts/src/matrix/correlation-matrix.d.ts +34 -0
- package/dist/packages/charts/src/matrix/heatmap-scale.d.ts +8 -2
- package/dist/packages/charts/src/matrix/index.d.ts +15 -3
- package/dist/packages/charts/src/matrix/matrix-cells.d.ts +27 -3
- package/dist/packages/charts/src/matrix/matrix-figure.d.ts +50 -0
- package/dist/packages/charts/src/matrix/matrix-mark.d.ts +34 -0
- package/dist/packages/charts/src/matrix/matrix-presets.d.ts +20 -0
- package/dist/packages/charts/src/matrix/matrix-range.d.ts +45 -0
- package/dist/packages/charts/src/matrix/matrix-strip.d.ts +13 -14
- package/dist/packages/charts/src/matrix/matrix-types.d.ts +40 -0
- package/dist/packages/charts/src/matrix/matrix.d.ts +13 -11
- package/dist/packages/charts/src/matrix/token-heatmap.d.ts +16 -10
- package/dist/packages/charts/src/plot/contours.d.ts +45 -0
- package/dist/packages/charts/src/plot/index.d.ts +49 -0
- package/dist/packages/charts/src/plot/label-place.d.ts +35 -0
- package/dist/packages/charts/src/plot/locate.d.ts +18 -0
- package/dist/packages/charts/src/plot/path.d.ts +39 -0
- package/dist/packages/charts/src/plot/plot-axes.d.ts +20 -0
- package/dist/packages/charts/src/plot/plot-layout.d.ts +221 -0
- package/dist/packages/charts/src/plot/plot-marks.d.ts +128 -0
- package/dist/packages/charts/src/plot/plot-surface.d.ts +32 -0
- package/dist/packages/charts/src/plot/render/density-layer.d.ts +17 -0
- package/dist/packages/charts/src/plot/render/hit-index.d.ts +37 -0
- package/dist/packages/charts/src/plot/render/plot-viewport.d.ts +39 -0
- package/dist/packages/charts/src/plot/render/point-layer.d.ts +41 -0
- package/dist/packages/charts/src/plot/render/theme-colors.d.ts +15 -0
- package/dist/packages/charts/src/plot/scale.d.ts +48 -0
- package/dist/packages/charts/src/plot/ticks.d.ts +34 -0
- package/dist/packages/charts/src/plot-width.d.ts +3 -2
- package/dist/packages/charts/src/relationship/contour-plot.d.ts +61 -0
- package/dist/packages/charts/src/relationship/density-map.d.ts +45 -0
- package/dist/packages/charts/src/relationship/embedding-map.d.ts +75 -0
- package/dist/packages/charts/src/relationship/index.d.ts +11 -0
- package/dist/packages/charts/src/relationship/level-legend.d.ts +11 -0
- package/dist/packages/charts/src/relationship/measures.d.ts +85 -0
- package/dist/packages/charts/src/relationship/parallel-coordinates.d.ts +30 -0
- package/dist/packages/charts/src/relationship/range-controls.d.ts +20 -0
- package/dist/packages/charts/src/relationship/scatter-matrix.d.ts +20 -0
- package/dist/packages/charts/src/spec/chart-guide.d.ts +21 -0
- package/dist/packages/charts/src/spec/figure-registry.d.ts +44 -0
- package/dist/packages/charts/src/spec/figure-spec.d.ts +147 -0
- package/dist/packages/charts/src/spec/figure-text.d.ts +8 -0
- package/dist/packages/charts/src/spec/figure.d.ts +12 -0
- package/dist/packages/charts/src/spec/guide-data.d.ts +85 -0
- package/dist/packages/charts/src/spec/index.d.ts +10 -0
- package/dist/packages/charts/src/spec/validate-figure.d.ts +15 -0
- package/dist/packages/charts/src/text/index.d.ts +11 -0
- package/dist/packages/charts/src/text/token-examples.d.ts +42 -0
- package/dist/packages/charts/src/text/token-grid.d.ts +47 -0
- package/dist/packages/charts/src/text/token-links.d.ts +49 -0
- package/dist/packages/charts/src/text/token-predictions.d.ts +38 -0
- package/dist/packages/charts/src/text/token-scale.d.ts +20 -0
- package/dist/packages/charts/src/text/token-text.d.ts +39 -0
- package/dist/packages/charts/src/timeline/event-strip.d.ts +70 -0
- package/dist/packages/charts/src/timeline/index.d.ts +3 -1
- package/dist/packages/charts/src/timeline/waterfall.d.ts +24 -13
- package/dist/packages/charts/src/transforms/bins.d.ts +91 -0
- package/dist/packages/charts/src/transforms/density.d.ts +53 -0
- package/dist/packages/charts/src/transforms/fits.d.ts +50 -0
- package/dist/packages/charts/src/transforms/index.d.ts +19 -0
- package/dist/packages/charts/src/transforms/matrices.d.ts +49 -0
- package/dist/packages/charts/src/transforms/quantiles.d.ts +96 -0
- package/dist/packages/charts/src/transforms/ranks.d.ts +44 -0
- package/dist/packages/charts/src/transforms/runs.d.ts +47 -0
- package/dist/packages/charts/src/transforms/sampling.d.ts +75 -0
- package/dist/packages/charts/src/transforms/smoothing.d.ts +41 -0
- package/dist/packages/charts/src/transforms/values.d.ts +70 -0
- package/dist/packages/charts/src/trend/bump-chart.d.ts +33 -0
- package/dist/packages/charts/src/trend/column-figure.d.ts +38 -0
- package/dist/packages/charts/src/trend/column-positions.d.ts +21 -0
- package/dist/packages/charts/src/trend/curve-chart.d.ts +69 -0
- package/dist/packages/charts/src/trend/end-labels.d.ts +40 -0
- package/dist/packages/charts/src/trend/horizon-chart.d.ts +37 -0
- package/dist/packages/charts/src/trend/index.d.ts +10 -0
- package/dist/packages/charts/src/trend/line-locate.d.ts +21 -0
- package/dist/packages/charts/src/trend/runs-chart.d.ts +50 -0
- package/dist/packages/charts/src/trend/slope-chart.d.ts +35 -0
- package/dist/packages/kits/src/evaluation/evaluation-data.d.ts +31 -0
- package/dist/packages/kits/src/evaluation/index.d.ts +8 -0
- package/dist/packages/kits/src/evaluation/leaderboard-cells.d.ts +62 -0
- package/dist/packages/kits/src/evaluation/leaderboard.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/model-comparison.d.ts +59 -0
- package/dist/packages/kits/src/evaluation/score-breakdown.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/attention-head-grid.d.ts +56 -0
- package/dist/packages/kits/src/interpretability/attribution-workbench.d.ts +29 -0
- package/dist/packages/kits/src/interpretability/embedding-atlas.d.ts +41 -0
- package/dist/packages/kits/src/interpretability/feature-card.d.ts +33 -0
- package/dist/packages/kits/src/interpretability/feature-list.d.ts +51 -0
- package/dist/packages/kits/src/interpretability/feature-logits.d.ts +23 -0
- package/dist/packages/kits/src/interpretability/features.d.ts +70 -0
- package/dist/packages/kits/src/interpretability/index.d.ts +16 -0
- package/dist/packages/kits/src/interpretability/kit-styles.d.ts +118 -0
- package/dist/packages/kits/src/interpretability/logit-lens.d.ts +50 -0
- package/dist/packages/kits/src/interpretability/node-panel.d.ts +32 -0
- package/dist/packages/kits/src/interpretability/shared-link.d.ts +8 -0
- package/dist/packages/kits/src/interpretability/steering-panel.d.ts +52 -0
- package/dist/packages/kits/src/operations/budget-board.d.ts +49 -0
- package/dist/packages/kits/src/operations/incident-timeline.d.ts +30 -0
- package/dist/packages/kits/src/operations/index.d.ts +6 -0
- package/dist/packages/kits/src/operations/service-health.d.ts +66 -0
- package/dist/packages/kits/src/training/index.d.ts +8 -0
- package/dist/packages/kits/src/training/run-dashboard.d.ts +49 -0
- package/dist/packages/kits/src/training/run-legend.d.ts +21 -0
- package/dist/packages/kits/src/training/run-marker.d.ts +5 -0
- package/dist/packages/kits/src/training/run-state.d.ts +7 -0
- package/dist/packages/kits/src/training/run-table.d.ts +63 -0
- package/dist/packages/kits/src/training/runs-overview.d.ts +20 -0
- package/dist/packages/kits/src/training/runs.d.ts +34 -0
- package/dist/packages/teaching/src/agent/index.d.ts +11 -0
- package/dist/packages/teaching/src/agent/learner-trace.d.ts +84 -0
- package/dist/packages/teaching/src/agent/lesson-bridge.d.ts +59 -0
- package/dist/packages/teaching/src/agent/lesson-tour.d.ts +63 -0
- package/dist/packages/teaching/src/agent/tutor-tools.d.ts +86 -0
- package/dist/packages/teaching/src/article/article-checks.d.ts +9 -0
- package/dist/packages/teaching/src/article/article-context.d.ts +49 -0
- package/dist/packages/teaching/src/article/article-error.d.ts +12 -0
- package/dist/packages/teaching/src/article/article-labels.d.ts +54 -0
- package/dist/packages/teaching/src/article/article-layout.stylex.d.ts +14 -0
- package/dist/packages/teaching/src/article/article-outline.d.ts +9 -0
- package/dist/packages/teaching/src/article/article.d.ts +42 -0
- package/dist/packages/teaching/src/article/beat-steps.d.ts +18 -0
- package/dist/packages/teaching/src/article/beat.d.ts +16 -0
- package/dist/packages/teaching/src/article/challenge.d.ts +29 -0
- package/dist/packages/teaching/src/article/exercise-styles.d.ts +76 -0
- package/dist/packages/teaching/src/article/figure.d.ts +51 -0
- package/dist/packages/teaching/src/article/index.d.ts +31 -0
- package/dist/packages/teaching/src/article/lesson-values.d.ts +5 -0
- package/dist/packages/teaching/src/article/linked-target.d.ts +22 -0
- package/dist/packages/teaching/src/article/notes.d.ts +36 -0
- package/dist/packages/teaching/src/article/outline-types.d.ts +73 -0
- package/dist/packages/teaching/src/article/predict.d.ts +58 -0
- package/dist/packages/teaching/src/article/progress-store.d.ts +64 -0
- package/dist/packages/teaching/src/article/scrolly.d.ts +26 -0
- package/dist/packages/teaching/src/article/term.d.ts +35 -0
- package/dist/packages/teaching/src/article/tex.d.ts +12 -0
- package/dist/packages/teaching/src/article/view-essay.d.ts +13 -0
- package/dist/packages/teaching/src/article/view-present.d.ts +8 -0
- package/dist/packages/teaching/src/article/view-sheet.d.ts +7 -0
- package/dist/packages/teaching/src/article/view-static.d.ts +7 -0
- package/dist/packages/teaching/src/article/walk.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/bound-value.d.ts +29 -0
- package/dist/packages/teaching/src/lesson/define-lesson.d.ts +136 -0
- package/dist/packages/teaching/src/lesson/index.d.ts +24 -0
- package/dist/packages/teaching/src/lesson/inline-choice.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-context.d.ts +18 -0
- package/dist/packages/teaching/src/lesson/lesson-error.d.ts +12 -0
- package/dist/packages/teaching/src/lesson/lesson-locale.d.ts +4 -0
- package/dist/packages/teaching/src/lesson/lesson-persistence.d.ts +17 -0
- package/dist/packages/teaching/src/lesson/lesson-player.d.ts +51 -0
- package/dist/packages/teaching/src/lesson/lesson-store.d.ts +84 -0
- package/dist/packages/teaching/src/lesson/lesson.d.ts +39 -0
- package/dist/packages/teaching/src/lesson/param-controls.d.ts +14 -0
- package/dist/packages/teaching/src/lesson/param.d.ts +34 -0
- package/dist/packages/teaching/src/lesson/playback.d.ts +42 -0
- package/dist/packages/teaching/src/lesson/transport.d.ts +19 -0
- package/dist/packages/teaching/src/lesson/use-lesson.d.ts +36 -0
- package/dist/packages/teaching/src/mdx/essay-components.d.ts +79 -0
- package/dist/packages/teaching/src/mdx/essay-markdown.d.ts +41 -0
- package/dist/packages/teaching/src/mdx/essay.d.ts +32 -0
- package/dist/packages/teaching/src/mdx/index.d.ts +9 -0
- package/dist/packages/teaching/src/mdx/requested-view.d.ts +6 -0
- package/dist/packages/teaching/src/scene/flow/flow-layout.d.ts +38 -0
- package/dist/packages/teaching/src/scene/flow/flow-pulse.d.ts +16 -0
- package/dist/packages/teaching/src/scene/flow/scene-flow.d.ts +81 -0
- package/dist/packages/teaching/src/scene/index.d.ts +77 -0
- package/dist/packages/teaching/src/scene/morph/morph-scope.d.ts +28 -0
- package/dist/packages/teaching/src/scene/plane/plane-hit.d.ts +22 -0
- package/dist/packages/teaching/src/scene/plane/plane-label.d.ts +23 -0
- package/dist/packages/teaching/src/scene/plane/plane-labels.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/plane-math.d.ts +45 -0
- package/dist/packages/teaching/src/scene/plane/scene-axes.d.ts +30 -0
- package/dist/packages/teaching/src/scene/plane/scene-curve.d.ts +42 -0
- package/dist/packages/teaching/src/scene/plane/scene-point.d.ts +59 -0
- package/dist/packages/teaching/src/scene/plane/scene-projection.d.ts +27 -0
- package/dist/packages/teaching/src/scene/plane/scene-region.d.ts +38 -0
- package/dist/packages/teaching/src/scene/plane/scene-rule.d.ts +35 -0
- package/dist/packages/teaching/src/scene/plane/scene-vector.d.ts +39 -0
- package/dist/packages/teaching/src/scene/scene-bracket.d.ts +24 -0
- package/dist/packages/teaching/src/scene/scene-callout.d.ts +26 -0
- package/dist/packages/teaching/src/scene/scene-context.d.ts +179 -0
- package/dist/packages/teaching/src/scene/scene-custom.d.ts +31 -0
- package/dist/packages/teaching/src/scene/scene-geometry.d.ts +181 -0
- package/dist/packages/teaching/src/scene/scene-group.d.ts +28 -0
- package/dist/packages/teaching/src/scene/scene-highlight.d.ts +19 -0
- package/dist/packages/teaching/src/scene/scene-layer.d.ts +16 -0
- package/dist/packages/teaching/src/scene/scene-node.d.ts +67 -0
- package/dist/packages/teaching/src/scene/scene-obstacles.d.ts +27 -0
- package/dist/packages/teaching/src/scene/scene-registry.d.ts +79 -0
- package/dist/packages/teaching/src/scene/scene-stagger.d.ts +43 -0
- package/dist/packages/teaching/src/scene/scene-style.d.ts +14 -0
- package/dist/packages/teaching/src/scene/scene-validate.d.ts +65 -0
- package/dist/packages/teaching/src/scene/scene-wire.d.ts +45 -0
- package/dist/packages/teaching/src/scene/scene.d.ts +36 -0
- package/dist/packages/teaching/src/scene/shapes/cell-color.d.ts +11 -0
- package/dist/packages/teaching/src/scene/shapes/cell-grid.d.ts +69 -0
- package/dist/packages/teaching/src/scene/shapes/scene-card.d.ts +114 -0
- package/dist/packages/teaching/src/scene/shapes/scene-cells.d.ts +84 -0
- package/dist/packages/teaching/src/scene/shapes/scene-slot.d.ts +37 -0
- package/dist/packages/teaching/src/scene/shapes/scene-stack.d.ts +46 -0
- package/dist/packages/teaching/src/scene/shapes/scene-token.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/scene-tokens.d.ts +40 -0
- package/dist/packages/teaching/src/scene/shapes/stack-book.d.ts +35 -0
- package/dist/packages/teaching/src/scene/shapes/stack-layout.d.ts +63 -0
- package/dist/packages/teaching/src/scene/shapes/token-layout.d.ts +39 -0
- package/dist/packages/teaching/src/spec/advice.d.ts +23 -0
- package/dist/packages/teaching/src/spec/chart-names.d.ts +2 -0
- package/dist/packages/teaching/src/spec/describe-lesson.d.ts +85 -0
- package/dist/packages/teaching/src/spec/explainer-guide.d.ts +21 -0
- package/dist/packages/teaching/src/spec/findings.d.ts +39 -0
- package/dist/packages/teaching/src/spec/index.d.ts +14 -0
- package/dist/packages/teaching/src/spec/lesson-plan.d.ts +43 -0
- package/dist/packages/teaching/src/spec/validate-plan.d.ts +11 -0
- package/dist/packages/teaching/src/time/clock.d.ts +7 -0
- package/dist/packages/teaching/src/time/tween.d.ts +19 -0
- package/dist/packages/teaching/src/time/use-tween.d.ts +6 -0
- package/dist/param-CqKUTHaO.js +450 -0
- package/dist/path-BglsXpnO.js +59 -0
- package/dist/plot-axes-DJkLW4wk.js +100 -0
- package/dist/plot-layout-CZVSJ-le.js +912 -0
- package/dist/plot-marks-uozcbOIX.js +229 -0
- package/dist/plot-surface-CbVBvgqZ.js +51 -0
- package/dist/plot-width-DcqtSgzb.js +124 -0
- package/dist/point-layer-C-EYETAt.js +655 -0
- package/dist/reference-lines-BDcttOp0.js +82 -0
- package/dist/scale-C2xgZyZN.js +63 -0
- package/dist/scene-0z2gbaDE.js +4938 -0
- package/dist/scene.js +1 -0
- package/dist/slope-chart-BKVEAVCs.js +1279 -0
- package/dist/{src-1EHkSFS-.js → src-BD6xlvDt.js} +2 -2
- package/dist/{src-DVHlknB6.js → src-CExIrXPC.js} +169 -193
- package/dist/src-DIS0YOj0.js +44 -0
- package/dist/src-Dcfq8vE4.js +2195 -0
- package/dist/styles2.css +907 -59
- package/dist/time-series-BgzGNOk0.js +2670 -0
- package/dist/token-heatmap-BrW1OsKD.js +1354 -0
- package/dist/token-predictions-yerq_Oet.js +1093 -0
- package/dist/tone-scope-DKiSw-JR.js +32 -0
- package/dist/transport-BJweqDPj.js +715 -0
- package/dist/tree-diagram-D09BRqE-.js +1629 -0
- package/dist/treemap-CW4WsJNL.js +472 -0
- package/dist/use-tween-5HZ55_9d.js +72 -0
- package/dist/values-963L6n1m.js +65 -0
- package/dist/violin-plot-DrtPZ1-T.js +1292 -0
- package/dist/waterfall-DYLSnGjm.js +576 -0
- package/package.json +78 -4
- package/recipes/allocation-report.tsx +15 -7
- package/recipes/counting-cards.tsx +656 -0
- package/recipes/explorable-essay.tsx +172 -0
- package/skills/extend-elements/SKILL.md +81 -0
- package/skills/plan-lesson/SKILL.md +86 -0
- package/skills/plan-lesson/references/plan-format.md +114 -0
- package/skills/plan-lesson/references/worked-plan.md +171 -0
- package/skills/review-elements/SKILL.md +47 -3
- package/skills/review-explainer/SKILL.md +97 -0
- package/skills/upgrade-elements/SKILL.md +3 -1
- package/skills/upgrade-elements/references/releases.md +249 -0
- package/skills/use-elements/SKILL.md +22 -14
- package/skills/use-elements/references/charts.md +362 -41
- package/skills/use-elements/references/figures.md +173 -0
- package/skills/use-elements/references/kits.md +180 -0
- package/skills/use-elements/references/teaching.md +36 -0
- package/skills/write-explainer/SKILL.md +112 -0
- package/skills/write-explainer/references/article.md +164 -0
- package/skills/write-explainer/references/lesson.md +148 -0
- package/skills/write-explainer/references/mdx.md +78 -0
- package/skills/write-explainer/references/scene-parts.md +273 -0
- package/skills/write-explainer/references/scene.md +168 -0
- package/skills/write-explainer/references/tutor.md +104 -0
- package/skills/write-explainer/references/worked-essay.md +459 -0
- package/templates/essay/AGENTS.md +14 -0
- package/templates/essay/README.md +59 -0
- package/templates/essay/index.html +17 -0
- package/templates/essay/package.template.json +21 -0
- package/templates/essay/plan.json +96 -0
- package/templates/essay/src/essay.mdx +97 -0
- package/templates/essay/src/figures.tsx +92 -0
- package/templates/essay/src/lesson.ts +83 -0
- package/templates/essay/src/main.tsx +53 -0
- package/templates/essay/src/mdx.d.ts +7 -0
- package/templates/essay/tsconfig.template.json +15 -0
- package/templates/essay/vite.config.template.txt +8 -0
- package/dist/categorical-values-BXi-rJuv.js +0 -74
- package/dist/chart-data-CIJVWCYt.js +0 -21
- package/dist/chart-frame-BaxKn_MB.js +0 -236
- package/dist/chart-input-Bm82_9Rd.js +0 -22
- package/dist/chart-theme-4zprJ3rW.js +0 -404
- package/dist/plot-width-v2c_rA20.js +0 -63
|
@@ -0,0 +1,656 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Article,
|
|
3
|
+
Aside,
|
|
4
|
+
Beat,
|
|
5
|
+
Challenge,
|
|
6
|
+
Figure,
|
|
7
|
+
FigureReference,
|
|
8
|
+
Footnote,
|
|
9
|
+
Predict,
|
|
10
|
+
Reveal,
|
|
11
|
+
Scrolly,
|
|
12
|
+
ScrollyStep,
|
|
13
|
+
Term,
|
|
14
|
+
useRevealed,
|
|
15
|
+
} from '@mechane-ai/elements/article';
|
|
16
|
+
import type { ArticleView } from '@mechane-ai/elements/article';
|
|
17
|
+
import type { ChartTone } from '@mechane-ai/elements/charts';
|
|
18
|
+
import { BarChart } from '@mechane-ai/elements/charts/cartesian';
|
|
19
|
+
import { CurveChart } from '@mechane-ai/elements/charts/trend';
|
|
20
|
+
import { defineLesson, Param, ParamChoice, Playback, Transport, useLesson, Value } from '@mechane-ai/elements/lesson';
|
|
21
|
+
import {
|
|
22
|
+
LessonFlow,
|
|
23
|
+
MorphScope,
|
|
24
|
+
Scene,
|
|
25
|
+
SceneAxes,
|
|
26
|
+
SceneCard,
|
|
27
|
+
SceneCells,
|
|
28
|
+
SceneCurve,
|
|
29
|
+
SceneNode,
|
|
30
|
+
ScenePoint,
|
|
31
|
+
SceneRule,
|
|
32
|
+
SceneSlot,
|
|
33
|
+
SceneStack,
|
|
34
|
+
SceneWire,
|
|
35
|
+
} from '@mechane-ai/elements/scene';
|
|
36
|
+
import type { CardRank, CardSuit, SceneCellInput } from '@mechane-ai/elements/scene';
|
|
37
|
+
import { spacing } from '@mechane-ai/elements/tokens';
|
|
38
|
+
import type { ReactNode } from 'react';
|
|
39
|
+
|
|
40
|
+
type Card = { readonly id: string; readonly rank: CardRank; readonly suit: CardSuit };
|
|
41
|
+
|
|
42
|
+
const suits = [
|
|
43
|
+
{ id: 'heart', label: 'Hearts', glyph: '♥' },
|
|
44
|
+
{ id: 'diamond', label: 'Diamonds', glyph: '♦' },
|
|
45
|
+
{ id: 'spade', label: 'Spades', glyph: '♠' },
|
|
46
|
+
{ id: 'club', label: 'Clubs', glyph: '♣' },
|
|
47
|
+
] as const;
|
|
48
|
+
|
|
49
|
+
/** A synthetic twelve-card deck, three faces of each suit, in one fixed shuffled order. */
|
|
50
|
+
const deck = [
|
|
51
|
+
{ id: 'spade:K', rank: 'K', suit: 'spade' },
|
|
52
|
+
{ id: 'heart:Q', rank: 'Q', suit: 'heart' },
|
|
53
|
+
{ id: 'club:J', rank: 'J', suit: 'club' },
|
|
54
|
+
{ id: 'spade:Q', rank: 'Q', suit: 'spade' },
|
|
55
|
+
{ id: 'heart:K', rank: 'K', suit: 'heart' },
|
|
56
|
+
{ id: 'diamond:J', rank: 'J', suit: 'diamond' },
|
|
57
|
+
{ id: 'club:Q', rank: 'Q', suit: 'club' },
|
|
58
|
+
{ id: 'spade:J', rank: 'J', suit: 'spade' },
|
|
59
|
+
{ id: 'diamond:K', rank: 'K', suit: 'diamond' },
|
|
60
|
+
{ id: 'heart:J', rank: 'J', suit: 'heart' },
|
|
61
|
+
{ id: 'diamond:Q', rank: 'Q', suit: 'diamond' },
|
|
62
|
+
{ id: 'club:K', rank: 'K', suit: 'club' },
|
|
63
|
+
] as const satisfies ReadonlyArray<Card>;
|
|
64
|
+
|
|
65
|
+
/** The faces of each suit; in the count chart each is one segment of its suit's bar. */
|
|
66
|
+
const faces = [
|
|
67
|
+
{ rank: 'J', label: 'Jack', tone: 'series3' },
|
|
68
|
+
{ rank: 'Q', label: 'Queen', tone: 'series5' },
|
|
69
|
+
{ rank: 'K', label: 'King', tone: 'series6' },
|
|
70
|
+
] as const;
|
|
71
|
+
|
|
72
|
+
const PER_SUIT = faces.length;
|
|
73
|
+
const EVEN = 1 / suits.length;
|
|
74
|
+
const LAST_DEAL = deck.length - 1;
|
|
75
|
+
const LOW_SURPRISE = 0.5;
|
|
76
|
+
const PAGE_WIDTH = 1200;
|
|
77
|
+
|
|
78
|
+
/** The page's own gutter: an article fills what it is given and leaves the edges to the page. */
|
|
79
|
+
const pageStyle = {
|
|
80
|
+
boxSizing: 'border-box',
|
|
81
|
+
maxWidth: PAGE_WIDTH,
|
|
82
|
+
margin: '0 auto',
|
|
83
|
+
padding: `${spacing.xxl} ${spacing.lg}`,
|
|
84
|
+
} as const;
|
|
85
|
+
|
|
86
|
+
const whole = { maximumFractionDigits: 0 } as const;
|
|
87
|
+
const percent = { style: 'percent', maximumFractionDigits: 0 } as const;
|
|
88
|
+
const bits = { style: 'unit', unit: 'bit', unitDisplay: 'long', maximumFractionDigits: 2 } as const;
|
|
89
|
+
|
|
90
|
+
/** The hue of each suit, shared by every card, chart and term of the essay. */
|
|
91
|
+
const suitTones: Readonly<Record<CardSuit, ChartTone>> = {
|
|
92
|
+
heart: 'negative',
|
|
93
|
+
diamond: 'series4',
|
|
94
|
+
spade: 'series1',
|
|
95
|
+
club: 'series2',
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const cardTones: Readonly<Record<string, ChartTone>> = Object.fromEntries(
|
|
99
|
+
deck.map((card) => [card.id, suitTones[card.suit]]),
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
/** The card dealt after `dealt` cards: the one the model is scored on. */
|
|
103
|
+
function nextCard(dealt: number): Card {
|
|
104
|
+
return deck[dealt] ?? deck[0];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** How many cards of each suit the first `dealt` cards hold, in the order of `suits`. */
|
|
108
|
+
function seenCounts(dealt: number): ReadonlyArray<number> {
|
|
109
|
+
const seen = deck.slice(0, dealt);
|
|
110
|
+
|
|
111
|
+
return suits.map((suit) => seen.filter((card) => card.suit === suit.id).length);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The chance the model gives each suit: the weighted share of what is left, plus the rest spread evenly. */
|
|
115
|
+
function chances({ dealt, trust }: { readonly dealt: number; readonly trust: number }): ReadonlyArray<number> {
|
|
116
|
+
const remaining = deck.length - dealt;
|
|
117
|
+
|
|
118
|
+
return seenCounts(dealt).map((seen) => (trust * (PER_SUIT - seen)) / remaining + (1 - trust) * EVEN);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The counts by suit as a sentence, such as "2 hearts, 1 diamonds". */
|
|
122
|
+
function spoken(counts: ReadonlyArray<number>): string {
|
|
123
|
+
return suits.map((suit, index) => `${counts[index] ?? 0} ${suit.label.toLowerCase()}`).join(', ');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** One column of counts, one cell per suit, each read out with its suit's name and what the count is. */
|
|
127
|
+
function suitColumn(counts: ReadonlyArray<number>, word: string): ReadonlyArray<ReadonlyArray<SceneCellInput>> {
|
|
128
|
+
return suits.map((suit, index) => {
|
|
129
|
+
const count = counts[index] ?? 0;
|
|
130
|
+
|
|
131
|
+
return [{ value: count, label: `${suit.label} ${word}: ${count}` }];
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** The chance of the next suit at each weight, for a share by the count. */
|
|
136
|
+
function weightedLine(share: number): (weight: number) => number {
|
|
137
|
+
return (weight) => weight * share + (1 - weight) * EVEN;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function suitLeft(dealt: number): number {
|
|
141
|
+
const { suit } = nextCard(dealt);
|
|
142
|
+
|
|
143
|
+
return deck.slice(dealt).filter((card) => card.suit === suit).length;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function surpriseAt({ dealt, trust }: { readonly dealt: number; readonly trust: number }): number {
|
|
147
|
+
const share = suitLeft(dealt) / (deck.length - dealt);
|
|
148
|
+
|
|
149
|
+
return -Math.log2(trust * share + (1 - trust) * EVEN);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** Counting cards: a model that counts the dealt cards guesses the next suit better. The deck is synthetic. */
|
|
153
|
+
export const countingLesson = defineLesson({
|
|
154
|
+
id: 'counting-cards',
|
|
155
|
+
title: 'Counting cards',
|
|
156
|
+
params: {
|
|
157
|
+
dealt: { kind: 'number', label: 'Cards dealt', value: 0, min: 0, max: LAST_DEAL, step: 1, format: whole },
|
|
158
|
+
trust: {
|
|
159
|
+
kind: 'number',
|
|
160
|
+
label: 'Weight on the count',
|
|
161
|
+
value: 0.5,
|
|
162
|
+
min: 0,
|
|
163
|
+
max: 1,
|
|
164
|
+
step: 0.05,
|
|
165
|
+
format: { maximumFractionDigits: 2 },
|
|
166
|
+
},
|
|
167
|
+
isNextShown: { kind: 'toggle', label: 'Next card face up', value: false },
|
|
168
|
+
arrangement: {
|
|
169
|
+
kind: 'choice',
|
|
170
|
+
label: 'Arrangement',
|
|
171
|
+
value: 'table',
|
|
172
|
+
options: [
|
|
173
|
+
{ id: 'table', label: 'On the table' },
|
|
174
|
+
{ id: 'counts', label: 'Counted by suit' },
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
derived: {
|
|
179
|
+
cardsLeft: { label: 'Cards left', format: whole, from: ({ dealt }) => deck.length - dealt },
|
|
180
|
+
suitLeft: { label: 'Left of the next suit', format: whole, from: ({ dealt }) => suitLeft(dealt) },
|
|
181
|
+
share: { label: 'Share by the count', format: percent, from: (values) => values.suitLeft / values.cardsLeft },
|
|
182
|
+
chance: {
|
|
183
|
+
label: 'Chance of the next suit',
|
|
184
|
+
format: percent,
|
|
185
|
+
from: (values) => values.trust * values.share + (1 - values.trust) * EVEN,
|
|
186
|
+
},
|
|
187
|
+
surprise: { label: 'Surprise', format: bits, from: (values) => -Math.log2(values.chance) },
|
|
188
|
+
},
|
|
189
|
+
beats: [
|
|
190
|
+
{
|
|
191
|
+
id: 'deck',
|
|
192
|
+
title: 'A deck, one card at a time',
|
|
193
|
+
goal: 'See that each dealt card leaves a smaller deck with a different mix of suits.',
|
|
194
|
+
states: [
|
|
195
|
+
{ id: 'fresh', label: 'A fresh deck', values: { dealt: 0 } },
|
|
196
|
+
{ id: 'four', label: 'Four dealt', values: { dealt: 4 } },
|
|
197
|
+
{ id: 'eight-up', label: 'Eight dealt, next face up', values: { dealt: 8, isNextShown: true } },
|
|
198
|
+
],
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
id: 'count',
|
|
202
|
+
title: 'The model keeps a count',
|
|
203
|
+
goal: 'Read the count of what is left as the feature the model guesses from.',
|
|
204
|
+
misconception: 'That the model remembers the order of the cards; it only keeps four numbers.',
|
|
205
|
+
steps: 2,
|
|
206
|
+
states: [
|
|
207
|
+
{ id: 'early', label: 'Two dealt', values: { dealt: 2 } },
|
|
208
|
+
{ id: 'late', label: 'Nine dealt', values: { dealt: 9 } },
|
|
209
|
+
],
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: 'readout',
|
|
213
|
+
title: 'From a count to a chance',
|
|
214
|
+
goal: 'Connect the weight on the count with how far the chance moves from an even guess.',
|
|
215
|
+
hints: ['Set the weight to 0 and the chance is always 25%.', 'Set it to 1 and the chance is the share left.'],
|
|
216
|
+
states: [
|
|
217
|
+
{ id: 'half', label: 'Weight one half', values: { dealt: 5, trust: 0.5 } },
|
|
218
|
+
{ id: 'even', label: 'Weight 0', values: { dealt: 5, trust: 0 } },
|
|
219
|
+
{ id: 'counter', label: 'Weight 1', values: { dealt: 5, trust: 1 } },
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: 'counted',
|
|
224
|
+
title: 'The same cards, counted',
|
|
225
|
+
goal: 'See the count as the dealt cards themselves, sorted by suit.',
|
|
226
|
+
states: [
|
|
227
|
+
{ id: 'table', label: 'On the table', values: { dealt: 8 } },
|
|
228
|
+
{ id: 'counts', label: 'Counted by suit', values: { dealt: 8, arrangement: 'counts' } },
|
|
229
|
+
],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
id: 'practice',
|
|
233
|
+
title: 'Play the deal',
|
|
234
|
+
goal: 'Find that counting helps most near the end of the deck.',
|
|
235
|
+
misconception: 'That counting lowers the surprise on every card; on a rare suit it raises it.',
|
|
236
|
+
steps: 1,
|
|
237
|
+
states: [
|
|
238
|
+
{ id: 'start', label: 'First card, weight 1', values: { dealt: 0, trust: 1 } },
|
|
239
|
+
{ id: 'end', label: 'Last card, weight 1', values: { dealt: LAST_DEAL, trust: 1 } },
|
|
240
|
+
],
|
|
241
|
+
},
|
|
242
|
+
],
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
/** The deck, the next card and the table, at the lesson's deal. */
|
|
246
|
+
function DealScene(): ReactNode {
|
|
247
|
+
const { values, locale } = useLesson(countingLesson);
|
|
248
|
+
const { dealt, isNextShown } = values;
|
|
249
|
+
const table = deck.slice(0, dealt);
|
|
250
|
+
const next = nextCard(dealt);
|
|
251
|
+
const rest = deck.slice(dealt + 1);
|
|
252
|
+
|
|
253
|
+
return (
|
|
254
|
+
<Scene
|
|
255
|
+
title="The deal"
|
|
256
|
+
description={`Synthetic deck. ${dealt} of ${deck.length} cards are on the table, one waits face ${isNextShown ? 'up' : 'down'} and ${rest.length} stay in the deck.`}
|
|
257
|
+
locale={locale}
|
|
258
|
+
x={[0, 2]}
|
|
259
|
+
y={[0, 2]}
|
|
260
|
+
height="regular"
|
|
261
|
+
>
|
|
262
|
+
<SceneSlot
|
|
263
|
+
id="next-slot"
|
|
264
|
+
size="small"
|
|
265
|
+
at={[1.4, 2]}
|
|
266
|
+
text="Next card"
|
|
267
|
+
label="The next card, the one the model guesses"
|
|
268
|
+
/>
|
|
269
|
+
<SceneStack
|
|
270
|
+
id="deck"
|
|
271
|
+
size="small"
|
|
272
|
+
at={[0.6, 2]}
|
|
273
|
+
cards={rest.map((card) => card.id)}
|
|
274
|
+
label={`The deck, ${rest.length} cards`}
|
|
275
|
+
/>
|
|
276
|
+
<SceneStack id="next" size="small" at={[1.4, 2]} cards={[next.id]} />
|
|
277
|
+
<SceneStack
|
|
278
|
+
id="table"
|
|
279
|
+
at={[1, 0]}
|
|
280
|
+
layout="fan"
|
|
281
|
+
size="small"
|
|
282
|
+
gap="small"
|
|
283
|
+
stagger="regular"
|
|
284
|
+
cards={table.map((card) => card.id)}
|
|
285
|
+
label={`The table, ${table.length} cards dealt`}
|
|
286
|
+
/>
|
|
287
|
+
{deck.map((card, index) => (
|
|
288
|
+
<SceneCard
|
|
289
|
+
key={card.id}
|
|
290
|
+
id={card.id}
|
|
291
|
+
rank={card.rank}
|
|
292
|
+
suit={card.suit}
|
|
293
|
+
isFaceUp={index < dealt || (index === dealt && isNextShown)}
|
|
294
|
+
/>
|
|
295
|
+
))}
|
|
296
|
+
</Scene>
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/** The count as a pipeline: the suits seen, what is left, and the chances the model reads out. */
|
|
301
|
+
function CountScene(): ReactNode {
|
|
302
|
+
const { values, locale } = useLesson(countingLesson);
|
|
303
|
+
const seen = seenCounts(values.dealt);
|
|
304
|
+
const left = seen.map((count) => PER_SUIT - count);
|
|
305
|
+
const guess = chances(values);
|
|
306
|
+
const isLeftShown = useRevealed(1);
|
|
307
|
+
const isGuessShown = useRevealed(2);
|
|
308
|
+
const glyphs = suits.map((suit) => suit.glyph);
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<Scene
|
|
312
|
+
title="From the cards seen to a guess"
|
|
313
|
+
description={`Synthetic deck after ${values.dealt} cards. Seen: ${spoken(seen)}. Left: ${spoken(left)}.`}
|
|
314
|
+
locale={locale}
|
|
315
|
+
x={[0, 2]}
|
|
316
|
+
y={[0, 2]}
|
|
317
|
+
height="regular"
|
|
318
|
+
>
|
|
319
|
+
<SceneCells
|
|
320
|
+
id="seen"
|
|
321
|
+
at={[0, 1]}
|
|
322
|
+
cells={suitColumn(seen, 'seen')}
|
|
323
|
+
columnLabels={['Seen']}
|
|
324
|
+
rowLabels={glyphs}
|
|
325
|
+
size="small"
|
|
326
|
+
palette="sequential"
|
|
327
|
+
domain={[0, PER_SUIT]}
|
|
328
|
+
format={whole}
|
|
329
|
+
label={`Cards seen: ${spoken(seen)}`}
|
|
330
|
+
/>
|
|
331
|
+
<SceneCells
|
|
332
|
+
id="left"
|
|
333
|
+
at={[0.5, 1]}
|
|
334
|
+
cells={suitColumn(left, 'left')}
|
|
335
|
+
columnLabels={['Left']}
|
|
336
|
+
size="small"
|
|
337
|
+
palette="sequential"
|
|
338
|
+
domain={[0, PER_SUIT]}
|
|
339
|
+
format={whole}
|
|
340
|
+
isShown={isLeftShown}
|
|
341
|
+
label={`Cards left: ${spoken(left)}`}
|
|
342
|
+
/>
|
|
343
|
+
<SceneNode
|
|
344
|
+
id="guess"
|
|
345
|
+
at={[2, 1]}
|
|
346
|
+
size={{ width: 260, height: 230 }}
|
|
347
|
+
label="The chance the model gives each suit for the next card"
|
|
348
|
+
isShown={isGuessShown}
|
|
349
|
+
>
|
|
350
|
+
<BarChart
|
|
351
|
+
title="The model’s chances"
|
|
352
|
+
locale={locale}
|
|
353
|
+
categories={suits.map((suit) => ({ id: suit.id, label: suit.glyph }))}
|
|
354
|
+
series={[{ id: 'chance', label: 'Chance of the suit', tone: 'series1', values: guess }]}
|
|
355
|
+
domain={[0, 1]}
|
|
356
|
+
valueFormat={percent}
|
|
357
|
+
valueLabel="Chance"
|
|
358
|
+
height="compact"
|
|
359
|
+
/>
|
|
360
|
+
</SceneNode>
|
|
361
|
+
<SceneWire
|
|
362
|
+
from="seen"
|
|
363
|
+
to="left"
|
|
364
|
+
text="3 − seen"
|
|
365
|
+
label="Three of each suit, minus what was seen"
|
|
366
|
+
isShown={isLeftShown}
|
|
367
|
+
/>
|
|
368
|
+
<SceneWire
|
|
369
|
+
from="left"
|
|
370
|
+
to="guess"
|
|
371
|
+
text="weighted share"
|
|
372
|
+
label="A weighted share of what is left"
|
|
373
|
+
isShown={isGuessShown}
|
|
374
|
+
/>
|
|
375
|
+
</Scene>
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** The chance the model gives the next suit, as a line over the weight, with a point the reader drags. */
|
|
380
|
+
function ChancePlane(): ReactNode {
|
|
381
|
+
const { values, locale } = useLesson(countingLesson);
|
|
382
|
+
const line = weightedLine(values.share);
|
|
383
|
+
|
|
384
|
+
return (
|
|
385
|
+
<Scene
|
|
386
|
+
title="Chance by weight"
|
|
387
|
+
description={`A straight line from an even 25% at weight 0 to the share by the count, ${Math.round(values.share * 100)}%, at weight 1. Drag the point to set the weight.`}
|
|
388
|
+
locale={locale}
|
|
389
|
+
x={[0, 1]}
|
|
390
|
+
y={[0, 1]}
|
|
391
|
+
height="regular"
|
|
392
|
+
>
|
|
393
|
+
<SceneAxes
|
|
394
|
+
x={{ label: 'Weight on the count', format: { maximumFractionDigits: 1 } }}
|
|
395
|
+
y={{ label: 'Chance', format: percent }}
|
|
396
|
+
/>
|
|
397
|
+
<SceneRule id="even" y={EVEN} text="Even guess" />
|
|
398
|
+
<SceneCurve id="chance-line" of={line} label="The chance of the next suit at every weight" tone="series1" />
|
|
399
|
+
<ScenePoint
|
|
400
|
+
id="weight"
|
|
401
|
+
at={[values.trust, values.chance]}
|
|
402
|
+
along={line}
|
|
403
|
+
sets={{ x: 'trust' }}
|
|
404
|
+
label={`Weight ${values.trust.toFixed(2)}, chance ${Math.round(values.chance * 100)}%`}
|
|
405
|
+
tone="series1"
|
|
406
|
+
/>
|
|
407
|
+
</Scene>
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/** The dealt cards, as the table shows them or counted by suit. Each card keeps its id in both. */
|
|
412
|
+
function CountedCards(): ReactNode {
|
|
413
|
+
const { values, locale } = useLesson(countingLesson);
|
|
414
|
+
const table = deck.slice(0, values.dealt);
|
|
415
|
+
|
|
416
|
+
const counts = (
|
|
417
|
+
<BarChart
|
|
418
|
+
title="Cards seen by suit"
|
|
419
|
+
description="The dealt cards stacked by suit, one segment per card: a bar's height is the count."
|
|
420
|
+
locale={locale}
|
|
421
|
+
categories={suits.map((suit) => ({ id: suit.id, label: suit.label }))}
|
|
422
|
+
series={faces.map((face) => ({
|
|
423
|
+
id: face.rank,
|
|
424
|
+
label: face.label,
|
|
425
|
+
tone: face.tone,
|
|
426
|
+
values: suits.map((suit) => (table.some((card) => card.id === `${suit.id}:${face.rank}`) ? 1 : 0)),
|
|
427
|
+
}))}
|
|
428
|
+
mode="stacked"
|
|
429
|
+
domain={[0, PER_SUIT]}
|
|
430
|
+
valueFormat={whole}
|
|
431
|
+
valueLabel="Cards"
|
|
432
|
+
height="tall"
|
|
433
|
+
/>
|
|
434
|
+
);
|
|
435
|
+
|
|
436
|
+
return <MorphScope figures={{ table: <DealScene />, counts }} show={values.arrangement} tones={cardTones} />;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** The model's surprise at each card of the deal, at the current weight and for an even guess. */
|
|
440
|
+
function SurpriseCurve(): ReactNode {
|
|
441
|
+
const { values, locale } = useLesson(countingLesson);
|
|
442
|
+
const deals = deck.map((_, dealt) => dealt);
|
|
443
|
+
|
|
444
|
+
return (
|
|
445
|
+
<CurveChart
|
|
446
|
+
title="Surprise across the deal"
|
|
447
|
+
description="Synthetic deck. The counting model's surprise at each next card, against an even guess's constant two bits."
|
|
448
|
+
locale={locale}
|
|
449
|
+
series={[
|
|
450
|
+
{
|
|
451
|
+
id: 'model',
|
|
452
|
+
label: 'Model',
|
|
453
|
+
tone: 'series1',
|
|
454
|
+
points: deals.map((dealt) => ({ x: dealt, y: surpriseAt({ dealt, trust: values.trust }) })),
|
|
455
|
+
},
|
|
456
|
+
{ id: 'even', label: 'Even guess', tone: 'neutral', points: deals.map((dealt) => ({ x: dealt, y: 2 })) },
|
|
457
|
+
]}
|
|
458
|
+
x={{ label: 'Cards dealt', domain: [0, LAST_DEAL], format: whole }}
|
|
459
|
+
y={{ label: 'Surprise (bits)', domain: [0, 3], format: { maximumFractionDigits: 1 } }}
|
|
460
|
+
markers={[{ x: values.dealt, label: 'Now' }]}
|
|
461
|
+
labels="inline"
|
|
462
|
+
height="compact"
|
|
463
|
+
/>
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function isLowSurprise(values: Readonly<Record<string, unknown>>): boolean {
|
|
468
|
+
return Number(values['surprise']) < LOW_SURPRISE;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/** The essay, written once; each view arranges it. Its deck and numbers are synthetic. */
|
|
472
|
+
export const countingEssay = (
|
|
473
|
+
<>
|
|
474
|
+
<Beat id="deck">
|
|
475
|
+
<p>
|
|
476
|
+
Twelve cards, three of each suit, are dealt one at a time. Before each card a model guesses its suit. A guess
|
|
477
|
+
that ignores the deal gives every suit 25%; a guess that counts can do better, because every dealt card changes
|
|
478
|
+
what is left.
|
|
479
|
+
</p>
|
|
480
|
+
<Scrolly
|
|
481
|
+
figure={
|
|
482
|
+
<Figure
|
|
483
|
+
id="deal"
|
|
484
|
+
caption="The deck, the card about to be dealt, and the table."
|
|
485
|
+
description="A face-down deck and, beside it, one card in the next-card bay; below them the dealt cards fan out face up."
|
|
486
|
+
reads={['dealt', 'isNextShown']}
|
|
487
|
+
>
|
|
488
|
+
<DealScene />
|
|
489
|
+
</Figure>
|
|
490
|
+
}
|
|
491
|
+
>
|
|
492
|
+
<ScrollyStep id="fresh" values={{ dealt: 0, isNextShown: false }}>
|
|
493
|
+
<p>
|
|
494
|
+
<strong>A fresh deck.</strong> Nothing is dealt, so every suit is equally likely next.
|
|
495
|
+
</p>
|
|
496
|
+
</ScrollyStep>
|
|
497
|
+
<ScrollyStep id="four" values={{ dealt: 4, isNextShown: false }}>
|
|
498
|
+
<p>
|
|
499
|
+
<strong>Four dealt.</strong> Two spades and two hearts are gone, so diamonds and clubs are now more likely.
|
|
500
|
+
</p>
|
|
501
|
+
</ScrollyStep>
|
|
502
|
+
<ScrollyStep id="eight" values={{ dealt: 8, isNextShown: true }}>
|
|
503
|
+
<p>
|
|
504
|
+
<strong>Eight dealt.</strong> Only four cards remain. Turn the next card face up or down:{' '}
|
|
505
|
+
<Param name="isNextShown" />.
|
|
506
|
+
</p>
|
|
507
|
+
</ScrollyStep>
|
|
508
|
+
</Scrolly>
|
|
509
|
+
</Beat>
|
|
510
|
+
<Beat id="count">
|
|
511
|
+
<p>
|
|
512
|
+
The model never sees the order of the deal. After <Param name="dealt" /> cards it keeps four numbers, the suits
|
|
513
|
+
seen so far, and from them <Term inspects="left">what is left</Term> of each suit (
|
|
514
|
+
<FigureReference to="count-pipeline" />
|
|
515
|
+
).
|
|
516
|
+
</p>
|
|
517
|
+
<Figure
|
|
518
|
+
id="count-pipeline"
|
|
519
|
+
caption="The count becomes the model’s guess, one step at a time."
|
|
520
|
+
description="Three parts joined by arrows: four cells counting the suits seen, four cells counting the suits left, and a bar chart of the chance the model gives each suit."
|
|
521
|
+
reads={['dealt', 'trust']}
|
|
522
|
+
>
|
|
523
|
+
<CountScene />
|
|
524
|
+
</Figure>
|
|
525
|
+
<Reveal at={1}>
|
|
526
|
+
<p>
|
|
527
|
+
Subtracting from three gives the cards left of each suit; <Value name="cardsLeft" /> cards remain in all.
|
|
528
|
+
</p>
|
|
529
|
+
</Reveal>
|
|
530
|
+
<Reveal at={2}>
|
|
531
|
+
<p>
|
|
532
|
+
<Term inspects="guess">The model’s chances</Term> mix that count with an even guess.
|
|
533
|
+
<Footnote id="blackjack">
|
|
534
|
+
Blackjack players count cards the same way, keeping one running number instead of four.
|
|
535
|
+
</Footnote>
|
|
536
|
+
</p>
|
|
537
|
+
</Reveal>
|
|
538
|
+
</Beat>
|
|
539
|
+
<Beat id="readout">
|
|
540
|
+
<p>
|
|
541
|
+
The weight on the count, now <Param name="trust" />, decides how much the model believes it. The chance is the
|
|
542
|
+
weight times the share by the count, plus the rest of the weight spread evenly over four suits.
|
|
543
|
+
</p>
|
|
544
|
+
<Predict
|
|
545
|
+
id="chance-guess"
|
|
546
|
+
prompt="Before you look at the figures: what chance does the model give the suit that comes next?"
|
|
547
|
+
min={0}
|
|
548
|
+
max={1}
|
|
549
|
+
step={0.05}
|
|
550
|
+
format={percent}
|
|
551
|
+
answerFrom="chance"
|
|
552
|
+
tolerance={0.05}
|
|
553
|
+
>
|
|
554
|
+
<p>
|
|
555
|
+
The next card’s suit has <Value name="suitLeft" /> of the <Value name="cardsLeft" /> cards left, so the model
|
|
556
|
+
gives it <Value name="chance" />.
|
|
557
|
+
</p>
|
|
558
|
+
</Predict>
|
|
559
|
+
<Figure
|
|
560
|
+
id="chance-plane"
|
|
561
|
+
caption="The chance of the next suit at every weight; drag the point."
|
|
562
|
+
description="A straight line from 25% at weight 0 to the share by the count at weight 1, with a dashed rule at 25% and a point at the current weight."
|
|
563
|
+
reads={['trust', 'dealt']}
|
|
564
|
+
>
|
|
565
|
+
<ChancePlane />
|
|
566
|
+
</Figure>
|
|
567
|
+
<Aside>Surprise is the loss a model trains on: the bits it takes to name the card that came.</Aside>
|
|
568
|
+
<Figure
|
|
569
|
+
id="derivation"
|
|
570
|
+
caption="Every value of the lesson and what it reads."
|
|
571
|
+
description="A diagram in layers: cards dealt feeds cards left and the cards left of the next suit, which give the share; with the weight they give the chance, and the chance gives the surprise."
|
|
572
|
+
>
|
|
573
|
+
<LessonFlow
|
|
574
|
+
names={['surprise']}
|
|
575
|
+
description="Synthetic deck. Each value sits one layer after what it reads."
|
|
576
|
+
formula={{
|
|
577
|
+
cardsLeft: '12 − dealt',
|
|
578
|
+
share: 'left of suit ÷ cards left',
|
|
579
|
+
chance: 'w · share + (1 − w) · ¼',
|
|
580
|
+
surprise: '−log₂ chance',
|
|
581
|
+
}}
|
|
582
|
+
/>
|
|
583
|
+
</Figure>
|
|
584
|
+
</Beat>
|
|
585
|
+
<Beat id="counted">
|
|
586
|
+
<p>
|
|
587
|
+
The count is nothing but the dealt cards sorted by suit. After <Value name="dealt" /> cards, switch the figure
|
|
588
|
+
between the table and the count and watch the same cards travel.
|
|
589
|
+
</p>
|
|
590
|
+
<Figure
|
|
591
|
+
id="morph"
|
|
592
|
+
caption="The dealt cards, on the table or counted by suit."
|
|
593
|
+
description="The deal scene, or a stacked bar chart with one bar per suit, where each dealt card becomes one segment of its suit's bar."
|
|
594
|
+
reads={['dealt']}
|
|
595
|
+
>
|
|
596
|
+
<CountedCards />
|
|
597
|
+
<ParamChoice name="arrangement" />
|
|
598
|
+
</Figure>
|
|
599
|
+
</Beat>
|
|
600
|
+
<Beat id="practice">
|
|
601
|
+
<p>
|
|
602
|
+
Play the deal with the weight at <Param name="trust" />. At card <Value name="dealt" /> the model gives the next
|
|
603
|
+
suit <Value name="chance" />, a surprise of <Value name="surprise" />.
|
|
604
|
+
</p>
|
|
605
|
+
<Figure
|
|
606
|
+
id="deal-run"
|
|
607
|
+
caption="The deal played card by card, and the model’s surprise at each card."
|
|
608
|
+
description="Play controls, the deal scene and a curve of the model's surprise at each of the twelve cards, against a flat line at two bits for an even guess."
|
|
609
|
+
reads={['dealt', 'trust']}
|
|
610
|
+
>
|
|
611
|
+
<Playback name="dealt" pace="slow" />
|
|
612
|
+
<Transport for="dealt" />
|
|
613
|
+
<DealScene />
|
|
614
|
+
<SurpriseCurve />
|
|
615
|
+
</Figure>
|
|
616
|
+
<Reveal at={1}>
|
|
617
|
+
<p>
|
|
618
|
+
With seven cards dealt the next card is the last spade, a suit the count calls unlikely: counting costs bits
|
|
619
|
+
there and wins them back near the end.
|
|
620
|
+
</p>
|
|
621
|
+
</Reveal>
|
|
622
|
+
<Challenge
|
|
623
|
+
id="low-surprise"
|
|
624
|
+
prompt="Make the model’s surprise at the next card less than half a bit."
|
|
625
|
+
isReached={isLowSurprise}
|
|
626
|
+
hints={['Deal to the last card.', 'Then put most of the weight on the count.']}
|
|
627
|
+
>
|
|
628
|
+
<p>
|
|
629
|
+
The surprise is <Value name="surprise" />: with one card left the count names its suit for certain.
|
|
630
|
+
</p>
|
|
631
|
+
</Challenge>
|
|
632
|
+
</Beat>
|
|
633
|
+
</>
|
|
634
|
+
);
|
|
635
|
+
|
|
636
|
+
type CountingCardsProps = {
|
|
637
|
+
readonly title: string;
|
|
638
|
+
readonly summary: string;
|
|
639
|
+
/** How the essay is arranged. Defaults to the scrolling essay. */
|
|
640
|
+
readonly view?: ArticleView | undefined;
|
|
641
|
+
};
|
|
642
|
+
|
|
643
|
+
/**
|
|
644
|
+
* Build an explorable essay that uses every teaching layer, from a lesson with beat states to cards that deal and flip.
|
|
645
|
+
* It draws a count as cells and a chart, a plane, the derivation, a morph into a chart, a prediction and a challenge.
|
|
646
|
+
* Pass a title, a summary and optionally a view.
|
|
647
|
+
*/
|
|
648
|
+
export function CountingCards({ title, summary, view }: CountingCardsProps) {
|
|
649
|
+
return (
|
|
650
|
+
<main style={pageStyle}>
|
|
651
|
+
<Article lesson={countingLesson} locale="en-US" title={title} summary={summary} tones={suitTones} view={view}>
|
|
652
|
+
{countingEssay}
|
|
653
|
+
</Article>
|
|
654
|
+
</main>
|
|
655
|
+
);
|
|
656
|
+
}
|