CaMa survival: a saved model is rehydrated with the current class before scoring
This commit is contained in:
@@ -16,7 +16,7 @@ import pandas as pd
|
||||
|
||||
from models.cama.seer_survival import survival_curves as luis
|
||||
from models.cama.survival import population
|
||||
from models.cama.survival.estimator import FEATURES, survival_settings
|
||||
from models.cama.survival.estimator import FEATURES, IntervalSurvival, survival_settings
|
||||
from models.dags.training import Scenario, dataflow
|
||||
|
||||
MIN_MEMBERS = 30
|
||||
@@ -29,6 +29,15 @@ class QueryError(ValueError):
|
||||
"""The selection cannot be answered; the message says why, in the reader's language."""
|
||||
|
||||
|
||||
def rehydrate(model) -> IntervalSurvival:
|
||||
"""The fitted model as the current `IntervalSurvival` code runs it. A version's saved model carries its class as it was
|
||||
when it was trained; its fitted state (`fitted_`, `weights_`, the codings) is what makes it that version, so that state
|
||||
is put in the current class and its methods are the code's."""
|
||||
current = IntervalSurvival.__new__(IntervalSurvival)
|
||||
current.__dict__.update(model.__dict__)
|
||||
return current
|
||||
|
||||
|
||||
def members(scenario: Scenario, frame: pd.DataFrame, lineage: dict) -> pd.DataFrame:
|
||||
"""Every member of the indexed cohort with her covariates and follow-up (the scenario's `labelled_members`)."""
|
||||
dr = dataflow(*scenario.modules, config=scenario.config)
|
||||
|
||||
Reference in New Issue
Block a user