..other code... preprocessing = ColumnTransformer(transformers = [('num_transform',numeric_transformer,numeric_features),('onehot transform',onehot_transformer,onehot_features),('target encoding',targetencoding_transformer,targetencoded_features)]) pipe = Pipeline(steps=[('preproc',preprocessing),('PCA',PCA(n_components=2)),('Decision Tree Classifier',DecisionTreeClassifier(ccp_alpha=0.05))]) X = data.drop(target_feature,axis=1) y=data[target_feature] pipe.fit_transform(X,y)
What I expected to happen:
I expected the pipe.fit_transform(X,y) code to execute successfully
What actually happened:
AttributeError: 'DecisionTreeClassifier' object has no attribute 'transform'
The way I understood was that the parts of the pipeline, which supports the “fit_transform” function, would execute and those bits where it is not applicable would be mute.
However, I got the above error on execution.
Could someone point me to my mistake? How do I get the pipeline to transform the data and then apply the classifier to the transformed data?