ncaa_eval.cli.predict module

Prediction orchestration for CLI predict command.

Loads a trained model, generates win-probability predictions for a target season, and formats output as CSV. Supports both stateful (Elo) and stateless (XGBoost, LogisticRegression) model types.

ncaa_eval.cli.predict.build_predictions(*, run_id: str, season: int, data_dir: Path) str[source]

Load a model and return a predictions CSV string.

Orchestration layer: loads the model and season data from disk, routes to the appropriate prediction path (stateful or stateless), and formats the result as a CSV string. Callers decide where to write the output.

Parameters:
  • run_id – Model run identifier.

  • season – Target season year (e.g. 2026).

  • data_dir – Path to the local data directory.

Returns:

CSV string with season,team_a_id,team_b_id,pred_win_prob header.

Raises:

FileNotFoundError – If the run, model, or season data cannot be loaded.

ncaa_eval.cli.predict.format_predictions_csv(rows: list[tuple[int, int, int, float]]) str[source]

Format prediction rows as a CSV string.

Parameters:

rows – List of (season, team_a_id, team_b_id, pred_win_prob) tuples.

Returns:

CSV string with header season,team_a_id,team_b_id,pred_win_prob.

ncaa_eval.cli.predict.run_predict(*, run_id: str, season: int, data_dir: Path, output: Path | None, console: Console | None = None) str[source]

Load a model and produce a predictions CSV.

Thin CLI wrapper around build_predictions that handles progress output and writing to a file or stdout.

Parameters:
  • run_id – Model run identifier.

  • season – Target season year (e.g. 2026).

  • data_dir – Path to the local data directory.

  • output – File path to write the CSV. None means stdout.

  • console – Rich Console instance for status output.

Returns:

The CSV string.

Raises:
  • FileNotFoundError – If the run or model cannot be loaded.

  • TypeError – If the model lacks a feature_config attribute (e.g. a malformed plugin).

  • AttributeError – If the model subclass did not set feature_config.