GSgnnClassificationEvaluator

class graphstorm.eval.GSgnnClassificationEvaluator(eval_frequency, eval_metric_list=None, multilabel=False, use_early_stop=False, early_stop_burnin_rounds=0, early_stop_rounds=3, early_stop_strategy='average_increase')

Bases: GSgnnBaseEvaluator, GSgnnPredictionEvalInterface

Evaluator for classification tasks.

A built-in evaluator for classification tasks. It uses accuracy as the default evaluation metric.

This class replaces the GSgnnAccEvaluator since v0.3.

Parameters

eval_frequency: int

The frequency (number of iterations) of doing evaluation.

eval_metric_list: list of string

Evaluation metrics used during evaluation. Default: [“accuracy”].

multilabel: bool

If set to true, the task is a multi-label classification task. Default: False.

use_early_stop: bool

Set true to use early stop. Default: False.

early_stop_burnin_rounds: int

Burn-in rounds (number of evaluations) before starting to check for the early stop condition. Default: 0.

early_stop_rounds: int

The number of rounds (number of evaluations) for validation scores used to decide early stop. Default: 3.

early_stop_strategy: str

The early stop strategy. GraphStorm supports two strategies: 1) consecutive_increase, and 2) average_increase. Default: average_increase.

evaluate(val_pred, test_pred, val_labels, test_labels, total_iters)

Compute classification metric scores on validation and test sets.

Parameters

val_predtensor

The tensor stores the prediction results on the validation nodes or edges.

test_predtensor

The tensor stores the prediction results on the test nodes or edges.

val_labelstensor

The tensor stores the labels of the validation nodes or edges.

test_labelstensor

The tensor stores the labels of the test nodes or edges.

total_iters: int

The current iteration number.

Returns

eval_score: dict

Validation scores of different classification metrics in the format of {metric: val_score}.

test_score: dict

Test scores of different classification metrics in the format of {metric: test_score}.

compute_score(pred, labels, train=True)

Compute classification evaluation score.

Parameters

pred: tensor

The tensor stores the prediction results.

labels: tensor

The tensor stores the labels.

train: bool

If in model training.

Returns

results: dict

Evaluation scores of different classification metrics in the format of {metric: score}. If either pred or labels are None, the score will be “N/A”.

property multilabel

Return if this is a multi-label classification task, which is given in class initialization.