@@ -1694,7 +1694,7 @@ class OneHotEncoder(BaseEstimator, TransformerMixin):
1694
1694
1695
1695
Parameters
1696
1696
----------
1697
- values : 'auto', 'seen', int, list of ints, or list of lists of objects
1697
+ values : 'auto', int, list of ints, or list of lists of objects
1698
1698
- 'auto' : determine set of values from training data. See the
1699
1699
documentation of `handle_unknown` for which values are considered
1700
1700
acceptable.
@@ -1731,11 +1731,11 @@ class OneHotEncoder(BaseEstimator, TransformerMixin):
1731
1731
Attributes
1732
1732
----------
1733
1733
feature_index_range_ : array, shape [n_feature, 2]
1734
- `feature_index_range_[i]` specifies the range of column indices
1735
- occupied by the feature `i` in the one-hot encoded array.
1734
+ `` feature_index_range_[i]` ` specifies the range of column indices
1735
+ occupied by the input feature `i` in the one-hot encoded array.
1736
1736
1737
1737
one_hot_feature_index_ : array, shape [n_features_new]
1738
- `one_hot_feature_index_[i]` specifies which feature of the input
1738
+ `` one_hot_feature_index_[i]` ` specifies which feature of the input
1739
1739
is encoded by column `i` in the one-hot encoded array.
1740
1740
1741
1741
Examples
@@ -1820,7 +1820,7 @@ def fit(self, X, y=None):
1820
1820
le = self ._label_encoders [cat_index ]
1821
1821
end = start + len (le .classes_ )
1822
1822
self .feature_index_range_ [i ] = start , end
1823
- start += len ( le . classes_ )
1823
+ start = end
1824
1824
cat_index += 1
1825
1825
1826
1826
indices = np .arange (start , start + n_features - num_cat )
@@ -1844,7 +1844,8 @@ def fit(self, X, y=None):
1844
1844
def _fit (self , X ):
1845
1845
"Assumes `X` contains only catergorical features."
1846
1846
1847
- X = check_array (X , dtype = np .object )
1847
+ if not np .issubdtype (X .dtype .type , np .integer ):
1848
+ X = check_array (X , dtype = np .object )
1848
1849
n_samples , n_features = X .shape
1849
1850
1850
1851
self ._n_features = n_features
@@ -1854,7 +1855,7 @@ def _fit(self, X):
1854
1855
1855
1856
if self .n_values is not None :
1856
1857
warnings .warn ('The parameter `n_values` is deprecated, use the'
1857
- 'parameter `classes_ ` instead and specify the '
1858
+ 'parameter `values ` instead and specify the '
1858
1859
'expected values for each feature' )
1859
1860
1860
1861
if isinstance (self .n_values , numbers .Integral ):
0 commit comments