Class: 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.
Constructors
new QuadraticDiscriminantAnalysis()
new QuadraticDiscriminantAnalysis(
opts
?):QuadraticDiscriminantAnalysis
Parameters
Parameter | Type | Description |
---|---|---|
opts ? | object | - |
opts.priors ? | ArrayLike | Class priors. By default, the class proportions are inferred from the training data. |
opts.reg_param ? | number | Regularizes 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. |
opts.store_covariance ? | boolean | If true , the class covariance matrices are explicitly computed and stored in the self.covariance_ attribute. |
opts.tol ? | number | Absolute 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. |
Returns QuadraticDiscriminantAnalysis
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:25
Properties
Property | Type | Default value | Defined in |
---|---|---|---|
_isDisposed | boolean | false | generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:23 |
_isInitialized | boolean | false | generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:22 |
_py | PythonBridge | undefined | generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:21 |
id | string | undefined | generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:18 |
opts | any | undefined | generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:19 |
Accessors
classes_
Get Signature
get classes_():
Promise
<ArrayLike
>
Unique class labels.
Returns Promise
<ArrayLike
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:579
covariance_
Get Signature
get covariance_():
Promise
<any
[]>
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
.
Returns Promise
<any
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:444
feature_names_in_
Get Signature
get feature_names_in_():
Promise
<ArrayLike
>
Names of features seen during fit. Defined only when X
has feature names that are all strings.
Returns Promise
<ArrayLike
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:633
means_
Get Signature
get means_():
Promise
<ArrayLike
[]>
Class-wise means.
Returns Promise
<ArrayLike
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:471
n_features_in_
Get Signature
get n_features_in_():
Promise
<number
>
Number of features seen during fit.
Returns Promise
<number
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:606
priors_
Get Signature
get priors_():
Promise
<ArrayLike
>
Class priors (sum to 1).
Returns Promise
<ArrayLike
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:498
py
Get Signature
get py():
PythonBridge
Returns PythonBridge
Set Signature
set py(
pythonBridge
):void
Parameters
Parameter | Type |
---|---|
pythonBridge | PythonBridge |
Returns void
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:56
rotations_
Get Signature
get rotations_():
Promise
<any
[]>
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.
Returns Promise
<any
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:525
scalings_
Get Signature
get scalings_():
Promise
<any
[]>
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.
Returns Promise
<any
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:552
Methods
decision_function()
decision_function(
opts
):Promise
<ArrayLike
>
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.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Array of samples (test vectors). |
Returns Promise
<ArrayLike
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:131
dispose()
dispose():
Promise
<void
>
Disposes of the underlying Python resources.
Once dispose()
is called, the instance is no longer usable.
Returns Promise
<void
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:112
fit()
fit(
opts
):Promise
<any
>
Fit the model according to the given training data and parameters.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Training vector, where n_samples is the number of samples and n_features is the number of features. |
opts.y ? | ArrayLike | Target values (integers). |
Returns Promise
<any
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:167
get_metadata_routing()
get_metadata_routing(
opts
):Promise
<any
>
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.routing ? | any | A MetadataRequest encapsulating routing information. |
Returns Promise
<any
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:210
init()
init(
py
):Promise
<void
>
Initializes the underlying Python resources.
This instance is not usable until the Promise
returned by init()
resolves.
Parameters
Parameter | Type |
---|---|
py | PythonBridge |
Returns Promise
<void
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:69
predict()
predict(
opts
):Promise
<ArrayLike
>
Perform classification on an array of test vectors X.
The predicted class C for each sample in X is returned.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
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:248
predict_log_proba()
predict_log_proba(
opts
):Promise
<ArrayLike
[]>
Return log of posterior probabilities of classification.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Array of samples/test vectors. |
Returns Promise
<ArrayLike
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:284
predict_proba()
predict_proba(
opts
):Promise
<ArrayLike
[]>
Return posterior probabilities of classification.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.X ? | ArrayLike [] | Array of samples/test vectors. |
Returns Promise
<ArrayLike
[]>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:320
score()
score(
opts
):Promise
<number
>
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.
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | ArrayLike | Sample weights. |
opts.X ? | ArrayLike [] | Test samples. |
opts.y ? | ArrayLike | True labels for X . |
Returns Promise
<number
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:358
set_score_request()
set_score_request(
opts
):Promise
<any
>
Request metadata passed to the score
method.
Note that this method is only relevant if enable_metadata_routing=True
(see sklearn.set_config
). Please see User Guide on how the routing mechanism works.
The options for each parameter are:
Parameters
Parameter | Type | Description |
---|---|---|
opts | object | - |
opts.sample_weight ? | string | boolean | Metadata routing for sample_weight parameter in score . |
Returns Promise
<any
>
Defined in generated/discriminant_analysis/QuadraticDiscriminantAnalysis.ts:408