Baseline IO
- class neer_match_utilities.baseline_io.ModelBaseline[source]
Save/load utilities for non-DL baseline models: - LogitMatchingModel - ProbitMatchingModel - GradientBoostingModel
- static load(model_directory)[source]
Load a baseline model.
Reads both layouts: models saved with the training data embedded in the statsmodels result (the original behavior), and models saved without it. In the latter case the regression table is restored from
meta.pklso thatsummary()andcoefficients()keep working.
- static save(model, target_directory, name, similarity_map=None, remove_data=True)[source]
- Parameters:
similarity_map (
SimilarityMap|dict|None) – Pass either a SimilarityMap instance OR the underlying dict (instructions). This is stored so that ModelBaseline.load(…) can return a model with loaded_model.similarity_map just like the DL models.remove_data (
bool) –Only relevant for the statsmodels baselines (Logit/Probit). A statsmodels
Resultsobject keeps a reference to itsModel, and hence to the fullendog/exogarrays. Since the design matrix here is the entire left x right cross join, pickling it verbatim costs roughly 1.9 KB per training pair – tens of gigabytes on realistic data – in order to persist a coefficient vector of a few hundred bytes.When True (default), the regression table is rendered and stored in
meta.pklfirst, and the result is then pickled without its data. The artifact becomes a few hundred KB regardless of dataset size;predict_proba,evaluate,suggestandsummaryall keep working on the reloaded model. What is lost is the ability to recompute data-dependent quantities (residuals, influence measures) from the archive.Set to False to reproduce the old behavior and pickle the data along with the model.
- Return type:
None
Notes
With
remove_data=Truestatsmodels strips the arrays from the in-memory result as well, so the passed-inmodelloses its residuals and influence measures too. Its coefficients, predictions and summary are unaffected.