sklvq.discriminants.DiscriminantBaseClass

class sklvq.discriminants.DiscriminantBaseClass[source]

Discriminant base class

Abstract class for implementing discriminant functions. Provides abstract methods with expected call signatures.

Custom discriminative function ‘__init__’ should accept any parameters as key-value pairs.

See also

RelativeDistance
abstract __call__(dist_same: numpy.ndarray, dist_diff: numpy.ndarray)numpy.ndarray[source]

Should implement a discriminant function

Parameters
dist_samendarray of shape (n_samples, 1), with n_samples >= 1

Shortest distance of n_samples to a prototype with the same label.

dist_diffndarray of shape (n_samples, 1), with n_samples >= 1

Shortest distance of n_samples to a prototype with a different label.

Returns
ndarraywith shape (n_samples, 1)

Should perform a elementwise evaluation of a discriminant function.

abstract gradient(dist_same: numpy.ndarray, dist_diff: numpy.ndarray, same_label: bool)numpy.ndarray[source]

Should implement the discriminant function’s gradient

Parameters
dist_samendarray with shape (n_samples, 1), with n_samples >= 1

Shortest distance of n_samples to a prototype with the same label.

dist_diffndarray with shape (n_samples, 1), with n_samples >= 1

Shortest distance of n_samples to a prototype with a different label.

same_labelbool

Indicates if the gradient with respect to a prototype with the same label (True) or with respect to a prototype with a different label (False) needs to be computed.

Returns
ndarray with shape (n_sampeles, 1)

Should perform a elementwise evaluation of a discriminant function’s gradient.

Examples using sklvq.discriminants.DiscriminantBaseClass