sklearn.feature_selection.r_regression(X, y, *, center=True, force_finite=True)
Compute Pearson’s r for each features and the target.
Pearson’s r is also known as the Pearson correlation coefficient.
Linear model for testing the individual effect of each of many regressors.
This is a scoring function to be used in a feature selection procedure, not
a free standing feature selection procedure.
The cross correlation between each regressor and the target is computed
as:
X : {array-like, sparse matrix} of shape (n_samples, n_features)
The data matrix.
y : array-like of shape (n_samples,)
The target vector.
center : bool, default=True
Whether or not to center the data matrix X and the target vector y.
By default, X and y will be centered.
force_finite : bool, default=True
Whether or not to force the Pearson’s R correlation to be finite.
In the particular case where some features in X or the target y
are constant, the Pearson’s R correlation is not defined. When
force_finite=False, a correlation of np.nan is returned to
acknowledge this case. When force_finite=True, this value will be
forced to a minimal correlation of 0.0.
Returns:
correlation_coefficient : ndarray of shape (n_features,)