Module for functions to predict the risk of lymphatic progression.
The code in this module is utilized by the views.render_risk_prediction and
views.render_risk_prediction functions of the riskpredictor app to compute the
risk of lymphatic progression for a given diagnosis.
| Function | assemble |
Create a DiagnosisConfig object from the cleaned form data. |
| Function | collect |
For an array of risk_values, collect the mean and std for each risk type. |
| Function | compute |
Compute the posterior state dists for the given model, priors, and diagnosis. |
| Function | compute |
Compute the risks for the given checkpoint and form data. |
| Function | create |
Create the fields and kwargs for dynamically created pydantic Risks model. |
| Type Variable | |
Undocumented |
| Variable | logger |
Undocumented |
| Variable | |
Keys may be True, False, or None, while values are the counts of each. |
dict[ str, Any], lnls: list[ str], modality: str = 'D') -> DiagnosisConfig:
¶
Create a DiagnosisConfig object from the cleaned form data.
For an array of risk_values, collect the mean and std for each risk type.
The format is chosen like the lyprox.dataexplorer.query.Statistics object that
collects how many patients had True, None, or False involvement for a
given LNL. In this case, we construct the returned dictionary like this:
{
True: 26.3, # Risk of involvement minus half the standard deviation
None: 5.2, # The standard deviation of the risk
False: 68.5, # Remaining number to sum to 100
}This format is compatible with the lyprox.dataexplorer.query.Statistics object
and thus also with the HTML templates used in the dataexplorer app.
Model, priors: np.ndarray, diagnosis: DiagnosisConfig, midext: bool | None = None, specificity: float = 0.9, sensitivity: float = 0.9) -> np.ndarray:
¶
Compute the posterior state dists for the given model, priors, and diagnosis.
CheckpointModel, form_data: dict[ str, Any], lnls: list[ str]) -> BaseModelT:
¶
Compute the risks for the given checkpoint and form data.
Returns an instance of a dynamically created pydantic BaseModel class that has
fields like ipsi_II or contra_III. In these fields, it stores the risk in
dictionaries returned by the collect_risk_stats function.