Sklearn Compatibility#
psipose estimators follow sklearn conventions strictly.
Rules#
__init__only stores parameters (no validation, no object construction)Use
Noneas default for mutable objects (encoders, ansatze)Resolve defaults in
fit(), not__init__()Fitted attributes end with
_(e.g.,weights_,classes_)fit()returnsselfUse
sklearn.utils.validation.check_X_yfor 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 AngleEncoder()
# ...
return self