Plot decision boundaries with ggplot2?

后端 未结 2 1888
[愿得一人]
[愿得一人] 2020-12-15 09:44

How do I plot the equivalent of contour (base R) with ggplot2? Below is an example with linear discriminant function analysis:

require(MASS)
iri         


        
2条回答
  •  -上瘾入骨i
    2020-12-15 10:38

    The partimat function in the klaR library does what you want for observed predictors, but if you want the same for the LDA projections, you can build a data frame augmenting the original with the LD1...LDk projections, then call partimat with formula Group~LD1+...+LDk, method='lda' - then you see the "LD-plane" that you intended to see, nicely partitioned for you. This seemed easier to me, at least to explain to students newer to R, since I'm just reusing a function already provided in a way in which it wasn't quite intended.

提交回复
热议问题