@@ -421,14 +421,11 @@ def fit(self, X, y):
421
421
func (rfe , self .estimator , X , y , train , test , scorer )
422
422
for train , test in cv .split (X , y ))
423
423
424
- scores = np .sum (scores , axis = 0 )[::- 1 ]
425
- # The index in 'scores' when 'n_features' features are selected
426
- n_feature_index = np .ceil ((n_features - n_features_to_select ) /
427
- float (self .step ))
428
- n_features_to_select = max (n_features_to_select ,
429
- n_features - ((n_feature_index -
430
- np .argmax (scores )) *
431
- self .step ))
424
+ scores = np .sum (scores , axis = 0 )
425
+ n_features_to_select = max (
426
+ n_features - (np .argmax (scores ) * self .step ),
427
+ n_features_to_select )
428
+
432
429
# Re-execute an elimination with best_k over the whole set
433
430
rfe = RFE (estimator = self .estimator ,
434
431
n_features_to_select = n_features_to_select , step = self .step )
@@ -444,5 +441,5 @@ def fit(self, X, y):
444
441
445
442
# Fixing a normalization error, n is equal to get_n_splits(X, y) - 1
446
443
# here, the scores are normalized by get_n_splits(X, y)
447
- self .grid_scores_ = scores / cv .get_n_splits (X , y )
444
+ self .grid_scores_ = scores [:: - 1 ] / cv .get_n_splits (X , y )
448
445
return self
0 commit comments