torcheval.metrics.functional.click_through_rate¶
- torcheval.metrics.functional.click_through_rate(input: Tensor, weights: Tensor | None = None, *, num_tasks: int = 1) Tensor ¶
Compute the click through rate given a click events. Its class version is
torcheval.metrics.ClickThroughRate
.- Parameters:
input (Tensor) – Series of values representing user click (1) or skip (0) of shape (num_events) or (num_objectives, num_events).
weights (Tensor, Optional) – Weights for each event, tensor with the same shape as input.
num_tasks (int) – Number of tasks that need weighted_calibration calculation. Default value is 1.
Examples:
>>> 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])