逆几何平均排名
- class InverseGeometricMeanRank[来源]
-
逆几何平均排名。
平均排名对应于算术平均数,并且往往更容易受到高排名值的影响。 平均倒数排名对应于调和平均数,并且往往更容易受到低排名值的影响。 剩下的毕达哥拉斯平均数,即几何平均数,位于中心位置,因此可以更好地平衡这些 偏差。因此,逆几何平均排名(IGMR)被定义为:
\[IGMR = \sqrt[\|\mathcal{I}\|]{\prod \limits_{r \in \mathcal{I}} r}\]注意
该指标自其在PyKEEN中实现以来是新颖的,由Max Berrendorf提出
属性摘要
指标是否需要二值化分数
是否存在期望的闭式解
是否存在方差的闭式解
是否在增加,即较大的值更好
返回用于度量结果字典的键。
指标的名称
指标是否需要每个排名任务的候选者数量
支持的排名类型。
指标是否支持权重
此指标的同义词
取值范围
方法总结
__call__(ranks[, num_candidates, weights])评估指标。
expected_value(num_candidates[, ...])计算预期的指标值。
生成额外的 repr,参见。
获取描述。
get_link()从docdata中获取链接。
获取此指标范围的数学表示。
get_sampled_values(num_candidates, num_samples)在采样的排名数组上计算指标。
遍历
extra_repr()的组件。numeric_expected_value(**kwargs)通过求和计算预期的指标值。
numeric_expected_value_with_ci(**kwargs)估计带有置信区间的期望值。
numeric_variance(**kwargs)通过求和计算方差。
numeric_variance_with_ci(**kwargs)估计带有置信区间的方差。
std(num_candidates[, num_samples, weights])计算标准差。
variance(num_candidates[, num_samples, weights])计算方差。
属性文档
- key
返回用于度量结果字典的键。
- supported_rank_types: ClassVar[Collection[Literal['optimistic', 'realistic', 'pessimistic']]] = ('optimistic', 'realistic', 'pessimistic')
支持的排名类型。大多数情况下等于所有排名类型
- synonyms: ClassVar[Collection[str]] = ('igmr',)
此指标的同义词
- value_range: ClassVar[ValueRange] = ValueRange(lower=0, lower_inclusive=False, upper=1, upper_inclusive=True)
取值范围
方法文档
- __call__(ranks: ndarray, num_candidates: ndarray | None = None, weights: ndarray | None = None) float[来源]
评估指标。
- expected_value(num_candidates: ndarray, num_samples: int | None = None, weights: ndarray | None = None, **kwargs) float
计算预期的指标值。
期望值是在假设每个个体排名遵循离散均匀分布 \(\mathcal{U}\left(1, N_i\right)\) 的情况下计算的,其中 \(N_i\) 表示排名任务 \(r_i\) 的候选者数量。
- Parameters:
num_candidates (ndarray) – 每个单独排名计算的候选数量
num_samples (int | None) – 用于模拟的样本数量,如果没有实现闭式期望值
weights (ndarray | None) – 形状: s 各个排名任务的权重
kwargs – 如果没有闭式解可用,则传递给
get_sampled_values()的额外基于关键字的参数
- Returns:
该指标的期望值
- Raises:
NoClosedFormError – 如果未实现闭式期望且未给出样本数量,则抛出此错误
- Return type:
注意
如果可用,优先选择解析解,但会回退到通过求和进行数值估计,参见
RankBasedMetric.numeric_expected_value()。
- get_sampled_values(num_candidates: ndarray, num_samples: int, weights: ndarray | None = None, generator: Generator | None = None, memory_intense: bool = True) ndarray
在采样的排名数组上计算指标。
- iter_extra_repr() Iterable[str]
遍历
extra_repr()的组件。此方法通常被重写。一个常见的模式是
def iter_extra_repr(self) -> Iterable[str]: yield from super().iter_extra_repr() yield "<key1>=<value1>" yield "<key2>=<value2>"
- Returns:
一个可迭代的
extra_repr()的各个组件- Return type:
- numeric_expected_value(**kwargs) float
通过求和计算预期的指标值。
期望值是在假设每个个体排名遵循离散均匀分布\(\mathcal{U}\left(1, N_i\right)\)的情况下计算的,其中\(N_i\)表示排名任务\(r_i\)的候选者数量。
- Parameters:
kwargs – 传递给
get_sampled_values()的基于关键字的参数- Returns:
该指标的估计期望值
- Return type:
警告
根据指标的不同,估计可能不太准确且收敛缓慢,参见 https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_discrete.expect.html
- numeric_variance(**kwargs) float
通过求和计算方差。
方差的计算基于每个个体排名遵循离散均匀分布的假设 \(\mathcal{U}\left(1, N_i\right)\),其中 \(N_i\) 表示排名任务 \(r_i\) 的候选者数量。
- Parameters:
kwargs – 传递给
get_sampled_values()的基于关键字的参数- Returns:
此指标的估计方差
- Return type:
警告
根据指标的不同,估计可能不太准确且收敛缓慢,参见 https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_discrete.expect.html
- std(num_candidates: ndarray, num_samples: int | None = None, weights: ndarray | None = None, **kwargs) float
计算标准差。
- Parameters:
num_candidates (ndarray) – 每个单独排名计算的候选数量
num_samples (int | None) – 用于模拟的样本数量,如果没有实现闭式期望值
weights (ndarray | None) – 形状: s 各个排名任务的权重
kwargs – 传递给
variance()的额外基于关键字的参数,
- Returns:
该指标的标准差(即方差的平方根)
- Return type:
有关详细解释,请参见
RankBasedMetric.variance()。
- variance(num_candidates: ndarray, num_samples: int | None = None, weights: ndarray | None = None, **kwargs) float
计算方差。
方差的计算基于每个个体排名遵循离散均匀分布的假设 \(\mathcal{U}\left(1, N_i\right)\),其中 \(N_i\) 表示排名任务 \(r_i\) 的候选者数量。
- Parameters:
num_candidates (ndarray) – 每个单独排名计算的候选数量
num_samples (int | None) – 用于模拟的样本数量,如果没有实现闭式期望值
weights (ndarray | None) – 形状: s 各个排名任务的权重
kwargs – 如果没有闭式解可用,则传递给
get_sampled_values()的额外基于关键字的参数
- Returns:
该指标的方差
- Raises:
NoClosedFormError – 如果没有实现闭式方差并且没有给出样本数量,则引发此错误
- Return type:
注意
如果可用,优先选择解析解,但会回退到通过求和进行数值估计,参见
RankBasedMetric.numeric_variance()。