16.2.6 Supervised GraphWiseモデルの分類と回帰モデル
プロパティを予測する場合、損失関数は、モデルが分類タスクまたは回帰タスクを実行するかどうかを定義します。
分類タスクの場合、Supervised GraphWiseモデルによってラベルが推測されます。このプロパティが数値であっても、モデルでは検出された値ごとに1つのラベルが割り当てられ、それに基づいて分類されます。分類タスクで使用可能なlossは、softmax cross entropy
、sigmoid cross entropy
およびDevNet loss
です。
回帰タスクの場合、Supervised GraphWiseモデルによってプロパティの値が推測されます。回帰タスクのlossは、MSE
lossです。
opg4j> import oracle.pgx.config.mllib.loss.LossFunctions
opg4j> var model = analyst.supervisedGraphWiseModelBuilder().
setVertexInputPropertyNames("vertex_features").
setEdgeInputPropertyNames("edge_features").
setVertexTargetPropertyName("scores").
setConvLayerConfigs(convLayerConfig).
setPredictionLayerConfigs(predictionLayerConfig).
setLossFunction(LossFunctions.MSELoss()).
setBatchGenerator(BatchGenerators.STRATIFIED_OVERSAMPLING).
build()
import oracle.pgx.config.mllib.loss.LossFunctions;
SupervisedGraphWiseModel model = analyst.supervisedGraphWiseModelBuilder()
.setVertexInputPropertyNames("vertex_features")
.setEdgeInputPropertyNames("edge_features")
.setVertexTargetPropertyName("scores")
.setConvLayerConfigs(convLayerConfig)
.setPredictionLayerConfigs(predictionLayerConfig)
.setLossFunction(LossFunctions.MSELoss())
.setBatchGenerator(BatchGenerators.STRATIFIED_OVERSAMPLING)
.build();
from pypgx.api.mllib import MSELoss
params = dict(edge_target_property_name="scores",
conv_layer_config=[conv_layer],
pred_layer_config=[pred_layer],
vertex_input_property_names=["vertex_features"],
edge_input_property_names=["edge_features"],
batch_gen='Stratified_Oversampling',
loss_fn=MSELoss())
model = analyst.supervised_graphwise_builder(**params)