Working with QDA – a nonlinear LDA
QDA is the generalization of a common technique such as quadratic regression. It is simply a generalization of a model to allow for more complex models to fit, though, like all things, when allowing complexity to creep in, we make our lives more difficult.
Getting ready
We will expand on the last recipe and look at QDA via the QDA object.
We said we made an assumption about the covariance of the model. Here we will relax that assumption.
How to do it...
- QDA is aptly a member of the
qda
module. Use the following commands to use QDA:
from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis as QDA qda = QDA() qda.fit(X.iloc[:, :-1], X.iloc[:, -1]) predictions = qda.predict(X.iloc[:, :-1]) predictions.sum() 2686.0 from sklearn.metricsimportclassification_report print classification_report(X.iloc[:, -1].values, predictions) precision recall f1-score support 0.0 0.65 0.66 0.65 3432 1.0 ...