指标#
这里我们描述 Argilla 中可用的指标
通用指标#
- argilla.metrics.commons.keywords(name, query=None, size=20)#
计算数据集中关键词的出现分布
- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 [query string syntax](https://docs.argilla.com.cn/en/latest/practical_guides/filter_dataset.html) 的 Elasticsearch 查询
size (int) – 要检索的关键词数量。默认为 20
- 返回:
数据集关键词出现分布
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.commons import keywords >>> summary = keywords(name="example-dataset") >>> summary.visualize() # will plot an histogram with results >>> summary.data # returns the raw result data
- argilla.metrics.commons.records_status(name, query=None)#
计算数据集的记录状态分布
- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 [query string syntax](https://docs.argilla.com.cn/en/latest/practical_guides/filter_dataset.html) 的 Elasticsearch 查询
- 返回:
状态分布指标摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.commons import records_status >>> summary = records_status(name="example-dataset") >>> summary.visualize() # will plot an histogram with results >>> summary.data # returns the raw result data
- argilla.metrics.commons.text_length(name, query=None)#
计算数据集的输入文本长度指标
- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 [query string syntax](https://docs.argilla.com.cn/en/latest/practical_guides/filter_dataset.html) 的 Elasticsearch 查询
- 返回:
文本长度指标摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.commons import text_length >>> summary = text_length(name="example-dataset") >>> summary.visualize() # will plot an histogram with results >>> summary.data # returns the raw result data
文本分类#
- argilla.metrics.text_classification.metrics.f1(name, query=None)#
计算数据集的单标签 f1 指标
- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 [query string syntax](https://docs.argilla.com.cn/en/latest/practical_guides/filter_dataset.html) 的 Elasticsearch 查询
- 返回:
f1 指标摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.text_classification import f1 >>> summary = f1(name="example-dataset") >>> summary.visualize() # will plot a bar chart with results >>> summary.data # returns the raw result data
- argilla.metrics.text_classification.metrics.f1_multilabel(name, query=None)#
计算数据集的多标签 f1 指标
- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 [query string syntax](https://docs.argilla.com.cn/en/latest/practical_guides/filter_dataset.html) 的 Elasticsearch 查询
- 返回:
f1 指标摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.text_classification import f1_multilabel >>> summary = f1_multilabel(name="example-dataset") >>> summary.visualize() # will plot a bar chart with results >>> summary.data # returns the raw result data
Token 分类#
- class argilla.metrics.token_classification.metrics.ComputeFor(value)#
一个枚举。
- argilla.metrics.token_classification.metrics.entity_capitalness(name, query=None, compute_for=ComputeFor.PREDICTIONS)#
计算实体首字母大写形式。实体首字母大写形式将实体提及形状分为 4 组
UPPER
:实体提及中的所有字符均为大写。LOWER
:实体提及中的所有字符均为小写。FIRST
:提及中的第一个字符为大写。MIDDLE
:提及中的第一个字符为小写,且至少有一个其他字符为大写。- 参数:
name (str) – 数据集名称。
query (Optional[str]) – 带有 query string syntax 的 Elasticsearch 查询
compute_for (Union[str, ComputeFor]) – 可以为注释或预测计算指标。接受的值为
Annotations
和Predictions
。默认为Predictions
。
- 返回:
实体首字母大写形式分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import entity_capitalness >>> summary = entity_capitalness(name="example-dataset") >>> summary.visualize()
- argilla.metrics.token_classification.metrics.entity_density(name, query=None, compute_for=ComputeFor.PREDICTIONS, interval=0.005)#
计算实体密度分布。然后在记录级别计算每个提及的实体密度,公式为
mention_length/tokens_length
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
compute_for (Union[str, ComputeFor]) – 可以为注释或预测计算指标。接受的值为
Annotations
和Predictions
。默认为Predictions
。interval (float) – 直方图的间隔。实体密度定义在 0-1 范围内。
- 返回:
实体密度分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import entity_density >>> summary = entity_density(name="example-dataset") >>> summary.visualize()
- argilla.metrics.token_classification.metrics.entity_labels(name, query=None, compute_for=ComputeFor.PREDICTIONS, labels=50)#
计算实体标签分布
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
compute_for (Union[str, ComputeFor]) – 可以为注释或预测计算指标。接受的值为
Annotations
和Predictions
。默认为Predictions
labels (int) – 要检索的顶部实体数量。数字越小,性能越好
- 返回:
实体标签分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import entity_labels >>> summary = entity_labels(name="example-dataset", labels=20) >>> summary.visualize() # will plot a bar chart with results >>> summary.data # The top-20 entity tags
- argilla.metrics.token_classification.metrics.f1(name, query=None)#
基于实体级别计算数据集的 F1 指标。
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
- 返回:
包含精确率、召回率和 F1 分数(平均值和每个标签)的 F1 指标摘要。
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import f1 >>> summary = f1(name="example-dataset") >>> summary.visualize() # will plot three bar charts with the results >>> summary.data # returns the raw result data
以表格形式显示结果
>>> import pandas as pd >>> pd.DataFrame(summary.data.values(), index=summary.data.keys())
- argilla.metrics.token_classification.metrics.mention_length(name, query=None, level='token', compute_for=ComputeFor.PREDICTIONS, interval=1)#
计算提及长度分布(以 token 数量计)。
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
level (str) – 提及长度级别。接受的值为“token”和“char”
compute_for (Union[str, ComputeFor]) – 可以为注释或预测计算指标。接受的值为
Annotations
和Predictions
。默认为Predictions
。interval (int) – 结果直方图的 bins 或 bucket
- 返回:
提及 token 分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import mention_length >>> summary = mention_length(name="example-dataset", interval=2) >>> summary.visualize() # will plot a histogram chart with results >>> summary.data # the raw histogram data with bins of size 2
- argilla.metrics.token_classification.metrics.token_capitalness(name, query=None)#
计算 token 首字母大写形式分布
UPPER
:token 中的所有字符均为大写。LOWER
:token 中的所有字符均为小写。FIRST
:token 中的第一个字符为大写。MIDDLE
:token 中的第一个字符为小写,且至少有一个其他字符为大写。- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
- 返回:
token 长度分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import token_capitalness >>> summary = token_capitalness(name="example-dataset") >>> summary.visualize() # will plot a histogram with results >>> summary.data # The token capitalness distribution
- argilla.metrics.token_classification.metrics.token_frequency(name, query=None, tokens=1000)#
计算多个 token 的 token 频率分布。
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
tokens (int) – 要检索的前 k 个 token 的数量
- 返回:
token 频率分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import token_frequency >>> summary = token_frequency(name="example-dataset", token=50) >>> summary.visualize() # will plot a histogram with results >>> summary.data # the top-50 tokens frequency
- argilla.metrics.token_classification.metrics.token_length(name, query=None)#
计算 token 大小分布(以字符数计)
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
- 返回:
token 长度分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import token_length >>> summary = token_length(name="example-dataset") >>> summary.visualize() # will plot a histogram with results >>> summary.data # The token length distribution
- argilla.metrics.token_classification.metrics.tokens_length(name, query=None, interval=1)#
计算以 token 数量衡量的文本长度分布。
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
interval (int) – 结果直方图的 bins 或 bucket
- 返回:
Token 分布摘要
- 返回类型:
MetricSummary
示例
>>> from argilla.metrics.token_classification import tokens_length >>> summary = tokens_length(name="example-dataset", interval=5) >>> summary.visualize() # will plot a histogram with results >>> summary.data # the raw histogram data with bins of size 5
- argilla.metrics.token_classification.metrics.top_k_mentions(name, query=None, compute_for=ComputeFor.PREDICTIONS, k=100, threshold=2, post_label_filter=None)#
计算数据集中前 k 个提及的一致性。
实体一致性定义给定提及的标签可变性。例如,在整个数据集中被识别为 Cardinal、Person 和 Time 的提及 first,其一致性低于在数据集中被识别为 Person 的提及 Peter。
- 参数:
name (str) – 数据集名称。
query (Optional[str]) –
带有 query string syntax 的 Elasticsearch 查询
compute_for (Union[str, ComputeFor]) – 可以为注释或预测计算指标。接受的值为
Annotations
和Predictions
。默认为Predictions
k (int) – 要检索的提及数量。
threshold (int) – 实体可变性阈值(必须大于或等于 1)。
post_label_filter (Optional[Set[str]]) – 用于过滤结果的标签集。此过滤器可能会影响预期的
mentions (number of) –
- 返回:
前 k 个提及分布摘要
示例
>>> from argilla.metrics.token_classification import top_k_mentions >>> summary = top_k_mentions(name="example-dataset") >>> summary.visualize()