FUNCTION REFERENCE

prune

Return a regression tree with selected branches collapsed to their node means.

Return a regression tree with selected branches collapsed to their node means.

Syntax

p = prune(tree); p = prune(tree,'Level',k); p = prune(tree,'Nodes',indices)

Level=0 preserves the tree; higher levels remove successive weakest links according to squared-error cost complexity. Nodes uses one-based node indices. The original tree remains immutable.

Example

m=fitrtree((0:7)',[0;0;1;1;4;4;5;5],'MinParentSize',2); p=prune(m,'Nodes',1); predict(p,[0;7])

Differences from MATLAB: Level and Nodes are supported; Alpha is not. prune(tree) returns an unchanged copy; pruning levels are computed on request.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.