Spaces:
Running
Running
Download src/chess_tutor/web/pca_plot.py from mickailh/chess-tutor: direct link, hf CLI and curl.
- Browser
- Download file 841 Bytes
-
https://huggingface.co/spaces/mickailh/chess-tutor/resolve/main/src/chess_tutor/web/pca_plot.py
- Command line
-
hf download hf://spaces/mickailh/chess-tutor/src/chess_tutor/web/pca_plot.py
-
curl -L -o pca_plot.py https://huggingface.co/spaces/mickailh/chess-tutor/resolve/main/src/chess_tutor/web/pca_plot.py
841 Bytes
| """2D PCA plot of cohort playstyle snapshots with the inferred player highlighted.""" | |
| from __future__ import annotations | |
| from typing import Any | |
| from chess_tutor.inference.pipeline import InferenceResult | |
| from chess_tutor.playstyle_coaching.teacher import TeacherCoachingBundle | |
| from chess_tutor.web.embedding import build_all_embedding_plots | |
| def build_pca_plot( | |
| result: InferenceResult, | |
| *, | |
| corpus_id: str = "standard_600", | |
| teacher_bundle: TeacherCoachingBundle | None = None, | |
| max_points: int = 6000, | |
| seed: int = 42, | |
| ) -> dict[str, Any] | None: | |
| """Fit PCA on cohort snapshots and return 2D coordinates for the web UI.""" | |
| return build_all_embedding_plots( | |
| result, | |
| corpus_id=corpus_id, | |
| teacher_bundle=teacher_bundle, | |
| max_points=max_points, | |
| seed=seed, | |
| )["pca_plot"] | |