Sklearn Compatibility#

psipose estimators follow sklearn conventions strictly.

Rules#

  1. __init__ only stores parameters (no validation, no object construction)

  2. Use None as default for mutable objects (encoders, ansatze)

  3. Resolve defaults in fit(), not __init__()

  4. Fitted attributes end with _ (e.g., weights_, classes_)

  5. fit() returns self

  6. Use sklearn.utils.validation.check_X_y for input validation

Example#

def __init__(self, encoder=None, ansatz=None):
    self.encoder = encoder  # Store None, resolve in fit()
    self.ansatz = ansatz

def fit(self, X, y):
    encoder = self.encoder if self.encoder is not None else AngleFeatureMap()
    # ...
    return self