> ## Documentation Index
> Fetch the complete documentation index at: https://prod-mint.classiq.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Qsvm

### QSVM

Quantum support vector machine (QSVM) model.
Classifies classical data into two categories.
The model is first trained, and fitted. After pre-training,
the model predicts the labels of new data points.

**Methods:**

| Name                              | Description                                                                                                   |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------- |
| [train](#train)                   | Trains an SVM model using a custom precomputed kernel from the training data.                                 |
| [predict](#predict)               | Predicts labels for new data using a precomputed kernel with a trained SVM model.                             |
| [test](#test)                     | Predicts the labels of the test dataset and evaluates the resulting test score using the ground-truth labels. |
| [get\_svm\_model](#get_svm_model) | Returns the classical SVM model.                                                                              |
| [get\_qprog](#get_qprog)          | Returns the quantum program.                                                                                  |

### feature\_map

`feature_map = feature_map`

### num\_qubits

`num_qubits = num_qubits`

### execution\_preferences

`execution_preferences = execution_preferences`

### kernel\_eval

`kernel_eval = QuantumKernelEvaluator(feature_map=(self.feature_map), num_qubits=(self.num_qubits), execution_preferences=(self.execution_preferences))`

### model

`model = SVC(kernel='precomputed')`

### train\_data

`train_data: np.ndarray | None = None`

#### train

<pre><code>train(
self: ,
train\_data: np.ndarray,
train\_labels: np.ndarray
) -> None</code></pre>

Trains an SVM model using a custom precomputed kernel from the training data.

**Parameters:**

| Name           | Type         | Description                           | Default    |
| -------------- | ------------ | ------------------------------------- | ---------- |
| `self`         | \`\`         |                                       | *required* |
| `train_data`   | `np.ndarray` | Contains the data points (np.ndarray) | *required* |
| `train_labels` | `np.ndarray` | Contains the labels (0,1).            | *required* |

#### predict

<pre><code>predict(
self: ,
data: np.ndarray
) -> np.ndarray</code></pre>

Predicts labels for new data using a precomputed kernel with a trained SVM model. Evaluates kernel
matrix elements which are associated with the support vectors (those associated with non-vanishing
coefficients in the prediction equation).

**Parameters:**

| Name   | Type         | Description                         | Default    |
| ------ | ------------ | ----------------------------------- | ---------- |
| `self` | \`\`         |                                     | *required* |
| `data` | `np.ndarray` | List of new data points to predict. | *required* |

**Returns:**

* **Type:** `np.ndarray`
* np.ndarray: Predicted labels (0,1).

#### test

<pre><code>test(
self: ,
data: np.ndarray,
data\_labels: np.ndarray
) -> tuple\[float, np.ndarray]</code></pre>

Predicts the labels of the test dataset and evaluates the resulting test score using the ground-truth labels.

**Parameters:**

| Name          | Type         | Description                          | Default    |
| ------------- | ------------ | ------------------------------------ | ---------- |
| `self`        | \`\`         |                                      | *required* |
| `data`        | `np.ndarray` | List of test data points to predict. | *required* |
| `data_labels` | `np.ndarray` | Contains the test data labels.       | *required* |

**Returns:**

* **Type:** `tuple[float, np.ndarray]`
* containing test score (float) and test labels (np.ndarray\[int]).

#### get\_svm\_model

<pre><code>get\_svm\_model(
self:
) -> SVC</code></pre>

Returns the classical SVM model.

**Parameters:**

| Name   | Type | Description | Default    |
| ------ | ---- | ----------- | ---------- |
| `self` | \`\` |             | *required* |

#### get\_qprog

<pre><code>get\_qprog(
self: ,
data\_dim: int = 0
) -> QuantumProgram | None</code></pre>

Returns the quantum program.

**Parameters:**

| Name       | Type  | Description | Default    |
| ---------- | ----- | ----------- | ---------- |
| `self`     | \`\`  |             | *required* |
| `data_dim` | `int` |             | 0          |
