nannyml.io.db.entities module
Contains the definitions of the database entities that map directly to the underlying table definitions.
Every Result
class has a matching Entity
class, which implies that each calculator or estimator will export
its results into a specific table.
- class nannyml.io.db.entities.CBPEPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float] = None, lower_threshold: Optional[float] = None)[source]
Bases:
nannyml.io.db.entities.Metric
Represents results of the
CBPE
estimator.Stored in the
cbpe_performance_metrics
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.DLEPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float] = None, lower_threshold: Optional[float] = None)[source]
Bases:
nannyml.io.db.entities.Metric
Represents results of the
DLE estimator
.Stored in the
dle_performance_metrics
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.DataReconstructionFeatureDriftMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float] = None, lower_threshold: Optional[float] = None)[source]
Bases:
nannyml.io.db.entities.Metric
DataReconstructionDriftCalculator
results.Stored in the
data_reconstruction_feature_drift_metrics
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.Metric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool)[source]
Bases:
sqlmodel.main.SQLModel
Base
Metric
definition.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
The technical identifier for this database row
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime.datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- value: float
The value returned by the method
- class nannyml.io.db.entities.Model(*, id: Optional[int] = None, name: str)[source]
Bases:
sqlmodel.main.SQLModel
Represents a
Model
.Only created when the
model_name
property of theDatabaseWriter
was given. Theid
field here will act as a foreign key in therun
table and allmetric
tables.Stored in the
model
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
A technical key that is used as a foreign key in the other tables
- name: str
Optional model name that might be useful in visualizations e.g. in Grafana dashboards
- class nannyml.io.db.entities.RealizedPerformanceMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool, upper_threshold: Optional[float] = None, lower_threshold: Optional[float] = None)[source]
Bases:
nannyml.io.db.entities.Metric
Represents results of the
PerformanceCalculator
.Stored in the
realized_performance_metrics
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- id: Optional[int]
The technical identifier for this database row
- lower_threshold: Optional[float]
The lower alerting threshold value
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- upper_threshold: Optional[float]
The upper alerting threshold value
- value: float
The value returned by the method
- class nannyml.io.db.entities.Run(*, id: Optional[int] = None, model_id: Optional[int] = None, execution_timestamp: datetime.datetime = datetime.datetime(2023, 7, 13, 14, 50, 34, 300909))[source]
Bases:
sqlmodel.main.SQLModel
Represents a NannyML run, allowing to filter results based on what run generated them.
The
id
field here will act as a foreign key in allmetric
tables.Stored in the
run
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- execution_timestamp: datetime.datetime
Execution time of NannyML run
- id: Optional[int]
Foreign key in all
metric
tables
- model: nannyml.io.db.entities.Model
The actual
Model
class instance that is linked to the run
- model_id: Optional[int]
Used to link a run to a model
- class nannyml.io.db.entities.UnivariateDriftMetric(*, id: Optional[int] = None, model_id: Optional[int] = None, run_id: int = None, start_timestamp: datetime.datetime, end_timestamp: datetime.datetime, timestamp: datetime.datetime, metric_name: str, value: float, alert: bool, column_name: str)[source]
Bases:
nannyml.io.db.entities.Metric
Represents results of the
UnivariateDriftCalculator
.Stored in the
univariate_drift_metrics
table.Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- column_name: str
The name of the column this metric belongs to
- id: Optional[int]
The technical identifier for this database row
- metric_name: str
The name of the method being calculated, e.g.
jensen_shannon
orchi2
- model_id: Optional[int]
Foreign key pointing to a record in the
model
table
- run_id: int
Foreign key pointing to a record in the
run
table
- timestamp: datetime
The ‘’center’’ timestamp of the
Chunk
, i.e. the mean of the start and end timestamps
- value: float
The value returned by the method