def f_regression(X, y, center=True):
    if issparse(X) and center:
        raise ValueError("center=True only allowed for dense data")
    X, y = check_X_y(X, y, ['csr', 'csc', 'coo'], dtype=np.float64)
    if center:
        y = y - np.mean(y)
        X = X.copy('F')  # faster in fortran
        X -= X.mean(axis=0)

    # compute the correlation
    corr = safe_sparse_dot(y, X)
    corr /= row_norms(X.T)
    corr /= norm(y)

    # convert to p-value
    degrees_of_freedom = y.size - (2 if center else 1)
    F = corr ** 2 / (1 - corr ** 2) * degrees_of_freedom
    pv = stats.f.sf(F, 1, degrees_of_freedom)
    return F, pv


######################################################################
# Base classes
Univariate linear regression tests.
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/feature_selection/univariate_selection.py/f_regression