Skip to content

PearsonCorr

Online Pearson correlation.

Parameters

  • ddof

    Default1

    Delta Degrees of Freedom.

Attributes

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 and return the called instance.

Parameters

  • x
  • y