Custom Pipelines in EvalMLΒΆ
EvalML pipelines consist of modular components combining any number of transformers and an estimator. This allows you to create pipelines that fit the needs of your data to achieve the best results. You can create your own pipeline like this:
[1]:
from evalml.pipelines import PipelineBase
from evalml.pipelines.components import StandardScaler, SimpleImputer
from evalml.pipelines.components.estimators import LogisticRegressionClassifier
# objectives can be either a str or the evalml objective object
objective = 'Precision_Macro'
# pipeline needs to be a subclass of `PipelineBase`
class CustomPipeline(PipelineBase):
# component_graph and problem_types are required class variables
# components can be passed in as objects or as component name strings
component_graph = ['Simple Imputer', StandardScaler(), 'Logistic Regression Classifier']
supported_problem_types = ['binary', 'multiclass']
# you can override component hyperparameter_ranges like so
# ranges must adhere to skopt tuner
custom_hyperparameters = {
"impute_strategy":["most_frequent"]
}
# a parameters dictionary is necessary to instantiate pipelines
parameters = {
'Simple Imputer':{
'impute_strategy':"most_frequent"
},
'Logistic Regression Classifier':{
'penalty':'l2',
'C':5,
}
}
pipeline = CustomPipeline(parameters={}, objective=objective, random_state=3)
[2]:
from evalml.demos import load_wine
X, y = load_wine()
pipeline.fit(X, y)
pipeline.score(X, y)
[2]:
(1.0, {})