@@ -304,8 +304,8 @@ def n_values_(self):
304304 return self ._n_values_
305305
306306 def _handle_deprecations (self , X ):
307-
308307 # internal version of the attributes to handle deprecations
308+ self ._n_values = self .n_values
309309 self ._categories = getattr (self , '_categories' , None )
310310 self ._categorical_features = getattr (self , '_categorical_features' ,
311311 None )
@@ -362,7 +362,7 @@ def _handle_deprecations(self, X):
362362 )
363363 warnings .warn (msg , FutureWarning )
364364 self ._legacy_mode = True
365- self .n_values = 'auto'
365+ self ._n_values = 'auto'
366366
367367 # if user specified categorical_features -> always use legacy mode
368368 if self .categorical_features is not None :
@@ -427,18 +427,18 @@ def _legacy_fit_transform(self, X):
427427 "be able to use arbitrary integer values as "
428428 "category identifiers." )
429429 n_samples , n_features = X .shape
430- if (isinstance (self .n_values , six .string_types ) and
431- self .n_values == 'auto' ):
430+ if (isinstance (self ._n_values , six .string_types ) and
431+ self ._n_values == 'auto' ):
432432 n_values = np .max (X , axis = 0 ) + 1
433- elif isinstance (self .n_values , numbers .Integral ):
434- if (np .max (X , axis = 0 ) >= self .n_values ).any ():
433+ elif isinstance (self ._n_values , numbers .Integral ):
434+ if (np .max (X , axis = 0 ) >= self ._n_values ).any ():
435435 raise ValueError ("Feature out of bounds for n_values=%d"
436- % self .n_values )
436+ % self ._n_values )
437437 n_values = np .empty (n_features , dtype = np .int )
438- n_values .fill (self .n_values )
438+ n_values .fill (self ._n_values )
439439 else :
440440 try :
441- n_values = np .asarray (self .n_values , dtype = int )
441+ n_values = np .asarray (self ._n_values , dtype = int )
442442 except (ValueError , TypeError ):
443443 raise TypeError ("Wrong type for parameter `n_values`. Expected"
444444 " 'auto', int or array of ints, got %r"
@@ -462,8 +462,8 @@ def _legacy_fit_transform(self, X):
462462 shape = (n_samples , indices [- 1 ]),
463463 dtype = self .dtype ).tocsr ()
464464
465- if (isinstance (self .n_values , six .string_types ) and
466- self .n_values == 'auto' ):
465+ if (isinstance (self ._n_values , six .string_types ) and
466+ self ._n_values == 'auto' ):
467467 mask = np .array (out .sum (axis = 0 )).ravel () != 0
468468 active_features = np .where (mask )[0 ]
469469 out = out [:, active_features ]
@@ -542,8 +542,8 @@ def _legacy_transform(self, X):
542542 out = sparse .coo_matrix ((data , (row_indices , column_indices )),
543543 shape = (n_samples , indices [- 1 ]),
544544 dtype = self .dtype ).tocsr ()
545- if (isinstance (self .n_values , six .string_types ) and
546- self .n_values == 'auto' ):
545+ if (isinstance (self ._n_values , six .string_types ) and
546+ self ._n_values == 'auto' ):
547547 out = out [:, self ._active_features_ ]
548548
549549 return out if self .sparse else out .toarray ()
0 commit comments