I am reading the book titled "An Introduction to Statistical Learning with Applications in R" by James et al. On page 326, we perform cross-validation to determine the optimal level of tree complexity (for a classification tree). Here, you can find an extract from the provided R-code. As you can notice one of the values of $k$ (which is actually the tuning parameter $\alpha$ for cost-complexity pruning) equals $-\infty$. I was wondering, how can one obtain $-\infty$ for the cost complexity parameter?

Thanks in advance.

  • $\begingroup$ What library was used to fit this model? What does the documentation about that library say about this method? $\endgroup$
    – Sycorax
    Mar 9, 2020 at 19:03
  • $\begingroup$ @SycoraxsaysReinstateMonica: It's the tree package and unfortunately the documentation does not cover this point at all. $\endgroup$
    – usεr11852
    Mar 9, 2020 at 19:17

1 Answer 1


The value -Inf does not really relate to the cv.tree functionality but rather to the functionality around prune.tree/prune.misclass. Within those functions we examine a series of different complexity parameters $k$. These complexity parameters $k$ when starting their "grid-search" they are set to something ridiculously negative (small) so we can ensure that we do not penalise anything and we have the maximal tree possible. The real number is actually something like -1.0e+200. Then in a rather hammy way within prune.tree the first member of the sequence of $k$'s is set to minus infinity (literally: k[1L] <- -Inf).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.