I'm trying to make a pipeline that handles numeric, categorical, and text variables. I want the data to be outputted to a new dataframe before I run the classifier. I'm getting the following error
ValueError: all the input array dimensions for the concatenation axis must match exactly, but along dimension 0, the array at index 0 has size 2499 and the array at index 2 has size 1.
Note that 2499 is the size of my training data. If I remove the text_preprocessing part of the pipeline my code works. Any ideas how I can get this to work? Thanks!
# Categorical pipeline
categorical_preprocessing = Pipeline(
[
('Imputation', SimpleImputer(strategy='constant', fill_value='?')),
('One Hot Encoding', OneHotEncoder(handle_unknown='ignore')),
]
)
# Numeric pipeline
numeric_preprocessing = Pipeline(
[
('Imputation', SimpleImputer(strategy='mean')),
('Scaling', StandardScaler())
]
)
text_preprocessing = Pipeline(
[
('Text',TfidfVectorizer())
]
)
# Creating preprocessing pipeline
preprocessing = make_column_transformer(
(numeric_features, numeric_preprocessing),
(categorical_features, categorical_preprocessing),
(text_features,text_preprocessing),
)
# Final pipeline
pipeline = Pipeline(
[('Preprocessing', preprocessing)]
)
test = pipeline.fit_transform(x_train)