Skip to content

StatisticRegressor

Dummy regressor that uses a univariate statistic to make predictions.

Parameters

Examples

from pprint import pprint
from river import dummy
from river import stats

sentences = [
    ('glad happy glad', 3),
    ('glad glad joyful', 3),
    ('glad pleasant', 2),
    ('miserable sad glad', -3)
]

model = dummy.StatisticRegressor(stats.Mean())

for sentence, score in sentences:
    model = model.learn_one(sentence, score)

new_sentence = 'glad sad miserable pleasant glad'
model.predict_one(new_sentence)
1.25

Methods

learn_one

Fits to a set of features x and a real-valued target y.

Parameters

  • x'dict'
  • y'base.typing.RegTarget'

Returns

Regressor: self

predict_one

Predict the output of features x.

Parameters

  • x'dict'

Returns

base.typing.RegTarget: The prediction.