Skip to content

Commit

Permalink
Update ComponentGraph to only apply samplers at fit-time, not during …
Browse files Browse the repository at this point in the history
…non-fit transformation/prediction.
  • Loading branch information
dsherry committed May 3, 2021
1 parent ce605c3 commit 4515fda
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions evalml/pipelines/component_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from networkx.algorithms.dag import topological_sort
from networkx.exception import NetworkXUnfeasible

from evalml.pipelines.components import ComponentBase, Estimator, Transformer
from evalml.pipelines.components import (
BaseSampler,
ComponentBase,
Estimator,
Transformer
)
from evalml.pipelines.components.utils import handle_component_class
from evalml.utils import (
_convert_woodwork_types_wrapper,
Expand Down Expand Up @@ -232,7 +237,10 @@ def _compute_features(self, component_list, X, y=None, fit=False):
self.input_feature_names.update({component_name: list(input_x.columns)})

if isinstance(component_instance, Transformer):
if fit:
if isinstance(component_instance, BaseSampler) and not fit:
# samplers are training-only components. don't apply them during non-fit evaluation.
output = input_x, input_y
elif fit:
output = component_instance.fit_transform(input_x, input_y)
else:
output = component_instance.transform(input_x, input_y)
Expand Down

0 comments on commit 4515fda

Please sign in to comment.