Generic function that walks the tree for a single row of new data, printing the SVM decision value and chosen branch at every internal node and the final predicted class at the leaf.

trace_path(object, ...)

# S3 method for class 'svmodt_node'
trace_path(object, sample_data, sample_idx = 1, ...)

Arguments

object

An svmodt_node returned by svm_split.

...

Currently unused.

sample_data

A data frame of new predictor values (one or more rows).

sample_idx

Integer; which row to trace (default 1).

Value

Invisibly returns the predicted class label (character string).

Methods (by class)

  • trace_path(svmodt_node): Method for svmodt_node objects.

Examples

# \donttest{
tree <- svm_split(wdbc, response = "diagnosis", max_depth = 3)
trace_path(tree, wdbc, sample_idx = 5)
#> === Tracing Prediction Path ===
#> Sample 5 :
#>    diagnosis = 2 
#>    radius_mean = 20.29 
#>    texture_mean = 14.34 
#>    perimeter_mean = 135.1 
#>    area_mean = 1297 
#>    smoothness_mean = 0.1003 
#>    compactness_mean = 0.1328 
#>    concavity_mean = 0.198 
#>    concave.points_mean = 0.1043 
#>    symmetry_mean = 0.1809 
#>    fractal_dimension_mean = 0.05883 
#>    radius_se = 0.7572 
#>    texture_se = 0.7813 
#>    perimeter_se = 5.438 
#>    area_se = 94.44 
#>    smoothness_se = 0.01149 
#>    compactness_se = 0.02461 
#>    concavity_se = 0.05688 
#>    concave.points_se = 0.01885 
#>    symmetry_se = 0.01756 
#>    fractal_dimension_se = 0.005115 
#>    radius_worst = 22.54 
#>    texture_worst = 16.67 
#>    perimeter_worst = 152.2 
#>    area_worst = 1575 
#>    smoothness_worst = 0.1374 
#>    compactness_worst = 0.205 
#>    concavity_worst = 0.4 
#>    concave.points_worst = 0.1625 
#>    symmetry_worst = 0.2364 
#>    fractal_dimension_worst = 0.07678 
#> 
#>  [Node 1 ] features = radius_mean,texture_mean,perimeter_mean,area_mean,smoothness_mean,compactness_mean,concavity_mean,concave.points_mean,symmetry_mean,fractal_dimension_mean,radius_se,texture_se,perimeter_se,area_se,smoothness_se,compactness_se,concavity_se,concave.points_se,symmetry_se,fractal_dimension_se,radius_worst,texture_worst,perimeter_worst,area_worst,smoothness_worst,compactness_worst,concavity_worst,concave.points_worst,symmetry_worst,fractal_dimension_worst 
#>    SVM decision value: 7.4255 
#>    -> Going LEFT (decision > 0)
#>    [Node 2 ] features = radius_mean,texture_mean,perimeter_mean,area_mean,smoothness_mean,compactness_mean,concavity_mean,concave.points_mean,symmetry_mean,fractal_dimension_mean,radius_se,texture_se,perimeter_se,area_se,smoothness_se,compactness_se,concavity_se,concave.points_se,symmetry_se,fractal_dimension_se,radius_worst,texture_worst,perimeter_worst,area_worst,smoothness_worst,compactness_worst,concavity_worst,concave.points_worst,symmetry_worst,fractal_dimension_worst 
#>      SVM decision value: 5.9638 
#>      -> Going LEFT (decision > 0)
#>      [FINAL] Predict M (n = 207 )
#>      Path taken: LEFT -> LEFT 
#> 
#> Final prediction: M 
# }