评估文档
主要类
并获得增强的文档体验
开始使用
主要类
EvaluationModuleInfo
基类 EvaluationModuleInfo
为子类 MetricInfo
、ComparisonInfo
和 MeasurementInfo
实现了逻辑。
class evaluate.EvaluationModuleInfo
< source >( description: str citation: str features: typing.Union[datasets.features.features.Features, typing.List[datasets.features.features.Features]] inputs_description: str = <factory> homepage: str = <factory> license: str = <factory> codebase_urls: typing.List[str] = <factory> reference_urls: typing.List[str] = <factory> streamable: bool = False format: typing.Optional[str] = None module_type: str = 'metric' module_name: typing.Optional[str] = None config_name: typing.Optional[str] = None experiment_id: typing.Optional[str] = None )
用于存储关于评估信息的基类,用于 MetricInfo
、ComparisonInfo
和 MeasurementInfo
。
EvaluationModuleInfo
文档化一个评估,包括其名称、版本和特性。有关完整列表,请参阅构造函数参数和属性。
注意:并非所有字段在构造时都已知,可能会在以后更新。
从 metric_info_dir
中的 JSON 文件创建 EvaluationModuleInfo。
将 EvaluationModuleInfo
以 JSON 格式写入 metric_info_dir
。同时将许可证单独保存在 LICENCE 中。
class evaluate.MetricInfo
< source >( description: str citation: str features: typing.Union[datasets.features.features.Features, typing.List[datasets.features.features.Features]] inputs_description: str = <factory> homepage: str = <factory> license: str = <factory> codebase_urls: typing.List[str] = <factory> reference_urls: typing.List[str] = <factory> streamable: bool = False format: typing.Optional[str] = None module_type: str = 'metric' module_name: typing.Optional[str] = None config_name: typing.Optional[str] = None experiment_id: typing.Optional[str] = None )
关于指标的信息。
EvaluationModuleInfo
文档化一个指标,包括其名称、版本和特性。有关完整列表,请参阅构造函数参数和属性。
注意:并非所有字段在构造时都已知,可能会在以后更新。
class evaluate.ComparisonInfo
< source >( description: str citation: str features: typing.Union[datasets.features.features.Features, typing.List[datasets.features.features.Features]] inputs_description: str = <factory> homepage: str = <factory> license: str = <factory> codebase_urls: typing.List[str] = <factory> reference_urls: typing.List[str] = <factory> streamable: bool = False format: typing.Optional[str] = None module_type: str = 'comparison' module_name: typing.Optional[str] = None config_name: typing.Optional[str] = None experiment_id: typing.Optional[str] = None )
关于比较的信息。
EvaluationModuleInfo
文档化一个比较,包括其名称、版本和特性。有关完整列表,请参阅构造函数参数和属性。
注意:并非所有字段在构造时都已知,可能会在以后更新。
class evaluate.MeasurementInfo
< source >( description: str citation: str features: typing.Union[datasets.features.features.Features, typing.List[datasets.features.features.Features]] inputs_description: str = <factory> homepage: str = <factory> license: str = <factory> codebase_urls: typing.List[str] = <factory> reference_urls: typing.List[str] = <factory> streamable: bool = False format: typing.Optional[str] = None module_type: str = 'measurement' module_name: typing.Optional[str] = None config_name: typing.Optional[str] = None experiment_id: typing.Optional[str] = None )
关于测量的信息。
EvaluationModuleInfo
文档化一个测量,包括其名称、版本和特性。有关完整列表,请参阅构造函数参数和属性。
注意:并非所有字段在构造时都已知,可能会在以后更新。
EvaluationModule
基类 EvaluationModule
为子类 Metric
、Comparison
和 Measurement
实现了逻辑。
class evaluate.EvaluationModule
< source >( config_name: typing.Optional[str] = None keep_in_memory: bool = False cache_dir: typing.Optional[str] = None num_process: int = 1 process_id: int = 0 seed: typing.Optional[int] = None experiment_id: typing.Optional[str] = None hash: str = None max_concurrent_cache_files: int = 10000 timeout: typing.Union[int, float] = 100 **kwargs )
参数
- config_name (
str
) — 这用于定义模块计算脚本特定的哈希值,并防止在修改模块加载脚本时覆盖模块的数据。 - keep_in_memory (
bool
) — 将所有预测和引用保存在内存中。在分布式设置中不可用。 - cache_dir (
str
) — 临时预测/引用数据将存储在其中的目录路径。在分布式设置中,数据目录应位于共享文件系统上。 - num_process (
int
) — 指定分布式设置中的节点总数。这对于在分布式设置中计算模块非常有用(特别是像 F1 这样的非累加性模块)。 - process_id (
int
) — 指定分布式设置中当前进程的 ID(介于 0 和 num_process-1 之间)。这对于在分布式设置中计算模块非常有用(特别是像 F1 这样的非累加性指标)。 - seed (
int
, 可选) — 如果指定,这将在运行 evaluate.EvaluationModule.compute() 时临时设置 numpy 的随机种子。 - experiment_id (
str
) — 特定的实验 ID。如果多个分布式评估共享相同的文件系统,则使用此 ID。这对于在分布式设置中计算模块非常有用(特别是像 F1 这样的非累加性指标)。 - hash (
str
) — 用于根据哈希文件内容识别评估模块。 - max_concurrent_cache_files (
int
) — 最大并发模块缓存文件数(默认为 10000)。 - timeout (
Union[int, float]
) — 分布式设置同步的超时时间,单位为秒。
EvaluationModule 是度量、比较和测量的基类和通用 API。
add
< source >( prediction = None reference = None **kwargs )
为评估模块的堆栈添加一个预测和一个参考答案。
add_batch
< source >( predictions = None references = None **kwargs )
为评估模块的堆栈添加一批预测和参考答案。
download_and_prepare
< source >( download_config: typing.Optional[evaluate.utils.file_utils.DownloadConfig] = None dl_manager: typing.Optional[datasets.download.download_manager.DownloadManager] = None )
下载并准备数据集以进行读取。
class evaluate.Metric
< source >( config_name: typing.Optional[str] = None keep_in_memory: bool = False cache_dir: typing.Optional[str] = None num_process: int = 1 process_id: int = 0 seed: typing.Optional[int] = None experiment_id: typing.Optional[str] = None hash: str = None max_concurrent_cache_files: int = 10000 timeout: typing.Union[int, float] = 100 **kwargs )
参数
- config_name (
str
) — 此参数用于定义特定于度量计算脚本的哈希值,并防止在修改度量加载脚本时覆盖度量的数据。 - keep_in_memory (
bool
) — 将所有预测和参考答案保存在内存中。在分布式设置中不可用。 - cache_dir (
str
) — 临时预测/参考数据将存储在其中的目录路径。在分布式设置中,数据目录应位于共享文件系统上。 - num_process (
int
) — 指定分布式设置中的节点总数。这对于在分布式设置中计算指标(特别是像 F1 这样的非加性指标)非常有用。 - process_id (
int
) — 指定分布式设置中当前进程的 ID(介于 0 和 num_process-1 之间)。这对于在分布式设置中计算指标(特别是像 F1 这样的非加性指标)非常有用。 - seed (
int
, 可选) — 如果指定,这将在运行 evaluate.Metric.compute() 时临时设置 numpy 的随机种子。 - experiment_id (
str
) — 特定的实验 ID。如果多个分布式评估共享同一文件系统,则使用此参数。这对于在分布式设置中计算指标(特别是像 F1 这样的非加性指标)非常有用。 - max_concurrent_cache_files (
int
) — 最大并发度量缓存文件数(默认为 10000)。 - timeout (
Union[int, float]
) — 分布式设置同步的超时时间,单位为秒。
Metric 是所有度量的基类和通用 API。
class evaluate.Comparison
< source >( config_name: typing.Optional[str] = None keep_in_memory: bool = False cache_dir: typing.Optional[str] = None num_process: int = 1 process_id: int = 0 seed: typing.Optional[int] = None experiment_id: typing.Optional[str] = None hash: str = None max_concurrent_cache_files: int = 10000 timeout: typing.Union[int, float] = 100 **kwargs )
参数
- config_name (
str
) — 此参数用于定义特定于比较计算脚本的哈希值,并防止在修改比较加载脚本时覆盖比较的数据。 - keep_in_memory (
bool
) — 将所有预测和参考答案保存在内存中。在分布式设置中不可用。 - cache_dir (
str
) — 临时预测/参考数据将存储在其中的目录路径。在分布式设置中,数据目录应位于共享文件系统上。 - num_process (
int
) — 指定分布式设置中的节点总数。这对于在分布式设置中计算比较(尤其是非加性比较)非常有用。 - process_id (
int
) — 指定分布式设置中当前进程的 ID(介于 0 和 num_process-1 之间)。这对于在分布式设置中计算比较(尤其是非加性比较)非常有用。 - seed (
int
, 可选) — 如果指定,这将在运行 evaluate.Comparison.compute() 时临时设置 numpy 的随机种子。 - experiment_id (
str
) — 一个特定的实验 ID。如果多个分布式评估共享同一个文件系统,则使用此 ID。这对于在分布式设置中计算比较(尤其是非加性比较)非常有用。 - max_concurrent_cache_files (
int
) — 最大并发比较缓存文件数(默认为 10000)。 - timeout (
Union[int, float]
) — 分布式设置同步的超时时间,以秒为单位。
Comparison 是所有比较的基类和通用 API。
class evaluate.Measurement
< source >( config_name: typing.Optional[str] = None keep_in_memory: bool = False cache_dir: typing.Optional[str] = None num_process: int = 1 process_id: int = 0 seed: typing.Optional[int] = None experiment_id: typing.Optional[str] = None hash: str = None max_concurrent_cache_files: int = 10000 timeout: typing.Union[int, float] = 100 **kwargs )
参数
- config_name (
str
) — 这用于定义特定于度量计算脚本的哈希值,并防止在修改度量加载脚本时覆盖度量的数据。 - keep_in_memory (
bool
) — 将所有预测和参考保留在内存中。在分布式设置中不可用。 - cache_dir (
str
) — 临时预测/参考数据将存储在其中的目录路径。在分布式设置中,数据目录应位于共享文件系统上。 - num_process (
int
) — 指定分布式设置中的节点总数。这对于在分布式设置中计算度量(尤其是非加性度量)非常有用。 - process_id (
int
) — 指定分布式设置中当前进程的 ID(介于 0 和 num_process-1 之间)。这对于在分布式设置中计算度量(尤其是非加性度量)非常有用。 - seed (
int
, 可选) — 如果指定,这将在运行 evaluate.Measurement.compute() 时临时设置 numpy 的随机种子。 - experiment_id (
str
) — 一个特定的实验 ID。如果多个分布式评估共享同一个文件系统,则使用此 ID。这对于在分布式设置中计算度量(尤其是非加性度量)非常有用。 - max_concurrent_cache_files (
int
) — 最大并发度量缓存文件数(默认为 10000)。 - timeout (
Union[int, float]
) — 分布式设置同步的超时时间,以秒为单位。
Measurement 是所有度量的基类和通用 API。
CombinedEvaluations
combine
函数允许将多个 EvaluationModule
组合成一个 CombinedEvaluations
。
evaluate.combine
< source >( evaluations force_prefix = False )
将多个指标、比较或度量组合成单个 CombinedEvaluations 对象,该对象可以像单个评估模块一样使用。
如果两个分数具有相同的名称,则它们将以其模块名称作为前缀。如果两个模块具有相同的名称,请使用字典为它们提供不同的名称,否则将在前缀后附加整数 ID。
示例
clf_metrics = combine([“accuracy”, “f1”, “precision”,“recall”]) clf_metrics.compute(predictions=[0,1], references=[1,1]) {‘accuracy’: 0.5, ‘f1’: 0.66, ‘precision’: 1.0, ‘recall’: 0.5}
add
< source >( prediction = None reference = None **kwargs )
为每个评估模块的堆栈添加一个预测结果和一个参考结果。
add_batch
< source >( predictions = None references = None **kwargs )
为每个评估模块的堆栈添加一批预测结果和参考结果。