XGBoost
XGBoost model implementations.
- class openadmet.models.architecture.xgboost.XGBClassifierModel(**extra_data: Any)[source]
Bases:
XGBoostModelBaseXGBoost classification model.
Common parameters for XGBoost models can be found at: https://xgboost.readthedocs.io/en/stable/python/python_api.html Common parameters that you might want to set include: - n_estimators: Number of trees in the ensemble - max_depth: Maximum depth of a tree - max_leaves: Maximum number of leaves in a tree - learning_rate: Step size shrinkage used in update to prevent overfitting - objective: Specify the learning task and corresponding objective function - booster: Specify which booster to use, options are gbtree, gblinear or dart - tree_method: Specify the tree construction algorithm used in XGBoost
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None
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.
- Args:
self: The BaseModel instance. context: The context.
- predict_proba(X: ndarray) ndarray[source]
Predict using the model, returning probabilities for each class.
- Parameters:
X (np.ndarray) – Data to predict on
- Returns:
Probabilities for each class from the model
- Return type:
np.ndarray
- class openadmet.models.architecture.xgboost.XGBRegressorModel(**extra_data: Any)[source]
Bases:
XGBoostModelBaseXGBoost regression model.
Common parameters for XGBoost models can be found at: https://xgboost.readthedocs.io/en/stable/python/python_api.html
Common parameters that you might want to set include: - n_estimators: Number of trees in the ensemble - max_depth: Maximum depth of a tree - max_leaves: Maximum number of leaves in a tree - learning_rate: Step size shrinkage used in update to prevent overfitting - objective: Specify the learning task and corresponding objective function - booster: Specify which booster to use, options are gbtree, gblinear or dart - tree_method: Specify the tree construction algorithm used in XGBoost
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class openadmet.models.architecture.xgboost.XGBoostModelBase(**extra_data: Any)[source]
Bases:
PickleableModelBaseBase class for XGBoost models.
- build()[source]
Prepare the model.
- model_config: ClassVar[ConfigDict] = {'extra': 'allow'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_post_init(context: Any, /) None
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.
- Args:
self: The BaseModel instance. context: The context.
- predict(X: ndarray, **kwargs) ndarray[source]
Predict using the model.
- Parameters:
X (np.ndarray) – Data to predict on
kwargs (Dict) – Keyword arguments for model
- Returns:
Predictions from the model
- Return type:
np.ndarray
- train(X: ndarray, y: ndarray)[source]
Train the model.
- Parameters:
X (np.ndarray) – Training data features
y (np.ndarray) – Training data labels