chess-tutor / src /chess_tutor /web /tsne_plot.py
github-actions[bot]
deploy prod from 06dbd16a01ddcfe02b2d936c681e3e4eaa9b141f
8e756fd
Raw
History Blame Contribute Delete
849 Bytes
"""2D t-SNE 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_tsne_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 t-SNE on a cohort subsample 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,
)["tsne_plot"]