Algorithms

Kernel Method Mixin

class KernelMethodMixin[source]

Bases: object

Mixin class for kernel methods such as SVM and Ridge. Exploits quantum parallelization to efficiently compute kernel matrices for train and test data.

Quantum Estimator

class QuantumEstimator(encoding_map=None, quantum_instance=None)[source]

Bases: sklearn.base.TransformerMixin

Parameters
  • encoding_map – Map to classical data to quantum states. This class does not impose any constraint on it. It can either be a custom encoding map or a qiskit FeatureMap

  • quantum_instance – The quantum instance to set. Can be a QuantumInstance or a Backend

abstract fit(X_train, y_train)[source]

Fits the model using X as training dataset and y as training labels

Parameters
  • X_train – training dataset

  • y_train – training labels

abstract predict(X_test)[source]

Predicts the labels associated to the unclassified data X_test

Parameters

X_test – the unclassified data

Return type

ndarray

Returns

the labels associated to X_test

property quantum_instance: qiskit.utils.quantum_instance.QuantumInstance

Returns the quantum instance to evaluate the circuit.

Return type

QuantumInstance

property encoding_map

Returns the Encoding Map

execute(qcircuits)[source]

Executes the given quantum circuit

Parameters
  • qcircuits – a QuantumCircuit or a list of

  • this type to be executed

Return type

Optional[Result]

Returns

the execution results

abstract score(X, y, sample_weight=None)[source]

Returns a score of this model given samples and true values for the samples. In case of classification, this value should correspond to mean accuracy, in case of regression, the coefficient of determination \(R^2\) of the prediction. In case of clustering, the y parameter is typically ignored.

Parameters
  • X – array-like of shape (n_samples, n_features)

  • y – array-like of labels of shape (n_samples,)

  • sample_weight – array-like of shape (n_samples,), default=None The weights for each observation in X. If None, all observations are assigned equal weight.

Return type

float

Returns

a float score of the model.