cyclonedx.model.model_card
This set of classes represents the model card types in the CycloneDX standard.
Note
Introduced in CycloneDX v1.5. Environmental considerations were added in v1.6.
Note
See the CycloneDX Schema for model cards:
Classes
Unit of CO2. Currently only tCO2eq is defined by CycloneDX 1.6+. |
|
Unit of energy. Currently only kWh is defined by CycloneDX 1.6+. |
|
Enumeration for machineLearningApproachType. |
|
Container for the approach element within modelParameters. |
|
Definition for items under modelParameters.inputs[] and outputs[]. |
|
modelParameters block within modelCard. |
|
Confidence interval with lower/upper bounds. |
|
A single performance metric entry. |
|
Graphic entry with optional name and image (AttachedText). |
|
A collection of graphics with optional description. |
|
quantitativeAnalysis block within modelCard. |
|
Entry in ethicalConsiderations with name and mitigation strategy. |
|
Entry in fairnessAssessments. |
|
Environmental considerations (1.6+). Energy consumptions and properties. |
|
Enumeration for lifecycle activity in energyConsumption.activity (1.6+). |
|
A measure of energy. Schema energyMeasure (1.6+): value + unit (kWh). |
|
A measure of CO2. Schema co2Measure (1.6+): value + unit (tCO2eq). |
|
Enumeration for provider energySource (1.6+). |
|
Energy provider per schema energyProvider (1.6+). |
|
Energy consumption entry. Matches schema energyConsumption (1.6+). |
|
considerations block within modelCard. |
|
Internal representation of CycloneDX modelCardType. |
Module Contents
- class cyclonedx.model.model_card.Co2MeasureUnit
Bases:
str,enum.EnumUnit of CO2. Currently only tCO2eq is defined by CycloneDX 1.6+.
- TCO2EQ = 'tCO2eq'
- class cyclonedx.model.model_card.EnergyMeasureUnit
Bases:
str,enum.EnumUnit of energy. Currently only kWh is defined by CycloneDX 1.6+.
- KWH = 'kWh'
- class cyclonedx.model.model_card.MachineLearningApproach
Bases:
str,enum.EnumEnumeration for machineLearningApproachType.
Values are stable across 1.5–1.7.
- SUPERVISED = 'supervised'
- UNSUPERVISED = 'unsupervised'
- REINFORCEMENT_LEARNING = 'reinforcement-learning'
- SEMI_SUPERVISED = 'semi-supervised'
- SELF_SUPERVISED = 'self-supervised'
- class cyclonedx.model.model_card.Approach(*, type: MachineLearningApproach | None = None)
Container for the approach element within modelParameters.
- property type: MachineLearningApproach | None
Learning types describing the learning problem or hybrid learning problem.
- Returns:
MachineLearningApproach if set else None
- class cyclonedx.model.model_card.InputOutputMLParameters(*, format: str)
Definition for items under modelParameters.inputs[] and outputs[].
- property format: str
The data format for input/output to the model.
- Returns:
str
- class cyclonedx.model.model_card.ModelParameters(*, approach: Approach | None = None, task: str | None = None, architecture_family: str | None = None, model_architecture: str | None = None, datasets: collections.abc.Iterable[Any] | None = None, inputs: collections.abc.Iterable[InputOutputMLParameters] | None = None, outputs: collections.abc.Iterable[InputOutputMLParameters] | None = None)
modelParameters block within modelCard.
Note
datasets is not supported yet (see issue #913):
passing non-empty datasets to the constructor raises NotImplementedError.
datasets found while deserializing JSON/XML are ignored, so re-serializing such a BOM drops them.
Note
inputs and outputs keep their given order and duplicates, because the position of an input/output is meaningful for a model signature.
- property approach: Approach | None
The overall approach to learning used by the model for problem solving.
- Returns:
Approach if set else None
- property task: str | None
Directly influences the input and/or output. Examples include classification, regression, clustering, etc.
- Returns:
str if set else None
- property architecture_family: str | None
The model architecture family such as transformer network, convolutional neural network, residual neural network, LSTM neural network, etc.
- Returns:
str if set else None
- property model_architecture: str | None
The specific architecture of the model such as GPT-1, ResNet-50, YOLOv3, etc.
- Returns:
str if set else None
- property inputs: List[InputOutputMLParameters]
The input format(s) of the model, in the given order.
- Returns:
List of InputOutputMLParameters
- property outputs: List[InputOutputMLParameters]
The output format(s) from the model, in the given order.
- Returns:
List of InputOutputMLParameters
- class cyclonedx.model.model_card.ConfidenceInterval(*, lower_bound: str | None = None, upper_bound: str | None = None)
Confidence interval with lower/upper bounds.
- property lower_bound: str | None
The lower bound of the confidence interval.
- Returns:
str if set else None
- property upper_bound: str | None
The upper bound of the confidence interval.
- Returns:
str if set else None
- class cyclonedx.model.model_card.PerformanceMetric(*, type: str | None = None, value: str | None = None, slice_: str | None = None, confidence_interval: ConfidenceInterval | None = None)
A single performance metric entry.
- property type: str | None
The type of performance metric.
- Returns:
str if set else None
- property value: str | None
The value of the performance metric.
- Returns:
str if set else None
- property slice_: str | None
The name of the slice this metric was computed on. By default, assume this metric is not sliced.
- Returns:
str if set else None
- property confidence_interval: ConfidenceInterval | None
The confidence interval of the metric.
- Returns:
ConfidenceInterval if set else None
- class cyclonedx.model.model_card.Graphic(*, name: str | None = None, image: cyclonedx.model.AttachedText | None = None)
Graphic entry with optional name and image (AttachedText).
- property name: str | None
The name of the graphic.
- Returns:
str if set else None
- property image: cyclonedx.model.AttachedText | None
The graphic (vector or raster). Base64 encoding must be specified for binary images.
- Returns:
AttachedText if set else None
- class cyclonedx.model.model_card.GraphicsCollection(*, description: str | None = None, collection: collections.abc.Iterable[Graphic] | None = None)
A collection of graphics with optional description.
- property description: str | None
A description of this collection of graphics.
- Returns:
str if set else None
- class cyclonedx.model.model_card.QuantitativeAnalysis(*, performance_metrics: collections.abc.Iterable[PerformanceMetric] | None = None, graphics: GraphicsCollection | None = None)
quantitativeAnalysis block within modelCard.
- property performance_metrics: SortedSet[PerformanceMetric]
The model performance metrics being reported. Examples may include accuracy, F1 score, precision, top-3 error rates, MSC, etc.
- Returns:
Set of PerformanceMetric
- property graphics: GraphicsCollection | None
A collection of graphics that represent various measurements.
- Returns:
GraphicsCollection if set else None
- class cyclonedx.model.model_card.EthicalConsideration(*, name: str | None = None, mitigation_strategy: str | None = None)
Entry in ethicalConsiderations with name and mitigation strategy.
- property name: str | None
The name of the risk.
- Returns:
str if set else None
- property mitigation_strategy: str | None
Strategy used to address this risk.
- Returns:
str if set else None
- class cyclonedx.model.model_card.FairnessAssessment(*, group_at_risk: str | None = None, benefits: str | None = None, harms: str | None = None, mitigation_strategy: str | None = None)
Entry in fairnessAssessments.
- property group_at_risk: str | None
The groups or individuals at risk of being systematically disadvantaged by the model.
- Returns:
str if set else None
- property benefits: str | None
Expected benefits to the identified groups.
- Returns:
str if set else None
- property harms: str | None
Expected harms to the identified groups.
- Returns:
str if set else None
- property mitigation_strategy: str | None
With respect to the benefits and harms outlined, any mitigation strategy implemented.
- Returns:
str if set else None
- class cyclonedx.model.model_card.EnvironmentalConsiderations(*, energy_consumptions: collections.abc.Iterable[EnergyConsumption] | None = None, properties: collections.abc.Iterable[cyclonedx.model.Property] | None = None)
Environmental considerations (1.6+). Energy consumptions and properties.
- property energy_consumptions: SortedSet[EnergyConsumption]
Describes energy consumption information incurred for one or more component lifecycle activities.
- Returns:
Set of EnergyConsumption
- class cyclonedx.model.model_card.EnergyActivity
Bases:
str,enum.EnumEnumeration for lifecycle activity in energyConsumption.activity (1.6+).
- DESIGN = 'design'
- DATA_COLLECTION = 'data-collection'
- DATA_PREPARATION = 'data-preparation'
- TRAINING = 'training'
- FINE_TUNING = 'fine-tuning'
- VALIDATION = 'validation'
- DEPLOYMENT = 'deployment'
- INFERENCE = 'inference'
- OTHER = 'other'
- class cyclonedx.model.model_card.EnergyMeasure(*, value: float, unit: EnergyMeasureUnit = EnergyMeasureUnit.KWH)
A measure of energy. Schema energyMeasure (1.6+): value + unit (kWh).
- property value: float
Quantity of energy.
- Returns:
float
- property unit: EnergyMeasureUnit
Unit of energy.
- Returns:
EnergyMeasureUnit
- class cyclonedx.model.model_card.Co2Measure(*, value: float, unit: Co2MeasureUnit = Co2MeasureUnit.TCO2EQ)
A measure of CO2. Schema co2Measure (1.6+): value + unit (tCO2eq).
- property value: float
Quantity of carbon dioxide (CO2).
- Returns:
float
- property unit: Co2MeasureUnit
Unit of carbon dioxide (CO2).
- Returns:
Co2MeasureUnit
- class cyclonedx.model.model_card.EnergySource
Bases:
str,enum.EnumEnumeration for provider energySource (1.6+).
- COAL = 'coal'
- OIL = 'oil'
- NATURAL_GAS = 'natural-gas'
- NUCLEAR = 'nuclear'
- WIND = 'wind'
- SOLAR = 'solar'
- GEOTHERMAL = 'geothermal'
- HYDROPOWER = 'hydropower'
- BIOFUEL = 'biofuel'
- UNKNOWN = 'unknown'
- OTHER = 'other'
- class cyclonedx.model.model_card.EnergyProvider(*, organization: cyclonedx.model.contact.OrganizationalEntity, energy_source: EnergySource, energy_provided: EnergyMeasure, bom_ref: str | cyclonedx.model.bom_ref.BomRef | None = None, description: str | None = None, external_references: collections.abc.Iterable[cyclonedx.model.ExternalReference] | None = None)
Energy provider per schema energyProvider (1.6+).
- property description: str | None
A description of the energy provider.
- Returns:
str if set else None
- property organization: cyclonedx.model.contact.OrganizationalEntity
The organization that provides energy.
- Returns:
OrganizationalEntity
- property energy_source: EnergySource
The energy source for the energy provider.
- Returns:
EnergySource
- property energy_provided: EnergyMeasure
The energy provided by the energy source for an associated activity.
- Returns:
EnergyMeasure
- property external_references: SortedSet[ExternalReference]
External references provide a way to document systems, sites, and information that may be relevant but are not included with the BOM.
- Returns:
Set of ExternalReference
- property bom_ref: cyclonedx.model.bom_ref.BomRef
An identifier which can be used to reference the energy provider elsewhere in the BOM. Every bom-ref must be unique within the BOM.
- Returns:
BomRef
- class cyclonedx.model.model_card.EnergyConsumption(*, activity: EnergyActivity, energy_providers: collections.abc.Iterable[EnergyProvider], activity_energy_cost: EnergyMeasure, co2_cost_equivalent: Co2Measure | None = None, co2_cost_offset: Co2Measure | None = None, properties: collections.abc.Iterable[cyclonedx.model.Property] | None = None)
Energy consumption entry. Matches schema energyConsumption (1.6+).
- property activity: EnergyActivity
The type of activity that is part of a machine learning model development or operational lifecycle.
- Returns:
EnergyActivity
- property energy_providers: SortedSet[EnergyProvider]
The provider(s) of the energy consumed by the associated model development lifecycle activity.
- Returns:
Set of EnergyProvider
- property activity_energy_cost: EnergyMeasure
The total energy cost associated with the model lifecycle activity.
- Returns:
EnergyMeasure
- property co2_cost_equivalent: Co2Measure | None
The CO2 cost (debit) equivalent to the total energy cost.
- Returns:
Co2Measure if set else None
- property co2_cost_offset: Co2Measure | None
The CO2 offset (credit) for the CO2 equivalent cost.
- Returns:
Co2Measure if set else None
- class cyclonedx.model.model_card.Considerations(*, users: collections.abc.Iterable[str] | None = None, use_cases: collections.abc.Iterable[str] | None = None, technical_limitations: collections.abc.Iterable[str] | None = None, performance_tradeoffs: collections.abc.Iterable[str] | None = None, ethical_considerations: collections.abc.Iterable[EthicalConsideration] | None = None, environmental_considerations: EnvironmentalConsiderations | None = None, fairness_assessments: collections.abc.Iterable[FairnessAssessment] | None = None)
considerations block within modelCard.
- property users: SortedSet[str]
Who are the intended users of the model?
- Returns:
Set of str
- property use_cases: SortedSet[str]
What are the intended use cases of the model?
- Returns:
Set of str
- property technical_limitations: SortedSet[str]
What are the known technical limitations of the model? E.g. What kind(s) of data should the model be expected not to perform well on? What are the factors that might degrade model performance?
- Returns:
Set of str
- property performance_tradeoffs: SortedSet[str]
What are the known tradeoffs in accuracy/performance of the model?
- Returns:
Set of str
- property ethical_considerations: SortedSet[EthicalConsideration]
What are the ethical risks involved in the application of this model?
- Returns:
Set of EthicalConsideration
- property environmental_considerations: EnvironmentalConsiderations | None
What are the various environmental impacts the corresponding machine learning model has exhibited across its lifecycle?
- Returns:
EnvironmentalConsiderations if set else None
- property fairness_assessments: SortedSet[FairnessAssessment]
How does the model affect groups at risk of being systematically disadvantaged? What are the harms and benefits to the various affected groups?
- Returns:
Set of FairnessAssessment
- class cyclonedx.model.model_card.ModelCard(*, bom_ref: str | cyclonedx.model.bom_ref.BomRef | None = None, model_parameters: ModelParameters | None = None, quantitative_analysis: QuantitativeAnalysis | None = None, considerations: Considerations | None = None, properties: collections.abc.Iterable[cyclonedx.model.Property] | None = None)
Internal representation of CycloneDX modelCardType.
Version gating: - Introduced in schema 1.5 - Unchanged structurally in 1.6 except for additional nested environmental considerations inside considerations - 1.7 retains 1.6 structure (additions in nested types only)
- property model_parameters: ModelParameters | None
Hyper-parameters for construction of the model.
- Returns:
ModelParameters if set else None
- property quantitative_analysis: QuantitativeAnalysis | None
A quantitative analysis of the model.
- Returns:
QuantitativeAnalysis if set else None
- property considerations: Considerations | None
What considerations should be taken into account regarding the model’s construction, training, and application?
- Returns:
Considerations if set else None
- property properties: SortedSet[Property]
Provides the ability to document properties in a name-value store.
- Returns:
Set of Property
- property bom_ref: cyclonedx.model.bom_ref.BomRef
An identifier which can be used to reference the model card elsewhere in the BOM. Every bom-ref must be unique within the BOM.
- Returns:
BomRef