question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ColumnTransformer breaks where X is a list

See original GitHub issue
>>> from sklearn.preprocessing import StandardScaler
>>> from sklearn.compose import ColumnTransformer
>>> ColumnTransformer([('foobar', StandardScaler(), [0, 1, 2])]).fit([[1, 2, 3]])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 398, in fit
    self.fit_transform(X, y=y)
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 422, in fit_transform
    self._validate_remainder(X)
  File "/Users/joel/repos/scikit-learn/sklearn/compose/_column_transformer.py", line 275, in _validate_remainder
    n_columns = X.shape[1]
AttributeError: 'list' object has no attribute 'shape'

The passed list should be interpreted as an array for the sake of extracting columns. Instead an error is raised.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jnothmancommented, Sep 19, 2018

Not supporting lists is very unconventional behaviour for scikit-learn…

0reactions
jorisvandenbosschecommented, Sep 24, 2018
Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError when using ColumnTransformer into a pipeline
ColumnTransformer returns numpy.array , so it can't have column attribute ... it would break the pipeline (someone correct me if I'm wrong).
Read more >
Lecture 6: sklearn ColumnTransformer and Text Features
pass a list of lists to OrdinalEncoder , where each inner list corresponds to manually created list of ordered categories for a corresponding...
Read more >
sklearn.compose.ColumnTransformer
Parameters: transformerslist of tuples. List of (name, transformer, columns) tuples specifying the transformer objects to be applied to subsets of the data.
Read more >
Column Transformer With Heterogeneous Data Sources ...
We combine them (with weights) using a ColumnTransformer and finally train a ... x, y=None): return self def transform(self, posts): return [{'length': ...
Read more >
'columntransformer' object has no attribute '_feature_names_in'
scikit-learn/scikit-learnColumnTransformer breaks where X is a list#12096. Created about 4 years ago. 5. py >>> from sklearn.preprocessing import ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found