Slide 29
Slide 29 text
OML4Py Metrics
OML4Py メトリック
OML4Pyにおいて、機械学習モデルのパフォーマンスの評価ができるメトリックが計算できる関数を含むメトリクスモジュール
が使⽤できるようになりました。
例: confusion_matrix関数を⽤いて、混同⾏列を計算
oml.metrics.metric_functionクラスの属性およびメソッドの詳細は、help(oml.metrics.metric_function)を実⾏す
るか、Oracle Machine Learning for Python APIリファレンスを参照してください。
例えば、confusion_matrixについて参照するには、help(oml.metrics.confusion_matrix)を実⾏します。
Documentation: OML4Py Metrics
import oml
import pandas as pd
from oml.metrics import confusion_matrix
y_true = [1, 0, 1, 0, 1, 1, 0, 1, 1, 0] --実際の値
y_pred = [1, 1, 1, 0, 0, 1, 1, 0, 0, 0] --予測値
sample_weight = [1, 2, 1, 1, 1, 1, 1, 3, 1, 1] –-各サンプルの重み
pdf = pd.DataFrame({'y_true': y_true 'y_pred': y_pred, 'sample_weight': sample_weight}) --モデル評価のために実際の値、予
測値、サンプルの重みを含んだデータフレーム
df = oml.create(pdf, ‘test_class’) --モデル評価に使⽤するために、OMLで使⽤されるデータフレーム
confusion_matrix(df, 'y_true', 'y_pred', sample_weight='sample_weight') --混同⾏列の計算
Copyright © 2025, Oracle and/or its affiliates
29