rodrigo-arenas / Sklearn-genetic-opt

ML hyperparameters tuning and features selection, using evolutionary algorithms.
https://sklearn-genetic-opt.readthedocs.io
MIT License
286 stars 73 forks source link

Fix the pickle error when dumping an estimator #140

Closed imxtx closed 9 months ago

imxtx commented 10 months ago

This fix #83. When saving an estimator, the dump method will report an error due to module class members and lambda functions.

Solved two issues:

  1. Pickle does dot support dumping module objects. There is no need to put the creator as a class member of GASearchCV and GAFeatureSelectionCV.
  2. Lambda creates anonymous function objects that don't have names and can't be found by the pickle loader. See https://stackoverflow.com/a/72339613.
codecov[bot] commented 9 months ago

Codecov Report

Merging #140 (94d0435) into master (7e62418) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #140   +/-   ##
=======================================
  Coverage   98.42%   98.42%           
=======================================
  Files          25       25           
  Lines        1016     1016           
=======================================
  Hits         1000     1000           
  Misses         16       16           
Files Changed Coverage Δ
sklearn_genetic/genetic_search.py 98.60% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

imxtx commented 9 months ago

cool,I will update it later.

                Tianxin Xie

                                ***@***.***

---- Replied Message ----FromRodrigo @.>Date09/20/2023 00:41 @.> CcT.X. @.>@.>SubjectRe: [rodrigo-arenas/Sklearn-genetic-opt] Fix the pickle error when dumping an estimator (PR #140) @rodrigo-arenas requested changes on this pull request.

hI @imxtx It looks good, the only change I'd request is to rename the function from getter_fittness_values to ind_fitness_values, just to a keep track of the names from the DEAP package Thanks!

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: @.> [ { @.": "http://schema.org", @.": "EmailMessage", "potentialAction": { @.": "ViewAction", "target": "https://github.com/rodrigo-arenas/Sklearn-genetic-opt/pull/140#pullrequestreview-1633750849", "url": "https://github.com/rodrigo-arenas/Sklearn-genetic-opt/pull/140#pullrequestreview-1633750849", "name": "View Pull Request" }, "description": "View this Pull Request on GitHub", "publisher": { @.***": "Organization", "name": "GitHub", "url": "https://github.com" } } ]