Documentation
Classes
QuadraticDiscriminantAnalysis

QuadraticDiscriminantAnalysis

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.

Python Reference (opens in a new tab)

Constructors

constructor()

Signature

new QuadraticDiscriminantAnalysis(opts?: object): QuadraticDiscriminantAnalysis;

Parameters

NameTypeDescription
opts?object-
opts.priors?ArrayLikeClass priors. By default, the class proportions are inferred from the training data.
opts.reg_param?numberRegularizes the per-class covariance estimates by transforming S2 as S2 \= (1 \- reg\_param) \* S2 + reg\_param \* np.eye(n\_features), where S2 corresponds to the scaling\_ attribute of a given class. Default Value 0
opts.store_covariance?booleanIf true, the class covariance matrices are explicitly computed and stored in the self.covariance\_ attribute. Default Value false
opts.tol?numberAbsolute threshold for a singular value to be considered significant, used to estimate the rank of Xk where Xk is the centered matrix of samples in class k. This parameter does not affect the predictions. It only controls a warning that is raised when features are considered to be colinear. Default Value 0.0001

Returns

QuadraticDiscriminantAnalysis

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:25 (opens in a new tab)

Properties

_isDisposed

boolean = false

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:23 (opens in a new tab)

_isInitialized

boolean = false

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:22 (opens in a new tab)

_py

PythonBridge

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:21 (opens in a new tab)

id

string

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:18 (opens in a new tab)

opts

any

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:19 (opens in a new tab)

Accessors

classes_

Unique class labels.

Signature

classes_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:526 (opens in a new tab)

covariance_

For each class, gives the covariance matrix estimated using the samples of that class. The estimations are unbiased. Only present if store\_covariance is true.

Signature

covariance_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:391 (opens in a new tab)

feature_names_in_

Names of features seen during fit. Defined only when X has feature names that are all strings.

Signature

feature_names_in_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:580 (opens in a new tab)

means_

Class-wise means.

Signature

means_(): Promise<ArrayLike[]>;

Returns

Promise<ArrayLike[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:418 (opens in a new tab)

n_features_in_

Number of features seen during fit.

Signature

n_features_in_(): Promise<number>;

Returns

Promise<number>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:553 (opens in a new tab)

priors_

Class priors (sum to 1).

Signature

priors_(): Promise<ArrayLike>;

Returns

Promise<ArrayLike>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:445 (opens in a new tab)

py

Signature

py(): PythonBridge;

Returns

PythonBridge

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:58 (opens in a new tab)

Signature

py(pythonBridge: PythonBridge): void;

Parameters

NameType
pythonBridgePythonBridge

Returns

void

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:62 (opens in a new tab)

rotations_

For each class k an array of shape (n_features, n_k), where n\_k \= min(n\_features, number of elements in class k) It is the rotation of the Gaussian distribution, i.e. its principal axis. It corresponds to V, the matrix of eigenvectors coming from the SVD of Xk \= U S Vt where Xk is the centered matrix of samples from class k.

Signature

rotations_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:472 (opens in a new tab)

scalings_

For each class, contains the scaling of the Gaussian distributions along its principal axes, i.e. the variance in the rotated coordinate system. It corresponds to S^2 / (n\_samples \- 1), where S is the diagonal matrix of singular values from the SVD of Xk, where Xk is the centered matrix of samples from class k.

Signature

scalings_(): Promise<any[]>;

Returns

Promise<any[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:499 (opens in a new tab)

Methods

decision_function()

Apply decision function to an array of samples.

The decision function is equal (up to a constant factor) to the log-posterior of the model, i.e. log p(y \= k | x). In a binary classification setting this instead corresponds to the difference log p(y \= 1 | x) \- log p(y \= 0 | x). See Mathematical formulation of the LDA and QDA classifiers.

Signature

decision_function(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Array of samples (test vectors).

Returns

Promise<ArrayLike>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:139 (opens in a new tab)

dispose()

Disposes of the underlying Python resources.

Once dispose() is called, the instance is no longer usable.

Signature

dispose(): Promise<void>;

Returns

Promise<void>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:120 (opens in a new tab)

fit()

Fit the model according to the given training data and parameters.

Signature

fit(opts: object): Promise<any>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Training vector, where n\_samples is the number of samples and n\_features is the number of features.
opts.y?ArrayLikeTarget values (integers).

Returns

Promise<any>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:177 (opens in a new tab)

init()

Initializes the underlying Python resources.

This instance is not usable until the Promise returned by init() resolves.

Signature

init(py: PythonBridge): Promise<void>;

Parameters

NameType
pyPythonBridge

Returns

Promise<void>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:71 (opens in a new tab)

predict()

Perform classification on an array of test vectors X.

The predicted class C for each sample in X is returned.

Signature

predict(opts: object): Promise<ArrayLike>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Vector to be scored, where n\_samples is the number of samples and n\_features is the number of features.

Returns

Promise<ArrayLike>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:223 (opens in a new tab)

predict_log_proba()

Return log of posterior probabilities of classification.

Signature

predict_log_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Array of samples/test vectors.

Returns

Promise<ArrayLike[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:261 (opens in a new tab)

predict_proba()

Return posterior probabilities of classification.

Signature

predict_proba(opts: object): Promise<ArrayLike[]>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Array of samples/test vectors.

Returns

Promise<ArrayLike[]>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:299 (opens in a new tab)

score()

Return the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Signature

score(opts: object): Promise<number>;

Parameters

NameTypeDescription
optsobject-
opts.X?ArrayLike[]Test samples.
opts.sample_weight?ArrayLikeSample weights.
opts.y?ArrayLikeTrue labels for X.

Returns

Promise<number>

Defined in: generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:339 (opens in a new tab)