ラベル SVC の投稿を表示しています。 すべての投稿を表示
ラベル SVC の投稿を表示しています。 すべての投稿を表示

2026年2月16日月曜日

量子カーネル(SVC法)ってどうなの?

【要旨】古典/量子カーネル(+SVC)の基本的な理解を深めるため、両者のクラス分け(分類)性能を比較した。現状では、多くの場合、古典カーネルが高い精度を示す。しかし、特殊なAd-hocデータに対しては、古典カーネルは対応できない反面、量子カーネルは完璧な分類結果を示した。ここに、量子カーネルの可能性を見ることができる。

🟢量子カーネルの概要
 まず、量子カーネルの概要を図1に示す。量子特性(重ね合せ、もつれ、位相、干渉)を生かしたFeature Mapと呼ばれる量子回路を用いることが特徴である。これによって、元の2次元データの座標を、高次元(この例では4次元)の量子状態ベクトルへ変換する。そして、その空間でのデータ間類似度を計算する。これも、量子回路で実行される。その情報とラベル情報を使って、古典的なSVC学習器を学習させる。

 Feature Mapにはいくつか種類があるが、ここでは、有名なZZFeature Mapというものを使う。その狙いは、一言で言えば、「古典的には表現困難な非線形の相関を捉える」ことである。従来の古典的な類似度の計算では、座標データが使われるが、このマッピングでは、座標データは量子の位相情報も埋め込んだ情報に変換されるので、位相の近似性も反映した学習となるはずである。
図1 量子カーネルの概要

🟢 実データ(金融 default)の分類
 金融defaultに関する実データ(Javier Mancilla Montero, PhDによる)の分類を試みる。ここに、1,000人の顧客の情報がある。各人には20個の調査項目の値とdefault(債務不履行)か否かのラベルが付いている。この生データは、20次元データなので、主成分分析により次元削減を行う。この例では2次元とした。Feature Mapでは、項目(特徴量)ごとに量子ビットが必要なため、そのようにするのが通例である。

 図2右上は、分類にかける状態である。その下に、古典カーネルによる分離結果を示した。精度0.94で、defaultか否かの境界線が引かれている。一方、その左に、量子カーネルによる結果がある。境界線はやや異なるが、量子カーネルの場合も同様に高い性能を示した。
図2 金融defaultの実データ1,000件の分類
 
 これ以外の実データセットとして(詳細は略すが)、腫瘍(特徴量30個)のサンプル569件がある。その良性 (Benign) /悪性 (Malignant) 分類問題でも、古典カーネル、量子カーネルとも精度0.90を超える結果出している。これらの分類問題では、長年の実績を持つ古典カーネルを使えば十分のように見える。しかし、全く新しい方法である量子カーネルも、実問題に対して同程度の分類性能を示したことは、注目すべきではないか。

🟢人工的なデータセット(Ad-hocデータ)の分類
 次に、量子カーネル(特に、ZZFeature Map)を評価するために作られたAd-hocデータセット(こちらを参照)で試みる。図3右上をご覧いただきたい。赤と青の点が、合計720個ランダムに散在している。だが、何か規則性もあるようだ。実際、データ点数を増やして行くと、赤青の市松模様に近づく。

 まず、これを古典カーネルで分類した。図3右下の通り、このような単純な境界線しか引くことができなかった。これでは、精度は50%台にとどまる。SVCのいくつかのパラメータを変更しても、ほとんどこれと変わらない。
図3 Ad-hocデータセットの古典カーネルによる分類

 次に、量子カーネルを適用した。その結果が図4である。図4右下の通り、正解率100%となる完璧な境界線が引かれた。その左側の図は、この境界線が引かれた時の、境界関数の山と谷の等高線をカラーで示したものである。
図4 Ad-hocデータセットの量子カーネルによる分類

 このデータセットは、ad-hocという名の通り、量子の空間(ヒルベルト空間)で綺麗に分離できるデータを、通常の2次元平面に写像して作ったものなので、当然、量子カーネルで完全に分離できたのである。

 そうであっても、この結果は、量子重ね合せ、位相、もつれを巧みに利用したZZFeature Mapの効果なのだと言える。特殊なデータセットではあるが、古典カーネルでは困難な、新たな領域を探求できる量子カーネルの可能性を示しているようだ!

2025年6月11日水曜日

Enjoy Observing Classical and Quantum Kernels in SVC

[Abstract]
The Support Vector Classifier (SVC) is a well-known and effective method for classification. One of its key strengths is the kernel trick, which implicitly maps complex, intertwined data into a higher-dimensional space using a kernel function—allowing for linear separation in that space. In this article, we’ll visually explore and enjoy the differences between classical and quantum kernels!

🟢 Input Dataset: Gaussian Parity
Classical SVC is highly powerful and often outperforms current quantum methods. However, quantum techniques offer novel capabilities that classical approaches cannot, which is why research in this area is gaining momentum.In this article, we use a dataset known as Gaussian Parity, which is considered well-suited for quantum methods.

     As shown in Fig. 1, this dataset consists of 80 samples (56 for training and 24 for testing) and two class labels. The data points from each class are interleaved in a diagonally crossed pattern, making linear separation difficult without transformation. This is where the kernel function—mentioned in the abstract—comes into play.

🟢 SVC Results with Classical and Quantum Kernels
Let’s start with the conclusion. Figure 2 shows classification results using SVC trained with (a) a classical kernel (RBF) and (b) a quantum kernel (a kernel matrix based on the ZZFeatureMap). On the test set, classification accuracy was 0.58 for (a) and 0.93 for (b).

     Of course, these results can vary depending on parameter settings. However, in this instance, the quantum kernel significantly outperformed the classical one. Also, the direction of the decision boundary differs considerably between (a) and (b).

🟢 Exploring the Classical Kernel (RBF)
Let’s take a closer look at the classical case. The RBF kernel is not used directly, but rather called internally during SVC training. It implicitly maps the input data into a higher-dimensional space.
Based on the learned model, we can use Principal Component Analysis (PCA) to project this high-dimensional space into three dimensions and visualize the decision function in 3D.

     The top two images in Fig. 3 show this 3D decision function. You can observe two peaks and two valleys. If we slice this 3D surface at the decision function value = 0, the resulting plane gives us the decision boundary.

🟢 Exploring the Quantum Kernel Matrix
Now let’s examine the quantum case. As shown in Fig. 4, the decision function exhibits a more complex pattern, with more peaks and valleys than in the classical case.
When we slice the surface at decision function = 0, we obtain a decision boundary that achieves a classification accuracy of 0.93.

     This example suggests that the quantum method is exploring and learning within a feature space that classical methods cannot access. This may open the door to entirely new possibilities!