OneHotEncoder ValueError: Shape mismatch 질문 드립니다.
조회수 908회
import mglearn
import numpy as np
X, y = mglearn.datasets.make_wave(n_samples = 100)
bins = np.linspace(-3, 3, 11)
which_bin = np.digitize(X, bins = bins)
from sklearn.preprocessing import OneHotEncoder
encoder = OneHotEncoder(categories = "Auto", sparse = False)
encoder.fit(which_bin)
X_binned = encoder.transform(which_bin)
print(X_binned[:5])
데이터를 이산형화 하여 which_bin으로 선언하고
원핫인코더로 fit 하려고 하면 ValueError: Shape mismatch: if categories is an array, it has to be of shape (n_features,).
발생합니다.
에러 메시지를 보면 shape가 되어야 한다고 하는데 어떻게 처리해야 에러 없이 진행될 수 있을까요?
댓글 입력