regressor_chain module¶
A model chaining regression models.
During the training stage, the first regression model learns the learning dataset, the second regression model learns the learning error of the first regression model, and the $i$-th regression model learns the learning error of its predecessor.
During the prediction stage, the different regression models are evaluated from a new input data and the sum of their output data is returned.
- class gemseo_mlearning.regression.regressor_chain.RegressorChain(data, transformer=None, input_names=None, output_names=None, **parameters)[source]
Bases:
MLRegressionAlgo
Chain regression.
- Parameters:
data (Dataset) – The learning dataset.
transformer (Mapping[str, TransformerType] | None) – The strategies to transform the variables. The values are instances of
Transformer
while the keys are the names of either the variables or the groups of variables, e.g."inputs"
or"outputs"
in the case of the regression algorithms. If a group is specified, theTransformer
will be applied to all the variables of this group. IfIDENTITY
, do not transform the variables.input_names (Iterable[str]) – The names of the input variables. If
None
, consider all the input variables of the learning dataset.output_names (Iterable[str]) – The names of the output variables. If
None
, consider all the output variables of the learning dataset.**parameters (Any) – The parameters of the machine learning algorithm.
- Raises:
ValueError – When both the variable and the group it belongs to have a transformer.
- add_algo(name, transformer=None, **parameters)[source]
Add a new regression algorithm in the chain.
- Parameters:
name (str) – The name of the regression algorithm.
transformer (Mapping[str, TransformerType] | None) – The strategies to transform the variables. The values are instances of
Transformer
while the keys are the names of either the variables or the groups of variables, e.g. “inputs” or “outputs” in the case of the regression algorithms. If a group is specified, theTransformer
will be applied to all the variables of this group. IfNone
, do not transform the variables.**parameters (Any) – The parameters of the regression algorithm
- Return type:
None
- SHORT_ALGO_NAME: ClassVar[str] = 'RegressorChain'
The short name of the machine learning algorithm, often an acronym.
Typically used for composite names, e.g.
f"{algo.SHORT_ALGO_NAME}_{dataset.name}"
orf"{algo.SHORT_ALGO_NAME}_{discipline.name}"
.
- algo: Any
The interfaced machine learning algorithm.
- learning_set: IODataset
The learning dataset.
- transformer: dict[str, Transformer]
The strategies to transform the variables, if any.
The values are instances of
Transformer
while the keys are the names of either the variables or the groups of variables, e.g. “inputs” or “outputs” in the case of the regression algorithms. If a group is specified, theTransformer
will be applied to all the variables of this group.