0
Python 2.7 (miniconda interpreter)에서 사용. 약 OneHotEncoder
에 대한 예를 아래에 혼동하면 enc.n_values_
출력이 [2, 3, 4]
인 이유가 무엇입니까? 누구든지 명확히하는 데 도움이 될 수 있다면 좋을 것입니다.Scickit에서 OneHotEncoder 혼란 학습
http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.OneHotEncoder.html
>>> from sklearn.preprocessing import OneHotEncoder
>>> enc = OneHotEncoder()
>>> enc.fit([[0, 0, 3], [1, 1, 0], [0, 2, 1], [1, 0, 2]])
OneHotEncoder(categorical_features='all', dtype=<... 'float'>,
handle_unknown='error', n_values='auto', sparse=True)
>>> enc.n_values_
array([2, 3, 4])
>>> enc.feature_indices_
array([0, 2, 5, 9])
>>> enc.transform([[0, 1, 1]]).toarray()
array([[ 1., 0., 0., 1., 0., 0., 1., 0., 0.]])
관련, 린
yangjie에게 감사드립니다. 그래서 3 개의 샘플은'[0, 1, 0, 1]','[0,1,2,0]'그리고'[3, 0, 1, 2]'입니까? –
또한'[n_samples, n_feature]'에 대해 혼란 스럽습니다.'n_samples' 행과'n_feature' 열이라고 생각했지만, 그렇지 않은 것 같습니다. 선명도가 좋다면 좋을 것입니다. :) –
'n_samples' 행과'n_feature' 열입니다. X에는 4 개의 샘플이 있으며, 각 샘플에는 3 개의 특징이 있습니다. – yangjie