Quadratic Discriminant Analysis
A classifier with a quadratic decision boundary, generated by fitting class conditional densities to the data and using Bayes' rule.
The model fits a Gaussian density to each class.
.. versionadded:: 0.17 *QuadraticDiscriminantAnalysis*
Read more in the :ref:`User Guide <lda_qda>`.
Parameters ---------- priors : array, optional, shape = n_classes
Priors on classes
reg_param : float, optional Regularizes the covariance estimate as ``(1-reg_param)*Sigma + reg_param*np.eye(n_features)``
store_covariance : boolean If True the covariance matrices are computed and stored in the `self.covariance_` attribute.
.. versionadded:: 0.17
tol : float, optional, default 1.0e-4 Threshold used for rank estimation.
.. versionadded:: 0.17
Attributes ---------- covariance_ : list of array-like of shape (n_features, n_features) Covariance matrices of each class.
means_ : array-like of shape (n_classes, n_features) Class means.
priors_ : array-like of shape (n_classes) Class priors (sum to 1).
rotations_ : list of arrays For each class k an array of shape n_features, n_k
, with ``n_k = min(n_features, number of elements in class k)`` It is the rotation of the Gaussian distribution, i.e. its principal axis.
scalings_ : list of arrays For each class k an array of shape n_k
. It contains the scaling of the Gaussian distributions along its principal axes, i.e. the variance in the rotated coordinate system.
classes_ : array-like, shape (n_classes,) Unique class labels.
Examples -------- >>> from sklearn.discriminant_analysis import QuadraticDiscriminantAnalysis >>> import numpy as np >>> X = np.array([-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]
) >>> y = np.array(1, 1, 1, 2, 2, 2
) >>> clf = QuadraticDiscriminantAnalysis() >>> clf.fit(X, y) QuadraticDiscriminantAnalysis() >>> print(clf.predict([-0.8, -1]
)) 1
See also -------- sklearn.discriminant_analysis.LinearDiscriminantAnalysis: Linear Discriminant Analysis