[debugging] Expected 2D array, got 1D array instead

Python/Scikit-Learn 2019. 11. 15. 16:01

sklearn을 사용하다 보면 제목과 같은 에러 메시지를 종종 볼 수 있다. 다행히 개발자분들 께서 친절히 에러 메시지에 해결책을 써두고는 한다: from sklearn.impute import SimpleImputer imp = SimpleImputer() imp.fit_transform([1,2,3]) ValueError: Expected 2D array, got 1D array instead: array=[1. 2. 3.]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. fit_transform..

Article Thumbnail