The issue arises because sklearn.set_config(transform_output="pandas")
is thread-local and does not persist across different threads, such as those used by Flask
for handling requests. To fix this, explicitly set the configuration inside the request context by calling sklearn.set_config(transform_output="pandas")
at the start of the predict()
route. This ensures the pipeline uses the correct configuration for pandas output during the request handling process.