textattack.metrics.attack_metrics package

attack_metrics package:

TextAttack provide users common metrics on attacks’ quality.

Metrics on AttackQueries

class textattack.metrics.attack_metrics.attack_queries.AttackQueries[source]

Bases: textattack.metrics.metric.Metric

avg_num_queries()[source]
calculate(results)[source]

Calculates all metrics related to number of queries in an attack.

Parameters

results (AttackResult objects) – Attack results for each instance in dataset

Metrics on AttackSuccessRate

class textattack.metrics.attack_metrics.attack_success_rate.AttackSuccessRate[source]

Bases: textattack.metrics.metric.Metric

attack_accuracy_perc()[source]
attack_success_rate_perc()[source]
calculate(results)[source]

Calculates all metrics related to number of succesful, failed and skipped results in an attack.

Parameters

results (AttackResult objects) – Attack results for each instance in dataset

original_accuracy_perc()[source]

Metrics on perturbed words

class textattack.metrics.attack_metrics.words_perturbed.WordsPerturbed[source]

Bases: textattack.metrics.metric.Metric

avg_number_word_perturbed_num()[source]
avg_perturbation_perc()[source]
calculate(results)[source]

Calculates all metrics related to perturbed words in an attack.

Parameters

results (AttackResult objects) – Attack results for each instance in dataset