Skip to content

Estimator conventions

torml edited this page Sep 24, 2026 · 1 revision

Estimator conventions

Followed from scikit-learn, per TORML_CODING_GUIDELINES.md:

  • Hyperparameters go in __init__ only and are stored unchanged on self.
  • fit returns self.
  • Learned attributes end with _ (coef_, classes_, n_features_in_).
  • Validate inputs through torml.utils (check_array, check_X_y).
  • get_params / set_params round-trip; clone rebuilds an unfitted copy.
  • Mixins provide score (ClassifierMixin → accuracy, RegressorMixin → R²), fit_transform (TransformerMixin), fit_predict (ClusterMixin).
  • Use vectorized PyTorch ops; no NumPy/SciPy/sklearn imports in library code.
  • torch.testing.assert_close for tensor comparisons in tests.

Clone this wiki locally