# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# resubPredict

Class: RegressionEnsemble

Predict response of ensemble by resubstitution

## Syntax

```Yfit = resubPredict(ens) Yfit = resubPredict(ens,Name,Value) ```

## Description

`Yfit = resubPredict(ens)` returns the response `ens` predicts for the data `ens.X`. `Yfit` is the predictions of `ens` on the data that `fitrensemble` used to create `ens`.

`Yfit = resubPredict(ens,Name,Value)` predicts responses with additional options specified by one or more `Name,Value` pair arguments.

## Input Arguments

 `ens` A regression ensemble created with `fitrensemble`.

### Name-Value Pair Arguments

Specify optional comma-separated pairs of `Name,Value` arguments. `Name` is the argument name and `Value` is the corresponding value. `Name` must appear inside single quotes (`' '`). You can specify several name and value pair arguments in any order as `Name1,Value1,...,NameN,ValueN`.

 `'learners'` Indices of weak learners in the ensemble ranging from `1` to `NumTrained`. `oobLoss` uses only these learners for calculating loss. Default: `1:NumTrained`

## Output Arguments

 `Yfit` A vector of predicted responses to the training data, with `ens``.X` elements.

## Examples

expand all

Find the resubstitution predictions of mileage from the `carsmall` data, and look at their mean-squared difference from the training data.

Load the` carsmall` data set and select horsepower and vehicle weight as predictors.

```load carsmall X = [Horsepower Weight];```

Train an ensemble of regression trees.

`ens = fitrensemble(X,MPG,'Method','LSBoost','Learners','Tree');`

Find the resubstitution predictions of `MPG`.

`Yfit = resubPredict(ens);`

Calculate the mean-squared difference of the resubstitution predictions from the training data.

`MSE = mean((Yfit - ens.Y).^2)`
```MSE = 0.5836 ```

Confirm that the result is the same as the result of `resubLoss.`

`resubLoss(ens)`
```ans = 0.5836 ```