ncaa_eval.model.base module¶
Model abstract base classes and configuration.
Defines the Model ABC, the StatefulModel template subclass for
sequential-update models, and the ModelConfig Pydantic base used by
every model’s hyperparameter schema.
- class ncaa_eval.model.base.Model[source]¶
Bases:
ABCAbstract base class for all NCAA prediction models.
Every model — stateful or stateless — must implement these five methods so that the training CLI, evaluation engine, and persistence layer can treat all models uniformly.
- feature_config¶
Declarative specification of which feature blocks the model expects. Set by subclass
__init__.
- feature_config: FeatureConfig¶
- abstractmethod fit(X: DataFrame, y: Series) None[source]¶
Train the model on feature matrix X and labels y.
- abstractmethod get_config() ModelConfig[source]¶
Return the Pydantic-validated configuration for this model.
- get_feature_importances() list[tuple[str, float]] | None[source]¶
Return feature name/importance pairs, or
Noneif unavailable.The default returns
None. Models that support feature importances (e.g. XGBoost) should override this method.
- class ncaa_eval.model.base.ModelConfig(*, model_name: str, calibration_method: Literal['isotonic', 'sigmoid'] | None = None)[source]¶
Bases:
BaseModelBase configuration shared by all model implementations.
Subclasses add model-specific hyperparameters as additional fields.
- calibration_method: CalibrationMethod | None¶
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_name: str¶
- class ncaa_eval.model.base.StatefulModel[source]¶
Bases:
ModelTemplate base for models that process games sequentially.
Concrete methods
fitandpredict_probaare provided as template methods. Subclasses implement the abstract hooks:update(game)— absorb a single game result_predict_one(team_a_id, team_b_id)— return P(team_a wins)start_season(season)— reset / prepare for a new seasonget_state()/set_state(state)— snapshot / restore ratings
- fit(X: DataFrame, y: Series) None[source]¶
Reconstruct games from X/y and update sequentially.
Reconstructs Game objects from the feature matrix and labels, then iterates chronologically, calling start_season() on season boundaries and update() per game.
- abstractmethod get_state() dict[str, Any][source]¶
Return a serialisable snapshot of internal ratings.
- predict_matchup(team_a_id: int, team_b_id: int) float[source]¶
Return P(team_a wins) for a single matchup.
Delegates to the
_predict_oneabstract hook.