aimclub/BAMT

Predict after saving the model

Yakonick opened this issue · 1 comments

There is a problem with save() method. After method call, regressors in distributions field changes to their pickle serialization.

bn = ContinuousBN(use_mixture=False, has_logit=False)
bn.add_nodes(DESCRIPTOR)
bn.add_edges(DISCRETIZED_DATA)
bn.fit_parameters(DATA)

bn.save(BN_NAME, MODELS_DIR)

bn.predict(TEST_DATA)

After calling predict() method we've got an error:

...
        if pvals is not None:
            for el in pvals:
                if str(el) == "nan":
                    return np.nan
            model = node_info["regressor_obj"]
>           pred = model.predict(pvals)
E           AttributeError: 'str' object has no attribute 'predict'

Because now instead of CatBoostRegressor object (for example) in node_info["regressor_obj"] we have something like this: "\x80\x04\x95w\x00\x00\x00\x00\x00\x00\x00\x8c\rcatbo..."

Well, truly, deepcopy must be implemented instead of shallow copy..