Skip to content

Refactor public estimator constructors for sklearn <=1.2 clone compatibility #82

Description

@TheHiddenObserver

Context

PR #79's Gate B found that sklearn.base.clone() under scikit-learn 1.2.2 fails for 26 public estimators because constructors normalize or defensively copy public parameters. The same failures reproduce on base SHA a4879fb, so this is pre-existing compatibility debt rather than a PR #79 regression.

The current regression test is version-limited and marked strict=True XFAIL for scikit-learn <1.3.

Goal

Restore legacy sklearn clone compatibility without weakening validation or changing normalized runtime behavior.

Required design

  • preserve each public constructor argument exactly on the public attribute expected by get_params(deep=False);
  • place canonicalized/validated values in private attributes, for example solver plus _solver_normalized;
  • avoid str(), .lower(), bool(), int(), float(), list(), dict(), or np.asarray() replacement of public constructor attributes inside __init__;
  • ensure set_params() refreshes private normalized state;
  • retain __sklearn_clone__ for newer sklearn while also satisfying the legacy constructor identity check;
  • centralize choice normalization and alias handling in shared helpers.

Work plan

  1. Generate a structured mismatch report for all public estimators and parameters.
  2. Group failures by normalization/copy pattern.
  3. Refactor shared bases and validators first.
  4. Update estimator families in small batches.
  5. Test clone, nested clone, pipelines, grid search, mutable parameters, and absence of fitted state.

Compatibility matrix

  • scikit-learn 1.2.2;
  • scikit-learn 1.3.x;
  • latest supported scikit-learn.

Acceptance criteria

  • test_all_default_public_estimators_clone passes without XFAIL on all supported sklearn versions;
  • get_params/set_params semantics remain stable;
  • normalized estimator behavior and error validation remain unchanged;
  • complete CPU and physical-GPU suites pass.

Relationship

Follow-up to PR #79. This is non-blocking for the GPU correctness and finite-input paths validated there.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions