torcheval.metrics.functional.click_through_rate¶
- torcheval.metrics.functional.click_through_rate(input: Tensor, weights: Tensor | None = None, *, num_tasks: int = 1) Tensor ¶
给定点击事件计算点击率。其类版本为
torcheval.metrics.ClickThroughRate
。- 参数:
input (Tensor) – 表示用户点击(1)或跳过(0)的一系列值,形状为 (num_events) 或 (num_objectives, num_events)。
weights (Tensor, Optional) – 每个事件的权重,张量与 input 形状相同。
num_tasks (int) – 需要加权校准计算的任务数量。默认值为 1。
示例
>>> import torch >>> from torcheval.metrics.functional import click_through_rate >>> input = torch.tensor([0, 1, 0, 1, 1, 0, 0, 1]) >>> click_through_rate(input) tensor(0.5) >>> weights = torch.tensor([1.0, 2.0, 1.0, 2.0, 1.0, 2.0, 1.0, 2.0]) >>> click_through_rate(input, weights) tensor(0.58333) >>> input = torch.tensor([[0, 1, 0, 1], [1, 0, 0, 1]]) >>> weights = torch.tensor([[1.0, 2.0, 1.0, 2.0],[1.0, 2.0, 1.0, 1.0]]) >>> click_through_rate(input, weights, num_tasks=2) tensor([0.6667, 0.4])