Loading...

vastorbit.machine_learning.memmodel.ensemble.GradientBoostingClassifier.predict_proba_sql

GradientBoostingClassifier.predict_proba_sql(X: Annotated[list | ndarray, 'Array Like Structure']) list[str]

Returns the SQL code needed to deploy the model using its attributes.

Parameters:

X (list | numpy.array) – The names or values of the input predictors.

Returns:

SQL code.

Return type:

str

Examples

Import the required modules and create many BinaryTreeClassifier.

from vastorbit.machine_learning.memmodel.tree import BinaryTreeClassifier

model1 = BinaryTreeClassifier(
    children_left = [1, 3, None, None, None],
    children_right = [2, 4, None, None, None],
    feature = [0, 1, None, None, None],
    threshold = ["female", 30, None, None, None],
    value = [
        None,
        None,
        [0.8, 0.1, 0.1],
        [0.1, 0.8, 0.1],
        [0.2, 0.2, 0.6],
    ],
    classes = ["a", "b", "c"]
)
model2 = BinaryTreeClassifier(
    children_left = [1, 3, None, None, None],
    children_right = [2, 4, None, None, None],
    feature = [0, 1, None, None, None],
    threshold = ["female", 30, None, None, None],
    value = [
        None,
        None,
        [0.7, 0.2, 0.1],
        [0.3, 0.5, 0.2],
        [0.2, 0.2, 0.6],
    ],
    classes = ["a", "b", "c"],
)
model3 = BinaryTreeClassifier(
    children_left = [1, 3, None, None, None],
    children_right = [2, 4, None, None, None],
    feature = [0, 1, None, None, None],
    threshold = ["female", 30, None, None, None],
    value = [
        None,
        None,
        [0.4, 0.4, 0.2],
        [0.2, 0.2, 0.6],
        [0.2, 0.5, 0.3],
    ],
    classes = ["a", "b", "c"],
)

Let’s create a model.

from vastorbit.machine_learning.memmodel.ensemble import GradientBoostingClassifier

model_gbc = GradientBoostingClassifier(
    trees = [model1, model2, model3],
    classes = ["a", "b", "c"],
    logodds = [0.1, 0.12, 0.15],
    learning_rate = 0.1,
)

Let’s use the following column names:

cnames = ["sex", "fare"]

Get the SQL code needed to deploy the model.

model_gbc.predict_proba_sql(cnames)

Note

Refer to GradientBoostingClassifier for more information about the different methods and usages.