mojolearn.r_regression#
- mojolearn.r_regression(X, y, *, center=True, force_finite=True)[source]#
Compute the Pearson correlation of each feature with a continuous target.
Follows scikit-learn’s
r_regression. Computation is float32.- Parameters:
X (array-like of shape (n_samples, n_features)) – Feature matrix.
y (array-like of shape (n_samples,)) – Target values.
center (bool, default True) – Center
Xandybefore computing the correlation.force_finite (bool, default True) – A constant feature or target gives a correlation of 0; with False it gives NaN.
- Returns:
correlation (array of shape (n_features,)) – Pearson correlation of each feature with
y.
Examples
>>> import numpy as np, mojolearn >>> rng = np.random.default_rng(0) >>> X = rng.random((1000, 8), dtype=np.float32) >>> y = X[:, 0] + rng.random(1000).astype(np.float32) >>> r = mojolearn.r_regression(X, y)