From 57e06b28abc554d2b9d03e76b9809e313ca3eb52 Mon Sep 17 00:00:00 2001 From: Aditya Srivastava <39651310+ADI10HERO@users.noreply.github.com> Date: Wed, 8 May 2019 17:35:10 +0530 Subject: [PATCH] Fixed boruta_py error when all features get selected When all features get selected boruta gives iterating over a 0-d array error --- boruta/boruta_py.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/boruta/boruta_py.py b/boruta/boruta_py.py index b84997c..ba7ab71 100644 --- a/boruta/boruta_py.py +++ b/boruta/boruta_py.py @@ -331,7 +331,13 @@ def _fit(self, X, y): not_selected = np.setdiff1d(np.arange(n_feat), selected) # large importance values should rank higher = lower ranks -> *(-1) imp_history_rejected = imp_history[1:, not_selected] * -1 + # if no features are rejected , returning importance_ + if(0 in imp_history_rejected.shape): + if self.verbose > 0: + self._print_results(dec_reg, _iter, 1) + self.importance_ = imp_history[1:] + return self # update rank for not_selected features if not_selected.shape[0] > 0: # calculate ranks in each iteration, then median of ranks across feats