Discriminant analysis application

LDA is performed in the MASS package, which we have already loaded so that we can access the biopsy data. The syntax is very similar to the lm() and glm() functions. 

We can now begin fitting our LDA model, which is as follows:

    > lda.fit <- lda(class ~ ., data = train)    > lda.fit    Call:    lda(class ~ ., data = train)    Prior probabilities of groups:       benign malignant    0.6371308 0.3628692    Group means:    thick  u.size u.shape   adhsn  s.size    nucl         chrom    benign    2.9205 1.30463 1.41390 1.32450 2.11589       1.39735 2.08278    malignant 7.1918 6.69767 6.68604 5.66860 5.50000       7.67441 5.95930                n.nuc     mit    benign    1.22516 1.09271    malignant 5.90697 2.63953    Coefficients of linear discriminants:                    LD1    thick    0.19557291    u.size   0.10555201    u.shape ...

Get Mastering Machine Learning with R - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.