regression

Module Contents

Classes

XGBRegressionModel

Base class for H1st Model.

XGBRegressionModeler

class regression.XGBRegressionModel(result_key: str = 'result', max_features: int = 50, eta: float = 0.001, n_estimators: int = 5, max_depth: int = 3, debug: bool = False)

Bases: h1st.model.model.Model

Base class for H1st Model.

To create your own model, inherit Model class and implement process accordingly. Please refer to Tutorial for more details how to create a model.

The framework allows you to persist and load model to the model repository. To persist the model, you can call persist(), and then load_params to retrieve the model. See persist() and load_params() document for more detail.

Model Persistence and Loading Example
import h1st

class MyModeler(h1st.model.Modeler):
    def build_model(self):
        ...

class MyModel(h1st.model.Model):



my_modeler = MyModeler()
my_modeler.model_class = MyModel

my_model = my_modeler.build_model()

# Persist the model to repo
my_model.persist('1st_version')

# Load the model from the repo
my_model_2 = MyModel()
my_model_2.load_params('1st_version')
input_key = X
output_key = predictions
name = XGBRegression
predict(self, input_data: dict) dict
prepare_data(self, prepared_data: dict)
train_model(self, input_data: dict)

This function can be used to build and train XGBRegression model. It also performs gridsearch which helps us to get optimal model parameters based on Mean Absolute Error.

prepared_data requires keys: X_train, y_train, X_test, y_test

evaluate_model(self, input_data, trained_model)

Calculate metrics

train(self, data: Dict[str, Any] = None) h1st.model.model.Model

Implement logic to create the corresponding MLModel, including both training and evaluation.

class regression.XGBRegressionModeler(result_key: str = 'result', max_features: int = 50, eta: float = 0.001, n_estimators: int = 5, max_depth: int = 3, debug: bool = False)
model_class
__get_model_build_params(self, model: XGBRegressionModel) dict
train_base_model(self, input_data: dict) xgboost.XGBRegressor

This function can be used to build and train XGBRegression model. It also performs gridsearch which helps us to get optimal model parameters based on Mean Absolute Error.

prepared_data requires keys: X_train, y_train, X_test, y_test

prepare_data(self, prepared_data: dict)
evaluate_model(self, input_data, trained_model)

Calculate metrics

train_model(self, data: Dict[str, Any] = None)

Implement logic to create the corresponding MLModel, including both training and evaluation.

build_model(self, data: Dict[str, Any] = None)