causalml icon indicating copy to clipboard operation
causalml copied to clipboard

How can I save a "UpliftTreeClassifier" model?

Open helenykwang opened this issue 3 years ago • 5 comments

I want to save models and reuse them in other scenes. However, when I execute "pickle.dump(model, file) ", it reports an error :

PicklingError: Can't pickle <cyfunction UpliftTreeClassifier.evaluate_KL at 0x00000210E9C5E818>: attribute lookup evaluate_KL on causalml.inference.tree.uplift failed

How can I save a "UpliftTreeClassifier" model? Thank u very much.

helenykwang avatar May 17 '22 02:05 helenykwang

I found a example notebook: https://colab.research.google.com/drive/1ud45oYCLFo6mWLDnK_uKpdQ9M7Oy5b7i?usp=sharing but it doesn't work

my version: 0.12.1

helenykwang avatar May 17 '22 02:05 helenykwang

It works for me, @helenykwang do you mind providing the errors you run into? Screen Shot 2022-05-20 at 10 17 58 PM

paullo0106 avatar May 21 '22 05:05 paullo0106

It works for me, @helenykwang do you mind providing the errors you run into? Screen Shot 2022-05-20 at 10 17 58 PM

Thanks for your reply, it can be saved normally on colab, but it fails to save on the local environment. Same version, same code. @paullo0106 image

helenykwang avatar May 24 '22 03:05 helenykwang

env: win10,python3.6.5

it works ,using causalml <= 0.11.1 ,not work when causalml >= 0.12.0

I think there is some problem with cpython file @jeongyoonlee @paullo0106 : image

helenykwang avatar Jun 08 '22 09:06 helenykwang

Hi @helenykwang, it sounds like the issue related to Cython on Windows. Which version of Cython do you have? Could you update Cython to the latest version and try again? I don't have a windows system to reproduce the issue on my end.

jeongyoonlee avatar Jun 14 '22 08:06 jeongyoonlee