# `PassiveAggressiveRegressor`

### *class* capymoa.regressor.PassiveAggressiveRegressor[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/regressor/_passive_aggressive_regressor.py#L19)

Bases: [`SKRegressor`](capymoa.base.SKRegressor.md#capymoa.base.SKRegressor)

Streaming Passive Aggressive regressor

This wraps [sklearn.linear_model.SGDRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html) with a passive aggressive
learning rate schedule for ease of use in the streaming context. Some
options are missing because they are not relevant in the streaming context.

Reference:

[Online Passive-Aggressive Algorithms K. Crammer, O. Dekel, J. Keshat, S.
Shalev-Shwartz, Y. Singer - JMLR (2006)](http://jmlr.csail.mit.edu/papers/volume7/crammer06a/crammer06a.pdf)

Example Usage:

```pycon
>>> from capymoa.datasets import Fried
>>> from capymoa.regressor import PassiveAggressiveRegressor
>>> from capymoa.evaluation import prequential_evaluation
>>> stream = Fried()
>>> schema = stream.get_schema()
>>> learner = PassiveAggressiveRegressor(schema)
>>> results = prequential_evaluation(stream, learner, max_instances=1000)
>>> results["cumulative"].rmse()
3.700...
```

#### \_\_init_\_(schema: [Schema](capymoa.stream.Schema.md#capymoa.stream.Schema), max_step_size: [float](https://docs.python.org/3/builtins/functions.html#float) = 1.0, fit_intercept: [bool](https://docs.python.org/3/builtins/functions.html#bool) = True, loss: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['epsilon_insensitive', 'squared_epsilon_insensitive'] = 'epsilon_insensitive', average: [bool](https://docs.python.org/3/builtins/functions.html#bool) = False, random_seed=1)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/regressor/_passive_aggressive_regressor.py#L48)

Construct a passive aggressive regressor.

* **Parameters:**
  * **schema** – Stream schema
  * **max_step_size** – Maximum step size (regularization).
  * **fit_intercept** – Whether the intercept should be estimated or not.
    If False, the data is assumed to be already centered.
  * **loss** – 

    The loss function to be used:
    * `"epsilon_insensitive"`: equivalent to PA-I in the reference paper.
    * `"squared_epsilon_insensitive"`: equivalent to PA-II in the reference
      paper.
  * **average** – When set to True, computes the averaged SGD weights and
    stores the result in the `sklearner.coef_` attribute. If set to an int greater
    than 1, averaging will begin once the total number of samples
    seen reaches average. So `average=10` will begin averaging after
    seeing 10 samples.
  * **random_seed** – Seed for the random number generator.
* **Raises:**
  [**ValueError**](https://docs.python.org/3/builtins/exceptions.html#ValueError) – If `loss` is not one of the supported losses.

#### *classmethod* from_params(schema: [Any](https://docs.python.org/3/library/typing.html#typing.Any) = None, params: [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, random_seed: [int](https://docs.python.org/3/builtins/functions.html#int) = 1) → [Any](https://docs.python.org/3/library/typing.html#typing.Any)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L170)

Construct an instance from parameters produced by `get_params`.

#### get_params() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)][[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_learner_params.py#L163)

Return the hyper-parameters captured from the constructor.

#### predict(instance: [Instance](capymoa.core.Instance.md#capymoa.core.Instance)) → [float](https://docs.python.org/3/builtins/functions.html#float)[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_regressor.py#L148)

#### train(instance: [RegressionInstance](capymoa.core.RegressionInstance.md#capymoa.core.RegressionInstance))[[source]](https://github.com/adaptive-machine-learning/CapyMOA/blob/3e255b1/src/capymoa/base/_regressor.py#L141)

#### sklearner *: [SGDRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html#sklearn.linear_model.SGDRegressor)*

The underlying scikit-learn object. See: [sklearn.linear_model.SGDRegressor](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.SGDRegressor.html)
