Skip to content

Commit 9e10ec0

Browse files
committed
COSMIT use norm function in feature selection
1 parent 551b6c2 commit 9e10ec0

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sklearn/feature_selection/univariate_selection.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from ..utils import (array2d, as_float_array,
2020
atleast2d_or_csr, check_arrays, safe_asarray, safe_sqr,
2121
safe_mask)
22-
from ..utils.extmath import safe_sparse_dot
22+
from ..utils.extmath import norm, safe_sparse_dot
2323
from ..externals import six
2424
from .base import SelectorMixin
2525

@@ -253,8 +253,9 @@ def f_regression(X, y, center=True):
253253

254254
# compute the correlation
255255
corr = safe_sparse_dot(y, X)
256+
# XXX could use corr /= row_norms(X.T) here, but the test doesn't pass
256257
corr /= np.asarray(np.sqrt(safe_sqr(X).sum(axis=0))).ravel()
257-
corr /= np.asarray(np.sqrt(safe_sqr(y).sum())).ravel()
258+
corr /= norm(y)
258259

259260
# convert to p-value
260261
dof = y.size - 2

0 commit comments

Comments
 (0)