Skip to contents

Fit a ranger model to rank the predictors by impurity importance, then drop every row that falls outside the interquartile-range envelope of any of the most important numeric ones. The envelopes apply together: a row survives only when it is inside all of them.

Usage

removeOutliersIQR(.data, n = 3, q = 3)

Arguments

.data

Training data containing a numeric response column named y. The response name is the package's split contract: buildDataset() renames each response to y when it writes the training splits.

n

Number of top-ranked predictors to inspect. Non-numeric predictors among them are ignored; when none of the n is numeric the data is returned unchanged.

q

Multiplier of the interquartile range. The envelope of a column runs from its first quartile minus q times its interquartile range to its third quartile plus the same amount, so a larger q keeps more rows. At the default of 3 an approximately normal column loses no row.

Value

A data.table holding the surviving rows and every original column.

Missing values

The ranger fit runs through caret's formula interface, whose default na.action is na.fail, so a missing value anywhere in .data stops the call before any envelope is computed. Resolve missing values before calling. A missing value in a column being inspected would not by itself remove its row: this function removes outliers, not incomplete rows.

See also

detectOutliers(), which scores rows instead of removing them and is the routine buildDataset() applies when outlier removal is enabled.