cursus.steps.configs.config_model_calibration_step

Model Calibration Step Configuration with Self-Contained Derivation Logic

This module implements the configuration class for the ModelCalibration step using a self-contained design where derived fields are private with read-only properties. Fields are organized into three tiers: 1. Tier 1: Essential User Inputs - fields that users must explicitly provide 2. Tier 2: System Inputs with Defaults - fields with reasonable defaults that can be overridden 3. Tier 3: Derived Fields - fields calculated from other fields (private with properties)

class ModelCalibrationConfig(*, author, bucket, role, region, service_name, pipeline_version, model_class='xgboost', current_date=<factory>, framework_version='2.1.0', py_version='py310', source_dir=None, enable_caching=False, use_secure_pypi=False, max_runtime_seconds=172800, project_root_folder, processing_instance_count=1, processing_volume_size=500, processing_instance_type_large='ml.m5.4xlarge', processing_instance_type_small='ml.m5.2xlarge', use_large_processing_instance=False, skip_volume_kms=None, processing_source_dir='dockers/xgboost_atoz/scripts', processing_entry_point='model_calibration.py', processing_script_arguments=None, processing_framework_version='1.2-1', label_field, score_field=None, score_fields=None, task_label_names=None, calibration_method='gam', monotonic_constraint=True, gam_splines=10, error_threshold=0.05, is_binary=True, num_classes=2, score_field_prefix='prob_class_', calibration_sample_points=1000, multiclass_categories=<factory>, job_type='calibration', **extra_data)[source]

Bases: ProcessingStepConfigBase

Configuration for ModelCalibration step with self-contained derivation logic.

This class defines the configuration parameters for the ModelCalibration step, which calibrates model prediction scores to accurate probabilities. Calibration ensures that model scores reflect true probabilities, which is crucial for risk-based decision-making and threshold setting.

Fields are organized into three tiers: 1. Tier 1: Essential User Inputs - fields that users must explicitly provide 2. Tier 2: System Inputs with Defaults - fields with reasonable defaults that can be overridden 3. Tier 3: Derived Fields - fields calculated from other fields (private with properties)

label_field: str
score_field: str | None
score_fields: List[str] | None
task_label_names: List[str] | None
calibration_method: str
monotonic_constraint: bool
gam_splines: int
error_threshold: float
is_binary: bool
num_classes: int
score_field_prefix: str
calibration_sample_points: int
multiclass_categories: List[int | str]
job_type: str
processing_entry_point: str
processing_source_dir: str
model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'allow', 'protected_namespaces': (), 'validate_assignment': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

initialize_derived_fields()[source]

Initialize all derived fields once after validation.

validate_config()[source]

Validate configuration and ensure defaults are set.

Returns:

The validated configuration object

Return type:

Self

Raises:

ValueError – If any validation fails

classmethod from_hyperparameters(hyperparameters, region, pipeline_s3_loc, processing_instance_type='ml.m5.xlarge', processing_instance_count=1, processing_volume_size=30, max_runtime_seconds=3600, pipeline_name=None, calibration_method='gam', monotonic_constraint=True, gam_splines=10, error_threshold=0.05, processing_entry_point='model_calibration.py', processing_source_dir='dockers/xgboost_atoz/pipeline_scripts')[source]

Create a ModelCalibrationConfig from a ModelHyperparameters instance.

This factory method creates a calibration config using values from the provided hyperparameters, with options to override specific calibration parameters.

Parameters:
  • hyperparameters (ModelHyperparameters) – ModelHyperparameters instance with classification settings

  • region (str) – AWS region

  • pipeline_s3_loc (str) – S3 location for pipeline artifacts

  • processing_instance_type (str) – SageMaker instance type for processing

  • processing_instance_count (int) – Number of processing instances

  • processing_volume_size (int) – EBS volume size in GB

  • max_runtime_seconds (int) – Maximum runtime in seconds

  • pipeline_name (str | None) – Name of the pipeline (optional)

  • calibration_method (str) – Method to use for calibration (gam, isotonic, platt)

  • monotonic_constraint (bool) – Whether to enforce monotonicity in GAM

  • gam_splines (int) – Number of splines for GAM

  • error_threshold (float) – Acceptable calibration error threshold

  • processing_entry_point (str) – Script entry point filename

  • processing_source_dir (str) – Directory containing the processing script

Returns:

Configuration object with values from hyperparameters

Return type:

ModelCalibrationConfig

get_environment_variables()[source]

Get environment variables for the processing script.

Returns:

Dictionary of environment variables to be passed to the processing script.

Return type:

dict

get_public_init_fields()[source]

Override get_public_init_fields to include calibration-specific fields. Gets a dictionary of public fields suitable for initializing a child config. Includes both base fields (from parent) and calibration-specific fields.

Returns:

Dictionary of field names to values for child initialization

Return type:

Dict[str, Any]

get_job_arguments()[source]

CLI args — config is the single source (FZ 31e1d3h).

model_post_init(context, /)

This function is meant to behave like a BaseModel method to initialize private attributes.

It takes context as an argument since that’s what pydantic-core passes when calling it.

Parameters:
  • self (BaseModel) – The BaseModel instance.

  • context (Any) – The context.

processing_instance_count: int
processing_volume_size: int
processing_instance_type_large: str
processing_instance_type_small: str
use_large_processing_instance: bool
skip_volume_kms: bool | None
processing_script_arguments: List[str] | None
processing_framework_version: str
author: str
bucket: str
role: str
region: str
service_name: str
pipeline_version: str
model_class: str
current_date: str
framework_version: str
py_version: str
source_dir: str | None
enable_caching: bool
use_secure_pypi: bool
max_runtime_seconds: int
project_root_folder: str