Conformal Prediction
Conformal PredictionがAIにどのように分布フリーな不確実性を提供するかを解説します。Ultralytics YOLO26で予測セットを実装し、信頼性の高いモデル結果を保証する方法を学びましょう。
Conformal prediction is a statistical framework in machine learning (ML) that provides distribution-free measures of uncertainty for model predictions. Instead of outputting a single point prediction—such as one specific class label—a conformal predictor outputs a prediction set or interval that contains the true value with a user-specified probability (e.g., 90% or 95%). This framework wraps around any artificial intelligence (AI) model to provide formal statistical guarantees without requiring changes to the model's architecture. For an exhaustive list of up-to-date tools and research, you can explore the Awesome Conformal Prediction repository.
Link to this sectionConformal Predictionの仕組み#
基本的なメカニズムは、nonconformity scoreを使用して、新しい予測が過去の例と比較してどれほど異例であるかを評価することに基づいています。
- モデルトレーニング:まず、標準的なトレーニングデータセットを使用してベースラインモデルをトレーニングします。
- キャリブレーションフェーズ:トレーニング済みのモデルに、別に保持しておいたキャリブレーションデータセットを入力します。画像分類における逆確率など、各予測のnonconformity scoreを計算します。
- 分位点計算:目標とする信頼レベル(例: 95%)を決定し、これらのキャリブレーションスコアの対応する分位点を求めて予測セットを構築します。
- 推論の適用:実際の推論時には、新しい入力を評価し、スコアがキャリブレーション分位点以下となるすべての可能なラベルを含めます。
このアプローチの数学的な証明については、A Gentle Introduction to Conformal Predictionチュートリアルを確認するか、時間的な不確実性を処理するための時系列予測アプローチについて学ぶことができます。
Link to this sectionConformal Predictionと関連用語の区別#
このフレームワークを、モデルテスト中に使用される標準的な指標と区別することが極めて重要です:
- Conformal Prediction vs. 信頼度スコア:標準的な信頼度スコアはモデルの内部的な確信度を反映しますが、多くの場合キャリブレーションが不十分であり、数学的な保証が欠けています。Conformal predictionは、これらの生スコアを保証されたセットに変換します。従来型の調整については、scikit-learnの確率キャリブレーションを参照してください。
- Conformal Prediction vs. 精度:精度は、データセット全体にわたってモデルがどれくらいの頻度で正解しているかを示すグローバルな履歴指標ですが、一方でconformal inferenceは、すべての新しい予測に対してローカルなインスタンス固有の間隔を提供します。
Link to this section実社会での応用#
Conformal predictionは、モデルの盲点を知ることが不可欠なハイステークスな分野において、なくてはならないものです。
- 医療診断:医療分野でスキャンを分析するためにAIを活用する際、モデルは誤った可能性のある単一のクラスではなく、もっともらしい診断のセットを出力する場合があります。これにより、臨床医はすべての実行可能な可能性を調査でき、信頼性の高いゲノム医療と画像診断に関する最近の研究をサポートします。
- 自動運転:自動車システムのAIにおいて、予測間隔を物体検出に適用すると、歩行者の周囲に空間的な信頼領域が生成されます。これにより、車両のブレーキシステムは最悪の動きを安全に考慮できるようになります。
Link to this section予測セットの実装#
MAPIE (Model Agnostic Prediction Interval Estimator)のようなライブラリはPython向けの組み込みツールを提供しており、回帰タスクではconformal quantile regressionが頻繁に使用されます。また、Ultralytics YOLO26のような高度なモデルからの確率を使用して、基本的なConformal predictionロジックを実装することも可能です。以下の例では、YOLO26の分類確率を使用して、累積しきい値に達するまでトップクラスを含めるというロジックを模倣した予測セットを構築します。
from ultralytics import YOLO
# Load an Ultralytics YOLO26 classification model
model = YOLO("yolo26n-cls.pt")
# Perform inference on an image
results = model("https://ultralytics.com/images/bus.jpg")
# Simple conformal-style prediction set logic based on cumulative probability
target_coverage = 0.95
prediction_set = []
cumulative_prob = 0.0
# Sort probabilities in descending order using the results object
probs = results[0].probs
sorted_indices = probs.top5
for idx in sorted_indices:
class_name = results[0].names[idx]
class_prob = probs.data[idx].item()
prediction_set.append((class_name, round(class_prob, 3)))
cumulative_prob += class_prob
# Stop adding to the set once we reach the 95% coverage threshold
if cumulative_prob >= target_coverage:
break
print(f"95% Prediction Set: {prediction_set}")Developing reliable systems requires robust data practices to prevent data drift from ruining calibration. Tools like the Ultralytics Platform simplify the process of gathering fresh classification datasets, retraining models, and securely managing model deployment. You can read more about curating balanced data in our guide on understanding dataset bias, or track the latest advancements presented at the annual COPA conference.






