Shortcuts

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

Parameters:
  • input (Tensor) – 表示用户点击(1)或跳过(0)的一系列值,形状为 (num_events) 或 (num_objectives, num_events)。

  • weights (Tensor, Optional) – 每个事件的权重,与输入形状相同的张量。

  • 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])