PearsonCorr¶
Online Pearson correlation.
Parameters¶
-
ddof
Default →
1
Delta Degrees of Freedom.
Attributes¶
-
var_x (stats.Var)
Running variance of
x
. -
var_y (stats.Var)
Running variance of
y
. -
cov_xy (stats.Cov)
Running covariance of
x
andy
.
Examples¶
from river import stats
x = [0, 0, 0, 1, 1, 1, 1]
y = [0, 1, 2, 3, 4, 5, 6]
pearson = stats.PearsonCorr()
for xi, yi in zip(x, y):
pearson.update(xi, yi)
print(pearson.get())
0
0
0
0.774596
0.866025
0.878310
0.866025
You can also do this in a rolling fashion:
from river import utils
x = [0, 0, 0, 1, 1, 1, 1]
y = [0, 1, 2, 3, 4, 5, 6]
pearson = utils.Rolling(stats.PearsonCorr(), window_size=4)
for xi, yi in zip(x, y):
pearson.update(xi, yi)
print(pearson.get())
0
0
0
0.7745966692414834
0.8944271909999159
0.7745966692414832
-4.712160915387242e-09
Methods¶
get
Return the current value of the statistic.
revert
update
Update the called instance.
Parameters
- x
- y