8000 API Freezing estimators · Issue #8370 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
API Freezing estimators #8370
Closed
Closed
@jnothman

Description

@jnothman

TODO: motivate freezing: pipeline components, calibration, transfer/semisupervised learning

This should probably be a SLEP, but I just want it saved somewhere.

Features required for estimator freezing:

  • clone must have is isinstance(obj, FrozenModel): return obj (or do so via class polymorphism / singledispatch)
  • FrozenModel delegates all attribute access (get, set, del) to its wrapped estimator (except where specified)
    • hence its estimator cannot be accessible at FrozenModel().estimator but at some more munged name.
  • FrozenModel has def fit(self, *args, **kwargs): return self
  • FrozenModel has def fit_transform(self, *args, **kwargs): return fit(self, *args, **kwargs).transform(self, args[0]) (and similar for fit_predict?)
  • isinstance(freeze(obj), type(obj)) == True and isinstance(freeze(obj), FrozenModel) == True
    • since this is determined from type(freeze(obj)) (excluding __instancecheck__, which seems irrelevant), this appears to be the hardest criterion to fulfill
    • seems to entail use of a mixin, class created in closure, setting __class__ (!), overloading of __reduce__, help! I think I've gone down the wrong path!!
  • must behave nicely with pickle and copy.[deep]copy
  • freeze(some_list) will freeze every element of the list

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0