multioutput
MultiTargetRegressor(module, loss_fn='mse', optimizer_fn='sgd', lr=0.001, device='cpu', seed=42, **kwargs)
¶
Bases: MultiTargetRegressor
, DeepEstimator
A Regressor that supports multiple targets.
PARAMETER | DESCRIPTION |
---|---|
module |
Torch Module that builds the autoencoder to be wrapped.
The Module should accept parameter
TYPE:
|
loss_fn |
Loss function to be used for training the wrapped model.
Can be a loss function provided by
TYPE:
|
optimizer_fn |
Optimizer to be used for training the wrapped model.
Can be an optimizer class provided by
TYPE:
|
lr |
Learning rate of the optimizer.
TYPE:
|
device |
Device to run the wrapped model on. Can be "cpu" or "gpu".
TYPE:
|
seed |
Random seed for the wrapped model.
TYPE:
|
**kwargs |
Parameters to be passed to the
DEFAULT:
|
Examples:
>>> from river import evaluate, compose
>>> from river import metrics
>>> from river import preprocessing
>>> from river import stream
>>> from sklearn import datasets
>>> from torch import nn
>>> from deep_river.regression.multioutput import MultiTargetRegressor
>>> class MyModule(nn.Module):
... def __init__(self, n_features):
... super(MyModule, self).__init__()
... self.dense0 = nn.Linear(n_features,3)
...
... def forward(self, X, **kwargs):
... X = self.dense0(X)
... return X
>>> dataset = stream.iter_sklearn_dataset(
... dataset=datasets.load_linnerud(),
... shuffle=True,
... seed=42
... )
>>> model = compose.Pipeline(
... preprocessing.StandardScaler(),
... MultiTargetRegressor(
... module=MyModule,
... loss_fn='mse',
... lr=0.3,
... optimizer_fn='sgd',
... ))
>>> metric = metrics.multioutput.MicroAverage(metrics.MAE())
>>> ev = evaluate.progressive_val_score(dataset, model, metric)
>>> print(f"MicroAverage(MAE): {metric.get():.2f}")
MicroAverage(MAE): 34.31
predict_one(x)
¶
Predicts the target value for a single example.
PARAMETER | DESCRIPTION |
---|---|
x |
Input example.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RegTarget
|
Predicted target value. |