smithery.ai

custom-sklearn-estimator

Build scikit-learn compatible custom estimators by following the official “rolling your own estimator” rules for __init__, fit/predict, validation, learned attributes, tags, and estimator checks; prerequisite for autogluon-sklearn-wrapper or any sklearn-facing wrappers.

First seen Apr 17, 2026

Installation

$ npx skills add https://smithery.ai

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from smithery.ai · top by installs.

npx skills add https://smithery.ai

Browse all from smithery.ai

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,557 B
  • docs SUMMARY.md 306 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 1 installs

SKILL.md

Custom scikit-learn Estimator

Purpose

Create scikit-learn compatible estimators that work with pipelines, model selection, and validation tooling. This skill codifies the required API patterns for init, fit, prediction/transform methods, learned attributes, and estimator checks.

Usage

  • “rolling your own estimator”
  • “custom scikit-learn estimator”
  • “build sklearn-compatible class”

Instructions

  1. Choose the estimator type and mixins

- Use ClassifierMixin, RegressorMixin, TransformerMixin, or ClusterMixin as needed, with BaseEstimator last in the inheritance list. - For meta-estimators, ensure sub-estimator params are exposed through getparams/setparams (handled by BaseEstimator).

  1. Implement a minimal init

- Keyword args with defaults; no validation or logic. - Assign each parameter to an attribute with the exact same name. - Avoid mutable defaults; do not set attributes with trailing _ here.

  1. Implement fit

- Signature: fit(self, X, y=None, **kwargs) and accept y=None even for unsupervised estimators. - Validate inputs using validatedata/checkarray; ensure X.shape[0] == y.shape[0] when supervised. - Set learned attributes with trailing (e.g., coef, classes). - Return self and overwrite learned attributes on every call unless warmstart=True.

  1. Implement prediction/transform methods

- Call checkisfitted and validate inputs with validatedata(..., reset=False). - Classifiers must use self.classes and return labels, not indices. - Transformers must preserve sample count and order.

  1. Handle randomness correctly

- Accept randomstate=None in init, store it unmodified. - In fit, use checkrandomstate and store RNG in randomstate_ if needed later.

  1. Optional: tags and set_output

- Implement __sklearn_tags__ if default tags are not appropriate. - For transformers, consider getfeaturenamesout and setoutput compatibility.

  1. Validate with estimator checks

- Run checkestimator or parametrizewith_checks when possible. - Use the response checklist in ./templates/estimator-checklist.md to confirm compliance.