cursus.steps.hyperparams.hyperparameters_xgboost

class XGBoostModelHyperparameters(*, full_field_list, cat_field_list, tab_field_list, id_name, label_name, multiclass_categories, categorical_features_to_encode=<factory>, model_class='xgboost', device=-1, header=0, lr=3e-05, batch_size=2, eval_batch_size_multiplier=2.0, max_epochs=3, metric_choices=['f1_score', 'auroc'], optimizer='SGD', class_weights=None, num_round, max_depth, min_child_weight=1.0, booster='gbtree', eta=0.3, gamma=0.0, max_delta_step=0.0, subsample=1.0, colsample_bytree=1.0, colsample_bylevel=1.0, colsample_bynode=1.0, lambda_xgb=1.0, alpha_xgb=0.0, tree_method='auto', sketch_eps=None, scale_pos_weight=1.0, num_parallel_tree=None, base_score=None, seed=None, early_stopping_rounds=None, **extra_data)[source]

Bases: ModelHyperparameters

Hyperparameters for the XGBoost model training, extending the base ModelHyperparameters.

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 attributes with properties)

num_round: int
max_depth: int
model_class: str
min_child_weight: float
booster: str
eta: float
gamma: float
max_delta_step: float
subsample: float
colsample_bytree: float
colsample_bylevel: float
colsample_bynode: float
lambda_xgb: float
alpha_xgb: float
tree_method: str
sketch_eps: float | None
scale_pos_weight: float
num_parallel_tree: int | None
base_score: float | None
seed: int | None
early_stopping_rounds: int | None
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].

property objective: str

Get objective derived from is_binary.

property eval_metric: List[str]

Get evaluation metrics derived from is_binary.

validate_xgboost_hyperparameters()[source]

Validate XGBoost-specific hyperparameters

get_public_init_fields()[source]

Override get_public_init_fields to include XGBoost-specific fields. Gets a dictionary of public fields suitable for initializing a child config.

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.

full_field_list: List[str]
cat_field_list: List[str]
tab_field_list: List[str]
id_name: str
label_name: str
multiclass_categories: List[int | str]
categorical_features_to_encode: List[str]
device: int
header: int
lr: float
batch_size: int
eval_batch_size_multiplier: float
max_epochs: int
metric_choices: List[str]
optimizer: str
class_weights: List[float] | None