Shortcuts

torcheval.metrics.WindowedClickThroughRate

class torcheval.metrics.WindowedClickThroughRate(*, num_tasks: int = 1, max_num_updates: int = 100, enable_lifetime: bool = True, device: device | None = None)

The windowed version of ClickThroughRate that provides both windowed and lifetime values. Windowed value is calculated from the input and target of the last window_size number of update() calls. Lifetime value is calculated from all past input and target of update() calls.

Compute the click through rate given click events. Its functional version is torcheval.metrics.functional.click_through_rate.

Parameters:
  • num_tasks (int) – Number of tasks that need click through rate calculation. Default value is 1.

  • max_num_updates (int) – The max window size that can accommodate the number of updates.

  • enable_lifetime (bool) – A boolean indicator whether to calculate lifetime values.

Examples:

>>> import torch
>>> from torcheval.metrics import WindowedClickThroughRate
>>> metric = WindowedClickThroughRate(max_num_updates=2)
>>> metric.update(torch.tensor([0, 1, 0, 1, 1, 0, 0, 1]))
>>> metric.update(torch.tensor([0, 1, 0, 1, 1, 1, 1, 1]))
>>> metric.update(torch.tensor([0, 1, 0, 1, 0, 0, 0, 1]))
>>> metric.compute()
tensor([0.5625])
__init__(*, num_tasks: int = 1, max_num_updates: int = 100, enable_lifetime: bool = True, device: device | None = None) None

Initialize a metric object and its internal states.

Use self._add_state() to initialize state variables of your metric class. The state variables should be either torch.Tensor, a list of torch.Tensor, a dictionary with torch.Tensor as values, or a deque of torch.Tensor.

Methods

__init__(*[, num_tasks, max_num_updates, ...])

Initialize a metric object and its internal states.

compute()

Return the stacked click through rank scores.

load_state_dict(state_dict[, strict])

Loads metric state variables from state_dict.

merge_state(metrics)

Merge the metric state with its counterparts from other metric instances.

reset()

Reset the metric state variables to their default value.

state_dict()

Save metric state variables in state_dict.

to(device, *args, **kwargs)

Move tensors in metric state variables to device.

update(input[, weights])

Update the metric state with new inputs.

Attributes

device

The last input device of Metric.to().

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources