shogun icon indicating copy to clipboard operation
shogun copied to clipboard

Pickle works with the old API not the new one

Open Khalifa1997 opened this issue 5 years ago • 8 comments

Whenever Pickle loads a saved Shogun model, it expects the model to be implemented using the old API this can be demonstrated here

I guess this is related to #4463

Khalifa1997 avatar Mar 31 '20 19:03 Khalifa1997

Could you post a minimal standalone python example on synthetic trivial data instead of the notebook? Thx

karlnapf avatar Mar 31 '20 20:03 karlnapf

@karlnapf I have updated the link, now it's a python file using Shogun's data however you're going to have to edit the path to point to your shogun dir

Khalifa1997 avatar Mar 31 '20 20:03 Khalifa1997

thanks. that does it. (BTW standalone means no loading of files, or adjustment of paths, but one can run this straight away, but nevermind this is sufficient.)

karlnapf avatar Apr 01 '20 09:04 karlnapf

Could you share Traceback if there is one please?

gf712 avatar Apr 01 '20 12:04 gf712

Could you share Traceback if there is one please?

@gf712 I have updated the gist

Khalifa1997 avatar Apr 01 '20 12:04 Khalifa1997

I think the offender is this hackery in swig/interfaces/SGBase.i

if isinstance(cls, str) and cls.startswith('shogun.'):
            if base is object:
                import shogun
                return eval(cls+'()')

Simple solution would be to replace it with the create method, but not sure that works with all cases of templated objects (although machines are rarely templated)

karlnapf avatar Apr 01 '20 12:04 karlnapf

Which templated objects are you referring to? The template type is hidden from interfaces no?

gf712 avatar Apr 01 '20 12:04 gf712

Nevermind for now, I thought this could become a problem, but not sure anymore now, as the serialization and the new api have changed the picture. I guess someone will see when trying to fix this

karlnapf avatar Apr 01 '20 13:04 karlnapf