# mlr_graphs_bagging

##### Create a bagging learner

Creates a `Graph`

that performs bagging for a supplied graph.
This is done as follows:

`Subsample`

the data in each step using`PipeOpSubsample`

, afterwards apply`graph`

.Replicate this step

`iterations`

times (in parallel)Average outputs of replicated

`graph`

s predictions using the`averager`

.

##### Usage

`pipeline_bagging(graph, iterations = 10, frac = 0.7, averager = NULL)`

##### Arguments

- graph
`PipeOp`

|`Graph`

A`PipeOpLearner`

or`Graph`

to create a robustifying pipeline for. Outputs from the replicated`graph`

s are connected with the`averager`

.- iterations
`integer(1)`

Number of bagging iterations. Defaults to 10.- frac
`numeric(1)`

Percentage of rows to keep during subsampling. See`PipeOpSubsample`

for more information. Defaults to 0.7.- averager
`PipeOp`

|`Graph`

A`PipeOp`

or`Graph`

that averages the predictions from the replicated and subsampled graph's. In the simplest case,`po("classifavg")`

and`po("regravg")`

can be used in order to perform simple averaging of classification and regression predictions respectively.`If`

NULL` (default), no averager is added to the end of the graph.

##### Value

##### Examples

```
# NOT RUN {
library(mlr3)
lrn_po = po("learner", lrn("regr.rpart"))
task = mlr_tasks$get("boston_housing")
gr = pipeline_bagging(lrn_po, 3, averager = po("regravg"))
resample(task, GraphLearner$new(gr), rsmp("holdout"))
# }
```

*Documentation reproduced from package mlr3pipelines, version 0.3.0, License: LGPL-3*