Giter Club home page Giter Club logo

Comments (3)

david-cortes avatar david-cortes commented on August 23, 2024

Thanks for the bug report. Yes, that small change would solve the issue.

from isotree.

zds0 avatar zds0 commented on August 23, 2024

This wasn't quite the complete solution. There's a related (and perhaps uncommon) scenario that encounters a similar bug.

When you import a saved model (extending on the example above)

iso_imp = IsolationForest.import_model('test_isolationforest', use_cpp=True)

and then re-export that same model object

iso_imp.export_model('test_isolationforest2', use_cpp=True)

the following error is thrown

TypeError                                 Traceback (most recent call last)
<ipython-input-14-a78373200393> in <module>
----> 1 iso_imp.export_model('test_isolationforest2', use_cpp=True)

isotree/__init__.py in export_model(self, file, use_cpp)
   2128         """
   2129         assert self.is_fitted_
-> 2130         metadata = self._export_metadata()
   2131         with open(file + ".metadata", "w") as of:
   2132             json.dump(metadata, of, indent=4)

isotree/__init__.py in _export_metadata(self)
   2363             "cat_levels" : [list(m) for m in self._cat_mapping],
   2364             "categ_cols" : [] if self.categ_cols is None else list(self.categ_cols),
-> 2365             "categ_max" : list(self._cat_max_lev)
   2366         }
   2367 

TypeError: 'NoneType' object is not iterable

I was able to resolve by replacing like 2365 with

"categ_max" : [] if self._cat_max_lev is None else list(self._cat_max_lev)

But again I'll leave it to you to decide if this is functionality you wish to support and to determine if this is the correct solution (I think there are a few different ways of handling).

Thanks for the great work on this research and this library!

from isotree.

david-cortes avatar david-cortes commented on August 23, 2024

Thanks again. That should solve it, but I've added a couple extra checks just in case.

from isotree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.