sklearn_lvq.LgmlvqModel

class sklearn_lvq.LgmlvqModel(prototypes_per_class=1, initial_prototypes=None, initial_matrices=None, regularization=0.0, initialdim=None, classwise=False, max_iter=2500, gtol=1e-05, beta=2, c=None, display=False, random_state=None)[source]

Localized Generalized Matrix Learning Vector Quantization

Parameters
prototypes_per_classint or list of int, optional (default=1)

Number of prototypes per class. Use list to specify different numbers per class.

initial_prototypesarray-like, shape = [n_prototypes, n_features + 1],
optional

Prototypes to start with. If not given initialization near the class means. Class label must be placed as last entry of each prototype.

initial_matriceslist of array-like, optional

Matrices to start with. If not given random initialization

regularizationfloat or array-like, shape = [n_classes/n_prototypes],
optional (default=0.0)

Values between 0 and 1. Regularization is done by the log determinant of the relevance matrix. Without regularization relevances may degenerate to zero.

initialdimint, optional

Maximum rank or projection dimensions

classwiseboolean, optional

If true, each class has one relevance matrix. If false, each prototype has one relevance matrix.

max_iterint, optional (default=2500)

The maximum number of iterations.

gtolfloat, optional (default=1e-5)

Gradient norm must be less than gtol before successful termination of l-bfgs-b.

betaint, optional (default=2)

Used inside phi. 1 / (1 + np.math.exp(-beta * x))

carray-like, shape = [2,3] ,optional

Weights for wrong classification of form (y_real,y_pred,weight) Per default all weights are one, meaning you only need to specify the weights not equal one.

displayboolean, optional (default=False)

Print information about the bfgs steps.

random_stateint, RandomState instance or None, optional

If int, random_state is the seed used by the random number generator; If RandomState instance, random_state is the random number generator; If None, the random number generator is the RandomState instance used by np.random.

Attributes
w_array-like, shape = [n_prototypes, n_features]

Prototype vector, where n_prototypes in the number of prototypes and n_features is the number of features

c_w_array-like, shape = [n_prototypes]

Prototype classes

classes_array-like, shape = [n_classes]

Array containing labels.

omegas_list of array-like

Relevance Matrices

dim_list of int

Maximum rank of projection

regularization_array-like, shape = [n_classes/n_prototypes]

Values between 0 and 1

Methods

decision_function(x)

Predict confidence scores for samples.

fit(x, y)

Fit the LVQ model to the given training data and parameters using l-bfgs-b.

get_params([deep])

Get parameters for this estimator.

phi(x)

Parameters

phi_prime(x)

Parameters

predict(x)

Predict class membership index for each input sample.

project(x, prototype_idx, dims[, …])

Projects the data input data X using the relevance matrix of the prototype specified by prototype_idx to dimension dim

score(X, y[, sample_weight])

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

set_params(**params)

Set the parameters of this estimator.

__init__(prototypes_per_class=1, initial_prototypes=None, initial_matrices=None, regularization=0.0, initialdim=None, classwise=False, max_iter=2500, gtol=1e-05, beta=2, c=None, display=False, random_state=None)[source]

Initialize self. See help(type(self)) for accurate signature.