17.3.6 Supervised EdgeWiseモデルの分類と回帰
プロパティを予測する場合、損失関数は、モデルが分類タスクまたは回帰タスクを実行するかどうかを定義します。
分類タスクの場合、Supervised EdgeWiseモデルによってラベルが推測されます。このプロパティが数値であっても、モデルでは検出された値ごとに1つのラベルが割り当てられ、それに基づいて分類されます。分類タスクで使用可能なlossは、softmax cross entropy
、sigmoid cross entropy
およびDevNet loss
です。
回帰タスクの場合、Supervised EdgeWiseモデルによってプロパティの値が推測されます。回帰タスクのlossは、MSE
lossです。
LossFunction
オブジェクトを指定することで、教師ありモデルに異なる損失関数を選択できます。
opg4j> import oracle.pgx.config.mllib.loss.LossFunctions;
opg4j> var model = analyst.supervisedEdgeWiseModelBuilder().
setVertexInputPropertyNames("vertex_features").
setEdgeInputPropertyNames("edge_features").
setEdgeTargetPropertyName("labels").
setLossFunction(LossFunctions.MSE_LOSS).
build()
import oracle.pgx.config.mllib.loss.LossFunctions;
SupervisedEdgeWiseModel model = analyst.supervisedEdgeWiseModelBuilder()
.setVertexInputPropertyNames("vertex_features")
.setEdgeInputPropertyNames("edge_features")
.setEdgeTargetPropertyName("labels")
.setLossFunction(LossFunctions.MSE_LOSS)
.build();
from pypgx.api.mllib import MSELoss
params = dict(edge_target_property_name="labels",
vertex_input_property_names=["vertex_features"],
edge_input_property_names=["edge_features"],
loss_fn=MSELoss())
model = analyst.supervised_edgewise_builder(**params)