Skip to content

SKLearn Model - Post transform ApplyBasePredictionPostTransform #782

@XavierGeerinck

Description

@XavierGeerinck

Hi All!

When trying to convert an SK model to ONNX I get the below. Any idea what I can do to still get it converted?

  File "/.pyenv/versions/3.11.8/lib/python3.11/site-packages/hummingbird/ml/operator_converters/_gbdt_commons.py", line 167, in convert_gbdt_common
    raise NotImplementedError("Post transform {} not implemeneted yet".format(extra_config[constants.POST_TRANSFORM]))
NotImplementedError: Post transform <hummingbird.ml.operator_converters._tree_commons.ApplyBasePredictionPostTransform object at 0x367896b10> not implemeneted yet

Printed the extra config generated just before the POST_TRANSFORM and got:

{
    'n_features': 42, 
    'test_input': (array([[0.96146009]]), array([[0.55694969]]), ..., array([[0.38754932]]), array([[0.35920703]])), 
    'container': True, 
    'n_threads': 16, 
    'n_inputs': 42, 
    'input_names': ['F0', 'F1', 'F2', ..., 'F41'], 
    'base_prediction': Parameter containing: tensor([0.5000])
}

This is how I call it:

dummy_input = pd.DataFrame([np.random.rand(42).tolist()], columns=column_names)

# Load the MultiOutputRegressor model
model = joblib.load("Model_One.pkl")

# Use hummingbird to convert the model to ONNX
# note: the XGBRegressor model requires us to provide dummy input
# see example: https://github.com/microsoft/hummingbird/blob/main/notebooks/XGB-example.ipynb
model_onnx = convert(
    model,
    "onnx",
    dummy_input,
)

# Save the model
model_onnx.save("model.onnx")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions