softening.by.data.range: Make split softening based on data ranges.

Description Usage Arguments Value Examples

View source: R/tree_data_bounds.R

Description

This softening configures each softening parameter in the tree according to ‘data ranges’ appropriate to tree nodes. The parameters are configured such that in each node the distance of the boundary of the softened area from split value is factor * the distance from the split value to the furthest data point in the tree node projected to the direction from the split value to the boundary.

Usage

1

Arguments

tr

The soft tree

ds

The data set to be used for determining data boundaries

factor

The scalar factor

Value

The soft tree with the new softening parameters

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
if(require(tree)) {
  train.data <- iris[c(TRUE,FALSE),]
  test.data <- iris[c(FALSE,TRUE),]
  tr <- tree( Species~., train.data )
  
  # tree with "zero softening"
  s0 <- softsplits( tr )
  # softened tree
  s1 <- softening.by.data.range( s0, train.data, .5 )
  
  response0 <- predictSoftsplits( s0, test.data )
  response1 <- predictSoftsplits( s1, test.data )
  # get class with the highest response
  classification0 <- levels(train.data$Species)[apply( response0, 1, which.max )]
  classification1 <- levels(train.data$Species)[apply( response1, 1, which.max )]
  
  # compare classifiction to the labels
  table( classification0, test.data$Species )
  table( classification1, test.data$Species )
}

SplitSoftening documentation built on Oct. 8, 2021, 5:07 p.m.