credibility¶
The credibility of a model for its contexts of use.
A model declares what it is used for (ContextOfUse), how risky a wrong answer
is, which evidence supports it and when it is accepted (Credibility). The
evidence is selected from the data points of the adopted fits (evaluate_fits,
mapping_table) with the kinds their records store (select,
check_declaration). The assessment (assess, CredibilityAssessment) gives
every context of use its metrics, acceptance, domain coverage, verdict and the
factors of V&V 40 (FACTORS) as plain data, written as JSON. The verification
(verify) evaluates the fits again with tightened tolerances and a second
integration method and checks the builds, for the factors of the verification,
and runs the battery of the checks of the builds (run_battery): mass
balance, non-negativity, zero dose, steady state, superposition, a second
simulator, plausibility and rebuild. The temporal validation (chronology)
splits the decisive points by whether the model collected their study after
the fit, and the provenance of the study data (study_data) names the
collection every study with points was written by. The parameter
uncertainty of the adopted fits is propagated to the decisive predictions
(propagate, UncertaintySettings), the probability that the acceptance is
met over the draws of the parameters. The simulated inputs of the mappings,
the covariates of the subjects and the doses, are checked against the reported
ones of their studies (input_checks), the equivalency of the inputs, and
the decisive points with the declared variability of the subjects
(predictive_checks, VariabilitySettings), the visual predictive check.
AcceptanceRecord
¶
Bases: TypedDict
The result of an acceptance rule as plain data, see AcceptanceResult.
ContextResult
dataclass
¶
ContextResult(
*,
id,
title,
question,
level,
influence,
consequence,
risk,
rationale,
extrapolation,
domain_statement,
quantities,
acceptance,
verdict,
factors,
n_decisive,
n_evaluable,
minimum_points,
verification=list(),
ratios=list(),
ratio_acceptance=None,
temporal=None,
uncertainty=None,
inputs=None,
variability=None,
)
The assessment of a context of use.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the id of the context. |
title |
str
|
the title. |
question |
str
|
the question. |
level |
CouLevel
|
the level on the ladder. |
influence |
Level
|
the influence of the model on the decision. |
consequence |
Level
|
the consequence of a wrong decision. |
risk |
Level
|
the model risk. |
rationale |
str
|
why this level, influence and consequence. |
extrapolation |
str
|
the argument for a domain without validation evidence. |
domain_statement |
str
|
what the domain claims beyond the metadata. |
quantities |
list[QuantityRecord]
|
the quantities of interest ( |
acceptance |
list[AcceptanceRecord]
|
the results of the acceptance rules ( |
verdict |
Verdict
|
the verdict. |
factors |
list[FactorRecord]
|
the factors of V&V 40 ( |
n_decisive |
int
|
the points of the decisive evidence, each row once. |
n_evaluable |
int
|
the decisive points which are applicable, see
|
minimum_points |
int
|
the evaluable points the verdict needs, see
|
verification |
list[CheckRecord]
|
the checks of the verification of the decisive
predictions, in the order of |
ratios |
list[RatioRecord]
|
the pairs of the arms of the assessed ratio quantities, see
|
ratio_acceptance |
AcceptanceRecord | None
|
the result of the rule of the ratio pairs
( |
temporal |
TemporalRecord | None
|
the decisive points of the studies the model collected
after their fit, see |
uncertainty |
UncertaintyRecord | None
|
the parameter uncertainty of the decisive predictions,
see |
inputs |
InputsRecord | None
|
the equivalency of the inputs of the decisive mappings, see
|
variability |
VariabilityRecord | None
|
the predictive check of the decisive points with the
declared variability of the subjects, see
|
decisive_role
property
¶
Get the role of the evidence which decides, see CouLevel.decisive_role.
uncovered_quantities
property
¶
Get the ids of the quantities of interest which are uncovered.
from_dict
classmethod
¶
Get the result from plain data, None as NaN.
A record of pkpdsim 0.17 has no minimum of points, read as 0, and no
coverage of the quantities, read as None with 0 points; a record of
0.18 or earlier has no ratio pairs, no temporal record, no
uncertainty, no equivalency of the inputs and no predictive check.
Coverage
¶
Bases: StrEnum
The coverage of a claimed value of the domain of a context of use.
CoverageEntry
dataclass
¶
The coverage of a value of a field of the metadata by a context of use.
Attributes:
| Name | Type | Description |
|---|---|---|
context |
str
|
the id of the context of use. |
field |
str
|
the field of the metadata, e.g. |
value |
str
|
the name of the value, e.g. |
coverage |
Coverage | None
|
the coverage of a claimed value, |
claimed |
bool
|
whether the domain claims the value; the values of the points of the evidence outside the claim are not claimed. |
n_points |
int
|
the points with the value: the applicable points of the validation evidence for a validated value, of the calibration evidence for a calibrated one, every point of the evidence for a value outside the claim. |
CredibilityAssessment
dataclass
¶
CredibilityAssessment(
*,
provenance,
contexts,
evidence,
coverage,
limitations,
unclaimed,
notes,
verification=None,
cross_validations=list(),
studies=list(),
inputs=list(),
vpc=list(),
)
The assessment of the contexts of use of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
provenance |
Provenance
|
what the assessment was computed from. |
contexts |
list[ContextResult]
|
the result of every context of use, in the declared order. |
evidence |
list[EvidenceResult]
|
the metrics of every evidence of every context. |
coverage |
list[CoverageEntry]
|
the coverage of the domain of every context. |
limitations |
list[EvidenceResult]
|
the metrics of the limitations, of the model (context
|
unclaimed |
list[UnclaimedRecord]
|
the validation points which no evidence and no limitation
selects, per fit and mapping ( |
notes |
str
|
the notes of the declaration. |
verification |
VerificationSummary | None
|
what the verification compared, |
cross_validations |
list[CrossValidation]
|
the leave-one-study-out cross-validations of the
adopted fits, see |
studies |
list[StudyData]
|
the provenance of the data of every study with points in the
adopted fits, see |
inputs |
list[InputCheck]
|
the checks of the simulated inputs of every mapping of the
adopted fits against the reported ones, see
|
vpc |
list[VpcPoint]
|
every data point of the adopted fits with the band of its
predictive check, see |
to_json
¶
Write the assessment as JSON.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the file. |
required |
from_json
classmethod
¶
Read an assessment written with to_json.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path
|
the file. |
required |
Returns:
| Type | Description |
|---|---|
CredibilityAssessment
|
The assessment. |
EvidenceResult
dataclass
¶
EvidenceResult(
*,
context,
name,
role,
description,
selection,
n_points,
n_mappings,
n_studies,
outliers_dropped,
limitation_subtracted,
metrics,
)
The metrics of an evidence of a context of use or of a limitation.
Attributes:
| Name | Type | Description |
|---|---|---|
context |
str
|
the id of the context of use, |
name |
str
|
the name of the evidence. |
role |
EvidenceRole
|
the role of the evidence. |
description |
str
|
what the evidence is. |
selection |
str
|
what the evidence selects, see |
n_points |
int
|
the data points. |
n_mappings |
int
|
the fit mappings, by experiment and key. |
n_studies |
int
|
the studies, the experiments of the mappings. |
outliers_dropped |
int
|
the outlier points a validation dropped. |
limitation_subtracted |
int
|
the limitation points subtracted. |
metrics |
dict[str, float]
|
|
Provenance
dataclass
¶
What an assessment was computed from.
Attributes:
| Name | Type | Description |
|---|---|---|
model |
str
|
the name of the model. |
title |
str
|
the title of the model. |
fits |
list[str]
|
the ids of the adopted fits. |
versions |
dict[str, str]
|
the versions of the packages, see |
commit |
str | None
|
the commit of the repository of the model, |
dirty |
bool | None
|
whether the repository has changes, |
date |
str
|
the date of the assessment, ISO 8601 with the time zone. |
lock |
str | None
|
whether the evidence matched the lock of the declaration
( |
QuantityRecord
¶
Bases: TypedDict
A quantity of interest as plain data, see QuantityOfInterest.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the id of the quantity. |
description |
str
|
what the quantity is. |
ratio |
bool
|
whether the quantity is a ratio between arms. |
coverage |
str | None
|
|
n_points |
int
|
the applicable decisive points of the quantity inside the claimed domain, the evaluable pairs of an assessed ratio, 0 for a ratio without a pairing. |
UnclaimedRecord
¶
Bases: TypedDict
The unclaimed validation points of a fit mapping.
Attributes:
| Name | Type | Description |
|---|---|---|
fit |
str
|
the subset of the fit. |
experiment |
str
|
the experiment. |
mapping |
str
|
the key of the mapping. |
n |
int
|
the points. |
Verdict
¶
Bases: StrEnum
The verdict of the assessment of a context of use.
Battery
dataclass
¶
The results of the battery of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
results |
tuple[BatteryResult, ...]
|
the result of every check of |
fates |
tuple[Fate, ...]
|
the fate of every dose of every build, see |
settings |
str
|
the settings of the simulations in words. |
result
¶
Get the result of a check.
Raises:
| Type | Description |
|---|---|
KeyError
|
if the battery has no result of the check. |
BatteryResult
dataclass
¶
The result of a check of the battery over the builds of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
check |
Check
|
the check. |
status |
BatteryStatus
|
whether it passed, failed or was not applicable. |
cases |
int
|
what was checked, e.g. the doses of the mass balance over the builds or the species of the non-negativity. |
largest |
float
|
the largest relative deviation of the check, |
at |
str
|
where the largest deviation is, e.g. |
problems |
tuple[str, ...]
|
what failed, a line each. |
statement |
str
|
what was checked in words, the reason for a check which is not applicable. |
BatteryStatus
¶
Bases: StrEnum
The result of a check of the battery.
Fate
dataclass
¶
Where a dose went at the end of the horizon, the mass balance of a route.
The parts are the differences to the simulation without a dose, so the fate of a dose of an endogenous substance is that of the dose and not of its production.
Attributes:
| Name | Type | Description |
|---|---|---|
build |
str
|
the build, e.g. |
dose |
str
|
the dose state or infusion rate, e.g. |
substance |
str
|
the dosed substance. |
amount |
float
|
the dose (mmole). |
parts |
Mapping[str, float]
|
the parts of the dose (mmole) by name: |
imbalance |
float
|
the imbalance of the dose simulation relative to the largest term of its balance. |
Acceptance
dataclass
¶
The percentage of the points a criterion accepts is at least minimum.
Attributes:
| Name | Type | Description |
|---|---|---|
criterion |
Criterion
|
the criterion, e.g. |
minimum |
float
|
the minimum percentage (0 to 100). |
AcceptanceResult
dataclass
¶
The result of an acceptance rule.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
the name of the rule. |
value |
float
|
the value of the rule on the points, |
limit |
str
|
the limit, e.g. |
met |
bool | None
|
whether the rule is met, |
AcceptanceRule
¶
AfeRange
dataclass
¶
The average fold error, the bias, is inside the range.
Attributes:
| Name | Type | Description |
|---|---|---|
low |
float
|
the smallest accepted AFE. |
high |
float
|
the largest accepted AFE. |
ContextOfUse
dataclass
¶
ContextOfUse(
*,
id,
title,
question,
level,
influence,
consequence,
quantities,
domain,
evidence,
acceptance=(),
limitations=(),
rationale="",
extrapolation="",
min_points=None,
ratio_acceptance=None,
)
What a model is used for: the question, the domain, the evidence and the acceptance.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the slug of the context, unique in the model. |
title |
str
|
the title. |
question |
str
|
the question of the context, one sentence. |
level |
CouLevel
|
the level on the ladder. |
influence |
Level
|
the influence of the model on the decision. |
consequence |
Level
|
the consequence of a wrong decision. |
quantities |
tuple[QuantityOfInterest, ...]
|
the quantities asked for, at least one which is no ratio. |
domain |
Domain
|
the domain claimed, at least one value of the metadata above C1. |
evidence |
tuple[Evidence, ...]
|
the evidence. |
acceptance |
tuple[AcceptanceRule, ...]
|
the rules, empty for the default of the risk. |
limitations |
tuple[Evidence, ...]
|
the evidence of what the model does not describe. |
rationale |
str
|
why this level, influence and consequence. |
extrapolation |
str
|
the argument for a domain without validation evidence. |
min_points |
int | None
|
the evaluable decisive points the verdict needs, at least
1; |
ratio_acceptance |
GuestAcceptance | None
|
the rule of the pairs of the assessed ratio
quantities, |
ratio_rule
property
¶
Get the rule of the ratio pairs: the declared or the default of the risk.
minimum_points
property
¶
Get the evaluable points the verdict needs: the declared or the default of the risk.
decisive_role
property
¶
Get the role of the evidence which decides, see CouLevel.decisive_role.
CouLevel
¶
Credibility
dataclass
¶
Credibility(
*,
contexts,
limitations=(),
notes="",
covariates=DEFAULT_COVARIATES,
variability=None,
)
The contexts of use of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
contexts |
tuple[ContextOfUse, ...]
|
the contexts of use. |
limitations |
tuple[Evidence, ...]
|
the model limitations, evidence of what it does not describe. |
notes |
str
|
notes on the declaration. |
covariates |
Mapping[str, str]
|
the covariates of the subjects whose simulated values the
equivalency of the inputs checks against the reported ones, the
target of the model and the measurement type of PK-DB of its
reported value ( |
variability |
Variability | None
|
the variability between the subjects, relative
distributions of targets ( |
Raises:
| Type | Description |
|---|---|
DeclarationError
|
with every problem of the declaration. |
context
¶
Get a context of use by its id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
the id of the context. |
required |
Returns:
| Type | Description |
|---|---|
ContextOfUse
|
The context. |
Raises:
| Type | Description |
|---|---|
KeyError
|
if there is no such context. |
DeclarationError
¶
Bases: ValueError
The declaration of the credibility of a model is invalid.
Attributes:
| Name | Type | Description |
|---|---|---|
problems |
every problem of the declaration. |
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problems
|
list[str]
|
every problem of the declaration. |
required |
Domain
dataclass
¶
The domain a context of use claims.
Attributes:
| Name | Type | Description |
|---|---|---|
metadata |
Mapping[str, Collection[StrEnum]]
|
the claimed values by field of |
statement |
str
|
what is claimed beyond the metadata, e.g. the dose range. |
problems
¶
Get the problems of the domain: an unknown field or a value of another vocabulary.
Evidence
dataclass
¶
A selection of the data with a role.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
the name of the evidence. |
role |
EvidenceRole
|
what the evidence is used for. |
selection |
Selection
|
the fit mappings it selects. |
description |
str
|
what the evidence is. |
fit |
str | None
|
the subset of the adopted fits it is taken from, |
EvidenceRole
¶
Bases: StrEnum
What evidence is used for.
GuestAcceptance
dataclass
¶
The percentage of the ratio pairs within the limits of Guest et al. is at least minimum.
Attributes:
| Name | Type | Description |
|---|---|---|
minimum |
float
|
the minimum percentage (0 to 100). |
delta |
float
|
the accepted variability at a ratio of 1, see
|
evaluate
¶
Evaluate the percentage of the evaluable pairs within the limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pairs
|
Collection[bool | None]
|
whether every pair is within, |
required |
Returns:
| Type | Description |
|---|---|
AcceptanceResult
|
The result, not evaluable without an evaluable pair. |
problems
¶
Get the problems of the rule: a minimum outside 0 to 100, a delta not above 1.
Level
¶
Bases: StrEnum
A level of influence, consequence or risk.
MaxGmfe
dataclass
¶
QuantityOfInterest
dataclass
¶
A quantity a context of use is asked for.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the observable of the fit mappings, e.g. |
description |
str
|
what the quantity is. |
ratio |
bool | Ratio
|
whether the quantity is a ratio between arms: |
Ratio
dataclass
¶
The arms of a ratio quantity: a numerator over its reference in a study.
See pkpdsim.credibility.ratios: per fit and study (the experiment) every
decisive mapping of the observable which numerator selects is paired
with the one which denominator selects, and the ratio of their summaries
is compared for the data and the predictions.
Attributes:
| Name | Type | Description |
|---|---|---|
observable |
str
|
the observable of the arms, e.g. |
numerator |
MappingFilter
|
selects the mappings of the arms, e.g. the renal impairment. |
denominator |
MappingFilter
|
selects the mapping of the reference arm, e.g. healthy. |
summary |
Summary
|
how the points of an arm are summarized. |
Summary
¶
Bases: StrEnum
How the points of an arm of a ratio are summarized, see Ratio.
Unclaimed
dataclass
¶
The validation points which no other evidence and no limitation selects.
Attributes:
| Name | Type | Description |
|---|---|---|
within |
MappingFilter | None
|
restricts the points to the ones this filter selects. |
Factor
dataclass
¶
A credibility factor of V&V 40.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
str
|
the id of the factor. |
name |
str
|
the name of the factor in V&V 40. |
status |
FactorStatus
|
how the factor is assessed. |
statement |
str
|
what the factor assesses, or the platform statement. |
step |
int | None
|
the step of the credibility work which will assess a factor which
is not assessed, |
FactorRecord
¶
Bases: TypedDict
A factor as plain data, see Factor.
FactorStatus
¶
Bases: StrEnum
How a credibility factor is assessed.
InputCheck
¶
Bases: TypedDict
The check of a simulated input of a mapping against the reported one.
Attributes:
| Name | Type | Description |
|---|---|---|
fit |
str
|
the subset of the fit. |
experiment |
str
|
the experiment, the study. |
mapping |
str
|
the key of the mapping. |
target |
str
|
the target of the model. |
kind |
str
|
|
measurement |
str
|
the measurement type of the reported value ( |
unit |
str
|
the unit of the target in the model, of every value. |
simulated |
float
|
the simulated value. |
source |
str
|
|
reported |
float | None
|
the reported central value (mean, median, geometric mean,
the value of an individual, the dose) the simulated one is
compared with, |
low |
float | None
|
the low end of the reported range, |
high |
float | None
|
the high end of the reported range, |
reported_by |
list[str]
|
the groups, individuals or interventions of the reported value. |
status |
str
|
the result, see |
ratio |
float | None
|
the simulated over the reported central value, |
InputsRecord
¶
Bases: TypedDict
The equivalency of the inputs of the decisive mappings of a context.
Attributes:
| Name | Type | Description |
|---|---|---|
n_mappings |
int
|
the decisive mappings. |
n_checked |
int
|
the decisive mappings with at least one input checked. |
inputs |
list[InputSummary]
|
the summary of every input, sorted by kind and target. |
differs |
list[InputCheck]
|
the checks which differ. |
InputStatus
¶
Bases: StrEnum
How a simulated input compares with the reported one.
LockMismatchError
¶
Bases: ValueError
The evidence selects other mappings than the lock of the declaration.
Attributes:
| Name | Type | Description |
|---|---|---|
problems |
every evidence which differs, with its added and removed mappings. |
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problems
|
list[str]
|
every evidence which differs. |
required |
RatioRecord
¶
Bases: TypedDict
A pair of arms of a ratio quantity.
Attributes:
| Name | Type | Description |
|---|---|---|
quantity |
str
|
the id of the ratio quantity. |
fit |
str
|
the subset of the fit of the points. |
experiment |
str
|
the experiment, the study of the arms. |
numerator |
str
|
the key of the mapping of the numerator. |
denominator |
str
|
the key of the mapping of the denominator. |
observed |
float
|
the ratio of the summaries of the data, |
predicted |
float
|
the ratio of the summaries of the predictions. |
limit |
float
|
the limit of Guest et al. for the observed ratio. |
within |
bool | None
|
whether the predicted ratio lies within the limits, |
metadata |
dict[str, str]
|
the values of the fields of the domain of the numerator
( |
FitTable
dataclass
¶
The data points of the adopted fits of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
table |
DataFrame
|
one row per data point ( |
lookup |
MappingLookup
|
the fit mapping of an experiment and a key. |
recorded_kinds |
Kinds
|
the kinds the records of the adopted fits store, by the subset of the fit, the experiment and the key of the mapping. |
reports |
Mapping[str, FitReport]
|
the reports the data points were evaluated with, by the
subset of the fit ( |
KindMismatchError
¶
Bases: ValueError
The kinds of the fit mappings differ from the kinds the adopted fits recorded.
Attributes:
| Name | Type | Description |
|---|---|---|
problems |
every mapping whose kind differs. |
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problems
|
list[str]
|
every mapping whose kind differs. |
required |
EvidenceSelection
dataclass
¶
The data points of an evidence of a context of use.
Attributes:
| Name | Type | Description |
|---|---|---|
context |
str
|
the id of the context of use. |
evidence |
Evidence
|
the evidence. |
rows |
Index
|
the selected rows of the table of the fits ( |
outliers_dropped |
int
|
the points of kind outlier which a validation selected and dropped. |
limitation_subtracted |
int
|
the limitation points the evidence selected and which were subtracted. |
SelectionError
¶
Bases: ValueError
The evidence of a declaration selects invalid data.
Attributes:
| Name | Type | Description |
|---|---|---|
problems |
every problem of the selection. |
Create the error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
problems
|
list[str]
|
every problem of the selection. |
required |
Selections
dataclass
¶
The data points of the evidence of every context of use of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
evidence |
tuple[EvidenceSelection, ...]
|
the selection of every evidence, in the order of the contexts and their evidence. |
limitations |
Index
|
the rows of the limitations of the model and of every context. |
unclaimed |
DataFrame
|
the validation points of no evidence and no limitation, with
the columns |
limitation_evidence |
tuple[EvidenceSelection, ...]
|
the selection of every limitation, the ones of the
model first, with the context |
StudyData
¶
Bases: TypedDict
The data of a study the adopted fits of a model have points of.
Attributes:
| Name | Type | Description |
|---|---|---|
study |
str
|
the study (the experiment). |
folder |
str | None
|
the folder of the study relative to the folder of the model,
|
fits |
list[str]
|
the subsets of the fits with points of the study. |
n_points |
int
|
the data points of the study in the fits, a point of two fits twice. |
recorded |
bool
|
whether the folder has a record of its collection. |
collected |
str | None
|
the day of the first collection, ISO format. |
dating |
str | None
|
how the day of the first collection is known. |
updated |
str | None
|
the day of the latest collection, ISO format. |
released |
str | None
|
the day PK-DB released the study, ISO format. |
pkdb_id |
str | None
|
the identifier of the release in PK-DB. |
source_digest |
str | None
|
the digest of the source files in PK-DB. |
pkdb_data_commit |
str | None
|
the commit of pkdb_data of the latest collection. |
pkdb_data_dirty |
bool | None
|
whether the study folder of that checkout had changes. |
n_tables |
int
|
the tables of the record. |
changed |
list[str] | None
|
the tables which differ from the record ( |
Chronology
dataclass
¶
When the adopted fits of a model ran and when it collected its studies.
Attributes:
| Name | Type | Description |
|---|---|---|
fits |
Mapping[str, date]
|
the day of every adopted fit, by its subset. |
studies |
Mapping[str, StudyRecord]
|
the record of every study of the data of the model, by study. |
new
¶
Get which points are of a study collected after the day of their fit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
points
|
DataFrame
|
data points with the columns |
required |
Returns:
| Type | Description |
|---|---|
Series
|
True for a point whose study the model collected after the day of |
Series
|
its fit; False for a point without a day of collection or fit. |
TemporalRecord
¶
Bases: TypedDict
The decisive points of a context of use which are new for their fit.
Attributes:
| Name | Type | Description |
|---|---|---|
studies |
list[TemporalStudy]
|
the new studies, by study and fit. |
n_points |
int
|
the decisive points of the new studies. |
n_evaluable |
int
|
those the fold criteria can evaluate. |
acceptance |
list[AcceptanceRecord]
|
the acceptance rules of the context on the new points. |
n_known |
int
|
the decisive studies which the model collected no later than the day of their fit. |
undated |
list[str]
|
the decisive studies without a day of collection. |
TemporalStudy
¶
Bases: TypedDict
A study a model collected after the fit of its decisive points.
Attributes:
| Name | Type | Description |
|---|---|---|
study |
str
|
the study (the experiment). |
fit |
str
|
the subset of the fit. |
fit_date |
str
|
the day the fit ran, ISO format. |
collected |
str
|
the day the model collected the study, ISO format. |
released |
str | None
|
the day PK-DB released the study, |
pkdb_id |
str | None
|
the identifier of the release in PK-DB. |
n_points |
int
|
the decisive points of the study of this fit. |
n_evaluable |
int
|
those the fold criteria can evaluate. |
Propagation
dataclass
¶
The decisive predictions at the draws of the parameters of the fits.
Attributes:
| Name | Type | Description |
|---|---|---|
settings |
UncertaintySettings
|
the settings of the propagation. |
draws |
Mapping[str, FitDraws]
|
the draws of every fit, by its subset. |
predictions |
DataFrame
|
one column per draw, the rows of the table of the fits;
|
failed |
Mapping[str, int]
|
the failed draws of every fit, by its subset. |
UncertaintyRecord
¶
Bases: TypedDict
The parameter uncertainty of the decisive predictions of a context of use.
Attributes:
| Name | Type | Description |
|---|---|---|
n_draws |
int
|
the draws of every fit. |
seed |
int
|
the seed. |
quantiles |
list[float]
|
the quantiles of the bands. |
threshold |
float
|
the probability of the statements of the rules. |
level |
float
|
the level of the decisions of the rules together. |
fits |
list[FitUncertainty]
|
the draws of the fits of the decisive points. |
n_points |
int
|
the evaluable decisive points with a band. |
coverage |
float | None
|
the share of them whose observation is inside the band. |
quantities |
list[QuantityBand]
|
the bands of the quantities which are no ratio. |
rules |
list[RuleProbability]
|
the probability of every acceptance rule, the ratio rule last. |
sensitivity |
list[SensitivityIndex]
|
the first-order indices of every quantity (the mean log ratio of its predictions to the reference predictions) and of the value of every rule to every fitted parameter of the draws. |
UncertaintySettings
dataclass
¶
The settings of the propagation of the parameter uncertainty.
Attributes:
| Name | Type | Description |
|---|---|---|
draws |
int
|
the number of draws of every fit, a power of two keeps the balance of the Sobol points; 128 decide a rule met on every draw at the threshold 0.9 for up to about ten rules of a context. |
seed |
int
|
the seed of the draws. |
quantiles |
tuple[float, float]
|
the quantiles of the prediction bands. |
threshold |
float
|
the probability of the statement that a rule is met. |
level |
float
|
the level of the decisions of the rules of a context of use, together (Bonferroni over its rules). |
PredictiveChecks
dataclass
¶
The predictive checks of the adopted fits of a model.
Attributes:
| Name | Type | Description |
|---|---|---|
settings |
VariabilitySettings
|
the settings. |
variability |
Variability
|
the declared variability. |
points |
DataFrame
|
the band of every row of the table of the fits, indexed as it,
with the columns of |
vectors |
Mapping[str, int]
|
the parameter vectors of every fit, by its subset. |
studies |
Mapping[str, int]
|
the studies of every parameter vector of every fit, by its subset. |
failed |
Mapping[str, int]
|
the failed subjects of every fit, by its subset. |
VariabilityRecord
¶
Bases: TypedDict
The predictive check of the decisive points of a context of use.
Attributes:
| Name | Type | Description |
|---|---|---|
subjects |
int
|
the subjects of every study of a parameter vector. |
studies |
int
|
the studies of every parameter vector, 1 without a variability between the studies. |
vectors |
int
|
the parameter vectors of the fits, the draws of the uncertainty or 1 for the adopted parameters. |
groups |
int
|
the virtual groups of a data point of a group. |
seed |
int
|
the seed. |
targets |
dict[str, str]
|
the target of every factor and its distribution. |
between |
dict[str, str]
|
the target of every factor between the studies and its distribution, empty without. |
quantiles |
list[float]
|
the quantiles of the bands. |
expected |
float
|
the probability between them, the coverage of a model whose variability is the one of the data. |
n_points |
int
|
the evaluable decisive points with a band. |
n_groups |
int
|
those of a group of more than one subject. |
coverage |
float | None
|
the share of them inside their band, |
low |
float | None
|
the low end of the Wilson interval of the coverage. |
high |
float | None
|
the high end. |
level |
float
|
the level of the interval. |
agreement |
str | None
|
|
quantities |
list[QuantityCoverage]
|
the coverage of every quantity of interest which is no ratio. |
failed |
int
|
the subjects whose simulation failed, over the fits. |
VariabilitySettings
dataclass
¶
VariabilitySettings(
subjects=64,
studies=16,
groups=1000,
seed=1234,
quantiles=(0.05, 0.95),
level=0.95,
)
The settings of the predictive checks.
Attributes:
| Name | Type | Description |
|---|---|---|
subjects |
int
|
the subjects of every study of a parameter vector of a fit. |
studies |
int
|
the studies of every parameter vector of a variability
between the studies ( |
groups |
int
|
the virtual groups of a data point of a group per study. |
seed |
int
|
the seed of the subjects and the groups. |
quantiles |
tuple[float, float]
|
the quantiles of the bands. |
level |
float
|
the level of the Wilson interval of the coverage. |
Check
¶
Bases: StrEnum
A check of the verification and the factor of V&V 40 it assesses.
The checks of the predictions (tolerances, integrator, setup)
compare the decisive predictions of a context of use; the checks of the
battery (pkpdsim.credibility.battery) check the builds of the model,
for every context of use alike.
CheckRecord
¶
Bases: TypedDict
The result of a check for a context of use.
A check of the battery (pkpdsim.credibility.battery) is a check of the
builds of the model, the same for every context.
Attributes:
| Name | Type | Description |
|---|---|---|
check |
str
|
the check, see |
factor |
str
|
the id of the factor of V&V 40 the check assesses. |
n_points |
int
|
the decisive points compared, the cases of a check of the battery. |
max_difference |
float
|
the largest relative difference of a decisive
prediction, |
at |
str
|
the point of the largest difference, |
acceptance_changed |
bool | None
|
whether a rule of the acceptance is met with the
alternative predictions and not with the reference or the other
way, |
passed |
bool
|
whether the check passed. |
problems |
list[str]
|
what failed beyond the numbers, e.g. a failed evaluation or an issue of a build. |
Verification
dataclass
¶
The alternative predictions and the problems an assessment is verified with.
Attributes:
| Name | Type | Description |
|---|---|---|
predictions |
Mapping[Check, Series]
|
the predictions of every numerical check ( |
failures |
Mapping[Check, Mapping[str, str]]
|
the failed evaluations of every numerical check, the message by the subset of the fit. |
summary |
VerificationSummary
|
what was compared, see |
VerificationSummary
dataclass
¶
What the verification of an assessment compared, as plain data.
Attributes:
| Name | Type | Description |
|---|---|---|
tightening |
float
|
the factor the tolerances were divided by. |
limit |
float
|
the largest relative difference a check accepts. |
scale_floor |
float
|
the floor of a relative difference, of the largest reference prediction of the mapping. |
fits |
list[FitSettingsRecord]
|
the settings of every adopted fit and of its alternatives. |
problems |
list[str]
|
the issues of the builds of the model, see
|
battery |
Battery | None
|
the checks of the builds of the model, see
|
assess
¶
assess(
model,
source_commit=None,
*,
verification=True,
lock=False,
uncertainty=None,
variability=None,
)
Assess the contexts of use of a model on its adopted fits.
The fits are evaluated fresh on the current model and data, see
evaluate_fits, and, with verification, again with the alternatives of
the checks of pkpdsim.credibility.verification; the cross-validations of
the adopted fits, the chronology of the model and its studies
(pkpdsim.credibility.temporal) and the provenance of the study data
(pkpdsim.credibility.studies) are read, and the simulated inputs of the
mappings are checked against the reported ones
(pkpdsim.credibility.inputs).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model with a declaration and adopted fits. |
required |
source_commit
|
str | None
|
the commit of the source repository of a release, see
|
None
|
verification
|
bool
|
verify the decisive predictions; the factors of the verification are not assessed without. |
True
|
lock
|
bool
|
write the lock of the evidence ( |
False
|
uncertainty
|
UncertaintySettings | None
|
propagate the parameter uncertainty of the adopted fits
to the decisive predictions with these settings, see
|
None
|
variability
|
VariabilitySettings | None
|
check the decisive points with the declared variability
of the subjects ( |
None
|
Returns:
| Type | Description |
|---|---|
CredibilityAssessment
|
The assessment. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model has no declaration or no adopted fits, or the settings of the variability are given for a declaration without a variability. |
KindMismatchError
|
if a kind differs from the recorded one. |
SelectionError
|
if the evidence selects invalid data. |
LockMismatchError
|
if the evidence differs from the lock. |
assess_table
¶
assess_table(
credibility,
fits,
provenance,
verification=None,
cross_validations=(),
chronology=None,
studies=(),
propagation=None,
inputs=None,
variability=None,
)
Assess the contexts of use of a declaration on the data points of the fits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credibility
|
Credibility
|
the declaration. |
required |
fits
|
FitTable
|
the data points of the adopted fits with |
required |
provenance
|
Provenance
|
what the table was computed from. |
required |
verification
|
Verification | None
|
the alternative predictions of the table and the issues
of the builds, see |
None
|
cross_validations
|
Sequence[CrossValidation]
|
the cross-validations of the adopted fits, which assess the factor model form. |
()
|
chronology
|
Chronology | None
|
when the adopted fits ran and the model collected its
studies, see |
None
|
studies
|
Sequence[StudyData]
|
the provenance of the study data of the points, see
|
()
|
propagation
|
Propagation | None
|
the predictions at the draws of the parameters of the
fits, see |
None
|
inputs
|
Sequence[InputCheck] | None
|
the checks of the simulated inputs of the mappings against the
reported ones, see |
None
|
variability
|
PredictiveChecks | None
|
the predictive checks of the fits with the declared
variability, see |
None
|
Returns:
| Type | Description |
|---|---|
CredibilityAssessment
|
The assessment. |
Raises:
| Type | Description |
|---|---|
SelectionError
|
if the evidence selects invalid data, see |
describe_selection
¶
Describe what a selection of an evidence selects.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selection
|
Selection
|
the selection. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The mapping keys by study for a |
str
|
|
str
|
|
str
|
|
str
|
the description of its filter; the qualified name otherwise. |
run_battery
¶
Run the battery of the checks of a model on its builds.
The checks of the simulations need a substance with a molecular weight,
Mr_<s>, the convention of the PBPK models; they are not applicable to a
model without.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model, every build of |
required |
rebuild
|
bool
|
run the check |
True
|
cross_simulator
|
bool
|
run the check |
True
|
Returns:
| Type | Description |
|---|---|
Battery
|
The results of the checks and the fates of the doses. |
check_declaration
¶
Check the credibility declaration of a model against its adopted fits.
The declaration must be valid, the kinds of the mappings of the current
selection of the fit definitions must be the recorded kinds of the adopted
fits, and the evidence must select valid data (see select), all from the
fit definitions and the records, without a simulation, and select the
mappings of its lock, if the model has one. A problem of the
records, e.g. a record without the kinds of its mappings, two kinds of one
mapping, no adopted fits or a subset adopted twice, is a problem as well,
after which the kinds and the evidence are not checked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model with a declaration and adopted fits. |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
Every problem, empty if the declaration holds. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model has no declaration. |
input_checks
¶
Check the simulated inputs of every mapping of the adopted fits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model, the folders of its studies hold the reported values. |
required |
fits
|
FitTable
|
the evaluated adopted fits with their reports, see
|
required |
covariates
|
Mapping[str, str]
|
the target of every covariate and the measurement type of
its reported value, see |
required |
Returns:
| Type | Description |
|---|---|
list[InputCheck]
|
The checks of every mapping of the points, in the order of the fits and |
list[InputCheck]
|
their mappings. |
lock_differences
¶
Get every evidence whose mappings differ from the lock of the model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model. |
required |
selections
|
Selections
|
the current selection of its declaration. |
required |
fits
|
FitTable
|
the table of the fits the selection was made on. |
required |
Returns:
| Type | Description |
|---|---|
list[str] | None
|
A line per evidence which is new, gone or selects other mappings, with |
list[str] | None
|
the added ( |
list[str] | None
|
matches the lock, |
write_lock
¶
Write the lock of the evidence of a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model. |
required |
selections
|
Selections
|
the selection of its declaration. |
required |
fits
|
FitTable
|
the table of the fits the selection was made on. |
required |
Returns:
| Type | Description |
|---|---|
Path
|
The file of the lock. |
guest_limit
¶
Get the limit of Guest et al. (2011) of an observed ratio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observed
|
float
|
the observed ratio, positive. |
required |
delta
|
float
|
the accepted variability at a ratio of 1. |
GUEST_DELTA
|
Returns:
| Type | Description |
|---|---|
float
|
The limit, |
ratio_pairs
¶
Get the pairs of the arms of a ratio quantity in the decisive points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
quantity
|
str
|
the id of the ratio quantity. |
required |
ratio
|
Ratio
|
its pairing. |
required |
points
|
DataFrame
|
the decisive points of the context of use with |
required |
lookup
|
MappingLookup
|
the fit mapping of an experiment and a key, which the filters of the numerator and the denominator read. |
required |
delta
|
float
|
the accepted variability of the limit at a ratio of 1. |
GUEST_DELTA
|
Returns:
| Type | Description |
|---|---|
list[RatioRecord]
|
The pairs, in the order of the points, and the problems of |
list[str]
|
|
evaluate_fits
¶
Evaluate the adopted fits of a model into the table of their data points.
Every fit is evaluated fresh on the current model and data with the settings
it ran with (sbmlsim.fit.cli.report_from_records), at the reference
parameter set of its record; the kinds of its mappings must be the recorded
ones.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model, its |
required |
Returns:
| Type | Description |
|---|---|
FitTable
|
The data points of every fit with the column |
FitTable
|
report of every fit. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model has no adopted fits, see |
FileNotFoundError
|
if a record has no parameters or no kinds. |
KindMismatchError
|
if a kind differs from the recorded one. |
kind_differences
¶
Compare the kinds of the mappings of a table with the recorded kinds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
DataFrame
|
a table of the fits with the columns |
required |
recorded
|
Kinds
|
the recorded kinds, see |
required |
Returns:
| Type | Description |
|---|---|
list[str]
|
One message per mapping whose kind differs from the recorded one, or |
list[str]
|
which only the table or only the record has; empty if the kinds agree. |
mapping_table
¶
Get the mappings of the adopted fits of a model without a simulation.
The kinds are the ones of the current selection of every fit definition;
the excluded mappings, which a fit does not evaluate, are no rows. The
recorded kinds are compared by the caller, see kind_differences.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model, its |
required |
Returns:
| Type | Description |
|---|---|
FitTable
|
One row per fit and mapping with the columns of |
FitTable
|
fields of the metadata. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the model has no adopted fits, see |
FileNotFoundError
|
if a record has no parameters or no kinds. |
recorded_kinds
¶
Get the kinds of the mappings which the record of an adopted fit stores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
record
|
Path
|
the directory of the record of the adopted fit. |
required |
fit
|
str
|
the subset of the fit, the first item of every key. |
required |
Returns:
| Type | Description |
|---|---|
dict[tuple[str, str, str], str]
|
The kind by the subset, the experiment and the key of the mapping. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
if the record has no metrics of its mappings. |
ValueError
|
if the metrics lack the experiment, the mapping or the kind, or store two kinds of one mapping. |
default_acceptance
¶
Get the acceptance a context of use of a risk takes without its own.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
risk
|
Level
|
the model risk. |
required |
Returns:
| Type | Description |
|---|---|
tuple[AcceptanceRule, ...]
|
The rules, all of which must be met. |
model_risk
¶
normalize_observable
¶
Get an observable without the brackets of a concentration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
observable
|
str
|
the observable, e.g. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The observable, e.g. |
select
¶
Select the data points of the evidence of every context of use.
A mapping (its experiment and key) which is training data of any adopted fit
counts as fitted in every fit: a validation which selects its points, in
any fit, is an error which names the fits it is training data of, and
neither Unclaimed nor the unclaimed validation points take them. Two
Unclaimed of different contexts may take the same points. See the module
for the other rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
credibility
|
Credibility
|
the declaration. |
required |
fits
|
FitTable
|
the table of the adopted fits, see |
required |
Returns:
| Type | Description |
|---|---|
Selections
|
The points of every evidence, the limitation points and the unclaimed |
Selections
|
validation points. |
Raises:
| Type | Description |
|---|---|
SelectionError
|
with every problem of the selection. |
study_data
¶
Get the provenance of the studies the data points are of.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model. |
required |
points
|
DataFrame
|
the data points of the adopted fits, with the columns |
required |
Returns:
| Type | Description |
|---|---|
list[StudyData]
|
A record per study of the points, sorted by study. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a record is not readable, see
|
chronology
¶
Get when the adopted fits of a model ran and when it collected its studies.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model. |
required |
Returns:
| Type | Description |
|---|---|
Chronology
|
The days of the adopted fits of |
Chronology
|
study folders of every data path of the model. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a record is not readable, see
|
propagate
¶
Evaluate the adopted fits of a model at the draws of their parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model with its adopted fits. |
required |
fits
|
FitTable
|
the fresh evaluation of the fits with their reports, see
|
required |
settings
|
UncertaintySettings
|
the settings of the propagation. |
required |
Returns:
| Type | Description |
|---|---|
Propagation
|
The predictions per draw. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the points of a draw are not the reference points. |
predictive_checks
¶
Get the predictive check of every adopted fit of a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model with its adopted fits. |
required |
fits
|
FitTable
|
the fresh evaluation of the fits with their reports, see
|
required |
variability
|
Variability
|
the variability of the subjects. |
required |
settings
|
VariabilitySettings
|
the settings. |
required |
propagation
|
Propagation | None
|
the draws of the parameters of the fits, see
|
None
|
Returns:
| Type | Description |
|---|---|
PredictiveChecks
|
The bands of the points of the fits. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if a target of the variability cannot be scaled in a simulation of a fit, or the points of a check are not the points of the fit. |
verify
¶
Evaluate the adopted fits of a model with the alternatives of the checks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
PKPDModel
|
the model, whose builds are checked. |
required |
fits
|
FitTable
|
the data points of the adopted fits with their reports, see
|
required |
tightening
|
float
|
the factor the tolerances are divided by. |
TIGHTENING
|
battery
|
bool
|
run the battery of the checks of the builds, see
|
True
|
Returns:
| Type | Description |
|---|---|
Verification
|
The alternative predictions, the issues of the builds and the battery. |
Raises:
| Type | Description |
|---|---|
ValueError
|
if the table of the fits has no reports. |