Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
tgsmith61591 committed Oct 17, 2016
1 parent 845e2f7 commit 651b271
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions skutil/h2o/one_way_fs.py
Expand Up @@ -332,7 +332,7 @@ def _test_and_score(frame, fun, cv, feature_names, target_feature, iid, select_f


# return tuple
return all_scores, all_pvalues, select_fun(all_scores, all_pvalues)
return all_scores, all_pvalues, select_fun(all_scores, all_pvalues, fn)


class _BaseH2OFScoreSelector(six.with_metaclass(ABCMeta,
Expand Down Expand Up @@ -393,7 +393,7 @@ def __init__(self, feature_names=None, target_feature=None,
max_version=self._max_version)

@abstractmethod
def _select_features(self, all_scores, all_pvalues):
def _select_features(self, all_scores, all_pvalues, feature_names):
"""This function should be overridden by subclasses, and
should handle the selection of features given the scores
and pvalues.
Expand All @@ -407,6 +407,9 @@ def _select_features(self, all_scores, all_pvalues):
all_pvalues : np.ndarray, float
The p-values
feature_names : array_like (str)
The list of names that are eligible for drop
Returns
-------
Expand Down Expand Up @@ -522,7 +525,7 @@ def fit(self, X):
return self._fit(X)

@overrides(_BaseH2OFScoreSelector)
def _select_features(self, all_scores, all_pvalues):
def _select_features(self, all_scores, all_pvalues, feature_names):
"""This function selects the top ``percentile`` of
features from the F-scores.
Expand All @@ -535,6 +538,9 @@ def _select_features(self, all_scores, all_pvalues):
all_pvalues : np.ndarray, float
The p-values
feature_names : array_like (str)
The list of names that are eligible for drop
Returns
-------
Expand Down Expand Up @@ -643,7 +649,7 @@ def fit(self, X):
return self._fit(X)

@overrides(_BaseH2OFScoreSelector)
def _select_features(self, all_scores, all_pvalues):
def _select_features(self, all_scores, all_pvalues, feature_names):
"""This function selects the top ``k`` features
from the F-scores.
Expand All @@ -656,6 +662,9 @@ def _select_features(self, all_scores, all_pvalues):
all_pvalues : np.ndarray, float
The p-values
feature_names : array_like (str)
The list of names that are eligible for drop
Returns
-------
Expand All @@ -670,7 +679,7 @@ def _select_features(self, all_scores, all_pvalues):
# adapted from sklearn.feature_selection.SelectKBest
all_scores = _clean_nans(all_scores)
mask = np.zeros(all_scores.shape, dtype=bool)
mask[np.argsort(scores, kind="mergesort")[-self.k:]] = 1
mask[np.argsort(all_scores, kind="mergesort")[-k:]] = 1 # we know k > 0

# inverse, since we're recording which features to DROP, not keep
mask = (~mask).tolist()
Expand Down

0 comments on commit 651b271

Please sign in to comment.