Skip to content

Commit 68f8878

Browse files
author
Boyan Hristov
committed
#104 - added an empty pipe at the end of the transformation pipeline to prevent weird handling of last transformation pipe, which is usually expected to be an estimator
1 parent 942d045 commit 68f8878

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

modAL/models/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,10 @@ def transform_without_estimating(self, X: modALinput) -> Union[np.ndarray, sp.cs
132132
if isinstance(pipe, Pipeline):
133133
# NOTE: The used pipeline class might be an extension to sklearn's!
134134
# Create a new instance of the used pipeline class with all
135-
# components but the final estimator.
136-
transformation_pipe = pipe.__class__(steps=pipe.steps[:-1])
135+
# components but the final estimator, which is replaced by an empty (passthrough) component.
136+
# This prevents any special handling of the final transformation pipe, which is usually
137+
# expected to be an estimator.
138+
transformation_pipe = pipe.__class__(steps=[*pipe.steps[:-1], ('passthrough', 'passthrough')])
137139
Xt.append(transformation_pipe.transform(X))
138140

139141
# in case no transformation pipelines are used by the estimator,

0 commit comments

Comments
 (0)