Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add function to get build param from XGB #190

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions h1st/model/ml/xgboost/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,47 @@ def __init__(
'debug': debug,
}

def __get_model_build_params(self, model: XGBRegressionModel) -> dict:
return {
'max_depth': model.max_depth,
'max_leaves': model.max_leaves,
'max_bin': model.max_bin,
'grow_policy': model.grow_policy,
'learning_rate': model.learning_rate,
'n_estimators': model.n_estimators,
'verbosity': model.verbosity,
'booster': model.booster,
'tree_method': model.tree_method,
'n_jobs': model.n_jobs,
'gamma': model.gamma,
'min_child_weight': model.min_child_weight,
'max_delta_step': model.max_delta_step,
'subsample': model.subsample,
'sampling_method': model.sampling_method,
'colsample_bytree': model.colsample_bytree,
'colsample_bylevel': model.colsample_bylevel,
'colsample_bynode': model.colsample_bynode,
'reg_alpha': model.reg_alpha,
'reg_lambda': model.reg_lambda,
'scale_pos_weight': model.scale_pos_weight,
'base_score': model.base_score,
'random_state': model.random_state,
'missing': model.missing,
'num_parallel_tree': model.num_parallel_tree,
'monotone_constraints': model.monotone_constraints,
'interaction_constraints': model.interaction_constraints,
'importance_type': model.importance_type,
'gpu_id': model.gpu_id,
'validate_parameters': model.validate_parameters,
'predictor': model.predictor,
'enable_categorical': model.enable_categorical,
'feature_types': model.feature_types,
'max_cat_to_onehot': model.max_cat_to_onehot,
'max_cat_threshold': model.max_cat_threshold,
'eval_metric': model.eval_metric,
'early_stopping_rounds': model.early_stopping_rounds
}

def train_base_model(self, input_data: dict) -> XGBRegressor:
"""
This function can be used to build and train XGBRegression model.
Expand Down Expand Up @@ -329,6 +370,7 @@ def train_base_model(self, input_data: dict) -> XGBRegressor:
}
)
self.stats['input_features'] = features
self.stats['build_params'] = self.__get_model_build_params(model)
return model

def prepare_data(self, prepared_data: dict):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "h1st"
version = "0.1.13"
version = "2.1.0"
description = "Human-First AI (H1st)"
authors = ["Aitomatic, Inc. <engineering@aitomatic.com>"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

[metadata]
name = h1st
version = 0.1.12
version = 2.1.0
Loading