API Documentation

This section shows the documentation of the Helstrom Quantum Centroid (HQC) classifier’s API. Click on the [source] links below (in green) to see the source code for the API.

class hqc.hqc.HQC(rescale=1, encoding='amplit', n_copies=1, class_wgt='equi', n_jobs=None, n_splits=1)[source]

The Helstrom Quantum Centroid (HQC) classifier is a quantum-inspired supervised classification approach for data with binary classes (ie. data with 2 classes only).

Parameters
  • rescale (int or float, default = 1) – The dataset rescaling factor. A parameter used for rescaling the dataset.

  • encoding (str, default = 'amplit') – The encoding method used to encode vectors into quantum densities. Possible values: ‘amplit’, ‘stereo’. ‘amplit’ means using the amplitude encoding method. ‘stereo’ means using the inverse of the standard stereographic projection encoding method. Default set to ‘amplit’.

  • n_copies (int, default = 1) – The number of copies to take for each quantum density. This is equivalent to taking the n-fold Kronecker tensor product for each quantum density.

  • class_wgt (str, default = 'equi') – The class weights assigned to the Quantum Helstrom observable terms. Possible values: ‘equi’, ‘weighted’. ‘equi’ means assigning equal weights of 1/2 (equiprobable) to the two classes in the Quantum Helstrom observable. ‘weighted’ means assigning weights equal to the proportion of the number of rows in each class to the two classes in the Quantum Helstrom observable. Default set to ‘equi’.

  • n_jobs (int, default = None) – The number of CPU cores used when parallelizing. If -1 all CPUs are used. If 1 is given, no parallel computing code is used at all. For n_jobs below -1, (n_cpus + 1 + n_jobs) are used. Thus for n_jobs = -2, all CPUs but one are used. None is a marker for ‘unset’ that will be interpreted as n_jobs = 1.

  • n_splits (int, default = 1) – The number of subset splits performed on the input dataset row-wise and on the number of eigenvalues/eigenvectors of the Quantum Helstrom observable for optimal speed performance. If 1 is given, no splits are performed. For optimal speed, recommend using n_splits = int(numpy.ceil(number of CPU cores used/2)). If memory blow-out occurs, reduce n_splits.

classes_

Sorted binary classes.

Type

ndarray, shape (2,)

centroids_

Quantum Centroids for class with index 0 and 1 respectively.

Type

ndarray, shape (2, (n_features + 1)**n_copies, (n_features + 1)**n_copies)

hels_obs_

Quantum Helstrom observable.

Type

ndarray, shape ((n_features + 1)**n_copies, (n_features + 1)**n_copies)

proj_sums_

Sum of the projectors of the Quantum Helstrom observable’s eigenvectors, which has corresponding positive and negative eigenvalues respectively.

Type

tuple, shape (2, (n_features + 1)**n_copies, (n_features + 1)**n_copies)

hels_bound_

Helstrom bound is the upper bound of the probability that one can correctly discriminate whether a quantum density is of which of the two binary quantum density pattern.

Type

float

fit(X, y)[source]

Perform HQC classification with the inverse of the standard stereographic projection encoding, with the option to rescale the dataset prior to encoding.

Parameters
  • X (array-like, shape (n_samples, n_features)) – The training input samples. An array of int or float.

  • y (array-like, shape (n_samples,)) – The training input binary target values. An array of str, int or float.

Returns

self – Returns self.

Return type

object

predict(X)[source]

Performs HQC classification on X and returns the binary classes.

Parameters

X (array-like, shape (n_samples, n_features)) – The input samples. An array of int or float.

Returns

self.classes_[predict_trace_index] – The predicted binary classes. An array of str, int or float.

Return type

array-like, shape (n_samples,)

predict_proba(X)[source]

Performs HQC classification on X and returns the trace of the dot product of the densities and the sum of the projectors with corresponding positive and negative eigenvalues respectively.

Parameters

X (array-like, shape (n_samples, n_features)) – The input samples. An array of int or float.

Returns

trace_matrix – Column index 0 corresponds to the trace of the dot product of the densities and the sum of projectors with positive eigenvalues. Column index 1 corresponds to the trace of the dot product of the densities and the sum of projectors with negative eigenvalues. An array of float.

Return type

array-like, shape (n_samples, 2)