title: SkLearn - Using RegressorChain with ColumnTransformer in Pipelines?
body: <p>I'm having problems using sklearn's <code>RegressorChain</code> (<a href="https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.RegressorChain.html" rel="nofollow noreferrer">https://scikit-learn.org/stable/modules/generated/sklearn.multioutput.RegressorChain.html</a>), and unfortunately there doesn't seem to be a lot of documentation/examples about this.</p>
  <p>The documentation states indirectly (through the <code>set_params</code> method) that it can be used with Pipelines. My pipeline has:</p>
  <pre class="lang-py prettyprint-override"><code>ct = ColumnTransformer(
      transformers=[
          ('scaler', MinMaxScaler(), numerical_columns),
          ('onehot', OneHotEncoder(), ['day_of_week']),
      ],
      remainder='passthrough'
  )
  
  cv = TimeSeriesSplit(n_splits = groups.nunique()) #groups by date
  
  pipeline = make_pipeline(ct, lgb.LGBMRegressor(random_state=42))
  
  target_transform_output = TransformedTargetRegressor(regressor=pipeline, transformer=PowerTransformer())
  </code></pre>
  <p>and then I do:</p>
  <pre class="lang-py prettyprint-override"><code>chain_regressor = RegressorChain(base_estimator=target_transform_output , order=[1,0,2])
  chain_regressor.fit(X, y)
  </code></pre>
  <p>In the above, both X and y are pandas Dataframes, and y has 3 target columns.</p>
  <p>When I run the code, I get a python stack trace caused by the <code>fit()</code> call, starting in <code>__init.py__</code> in <code>_get_column_indices(X, key)</code> when doing <code>all_columns = X.columns</code>. The error is:</p>
  <p><code>AttributeError: 'numpy.ndarray' object has no attribute 'columns'</code></p>
  <p>and further down at the end of the stack trace:</p>
  <p><code>ValueError: Specifying the columns using strings is only supported for pandas DataFrames</code></p>
  <p>I assume this is because the <code>ColumnTransformer</code> returns ndarrays, a well-known problem. Does this mean that the <code>RegressorChain</code> can't be used with the <code>ColumnTransformer</code>?</p>
  <p>After this, I removed the column transformer step from the pipeline and tried again, and without the <code>ColumnTransformer</code> everything works fine (even the <code>TransformedTargetRegressor</code>).</p>
  <p>Any help, ideas or workaround appreciated.</p>