automl / amltk

A build-it-yourself AutoML Framework
https://automl.github.io/amltk/
BSD 3-Clause "New" or "Revised" License
68 stars 6 forks source link

feat(sklearn): CVEvaluator allows `configure` and `build` params #250

Closed eddiebergman closed 10 months ago

eddiebergman commented 10 months ago

Cleans up some TODO's and makes the CVEvaluator more flexible for experienced users. Docstrings provided.

pipeline = Component(
    RandomForestClassifier,
    config={
        # Allow it to be configured with n_jobs
        "n_jobs": request("n_jobs", default=None)
    },
    space={"n_estimators": (10, 100), "criterion": ["gini", "entropy"]},
)

evaluator = CVEvaluation(
    X,
    y,
    # Use the `configure` keyword in params to pass to the `n_jobs`
    # Anything in the pipeline requesting `n_jobs` will get the value
    params={"configure": {"n_jobs": 2}}
)
history = pipeline.optimize(...)

Same can be done to interact with build(), for example, to build with an ImblearnPipeline or use your own custom builder.

from imblearn.pipeline import Pipeline as ImbalancedPipeline
CVEvaluator(
    ...,
    params={
        "build": {
            "builder": "sklearn",
            "pipeline_type": ImbalancedPipeline
        }
    }
)

Same exmaples given in docstrings

eddiebergman commented 10 months ago

@LennartPurucker You don't have to review necessarily but I thought you might like to know about this feature whenever you might get to use this ;)