Quantum Classification for Machine Learning¶
Forge provides the beginnings of quantum machine learning in the form of classification algorithms for fitting data points to a classification model, and predicting the classification of further data points in a unified function.

qcware.qml.
fit_and_predict
(X: numpy.array, model: str, y: Optional[numpy.array] = None, T: Optional[numpy.array] = None, parameters: dict = {}, backend: str = 'qcware/cpu_simulator')¶ This function combines both the fitting of data to a quantum model for the purposes of classification and also the use of that trained model for classifying new data. The interface and use are similar to scikitlearn’s fit and predict functions. At the present time, since the fit data comprises (in many cases) both classical and quantum data difficult to serialize, the fitting and prediction are done in a single step. We are looking to separate them into separate fit and predict steps in the future. Four clustering models are implemented at this time (see parameter model)
Arguments:
 Parameters
X (numpy.array) – Training data: \((N\times d)\) array containing training data
model (str) – String for the clustering model; one of [‘QNearestCentroid’, ‘QNeighborsClassifier’, ‘QNeighborsRegressor’, ‘QMeans’]
y (numpy.array) – Label vector: length \(d\) array containing respective labels of each data, defaults to None
T (numpy.array) – Test data: \((M\times d)\) array containing test data, defaults to None
parameters (dict) – Dictionary containing parameters for the model, defaults to {}
backend (str) – String describing the backend to use; currently one of [qcware/cpu_simulator, qcware/gpu_simulator], defaults to qcware/cpu_simulator
 Returns
A numpy array the length of the test data T containing fit labels
 Return type
numpy.array