def finalize(self) -> MetricResults: # noqa: D102 hits = next(self.losses_iter) return RankBasedMetricResults( mean_rank={ side: { rank_type: 10 for rank_type in RANK_TYPES } for side in SIDES }, mean_reciprocal_rank={ side: { rank_type: 1.0 for rank_type in RANK_TYPES } for side in SIDES }, adjusted_mean_rank={ side: 1.0 for side in SIDES }, hits_at_k={ side: { rank_type: { 10: hits, } for rank_type in RANK_TYPES } for side in SIDES }, )
def finalize(self) -> MetricResults: # noqa: D102 return RankBasedMetricResults( mean_rank=self.counter, mean_reciprocal_rank=None, adjusted_mean_rank=None, hits_at_k=dict(), )
def finalize(self) -> MetricResults: # noqa: D102 result = RankBasedMetricResults.create_random(self.random_state) assert self.values_iter is not None if self.key not in result.data: raise KeyError(self.key) result.data[self.key] = next(self.values_iter) return result
def finalize(self) -> MetricResults: # noqa: D102 return RankBasedMetricResults( mean_rank=None, mean_reciprocal_rank=None, adjusted_mean_rank=None, hits_at_k={ RANK_AVERAGE: { 10: next(self.losses_iter), }, }, )
def finalize(self) -> MetricResults: # noqa: D102 return RankBasedMetricResults( arithmetic_mean_rank=self.counter, geometric_mean_rank=None, harmonic_mean_rank=None, median_rank=None, inverse_arithmetic_mean_rank=None, inverse_geometric_mean_rank=None, inverse_harmonic_mean_rank=None, inverse_median_rank=None, rank_std=None, rank_var=None, rank_mad=None, adjusted_arithmetic_mean_rank=None, adjusted_arithmetic_mean_rank_index=None, hits_at_k=dict(), )
def finalize(self) -> MetricResults: # noqa: D102 hits = next(self.losses_iter) dummy_1 = { side: {rank_type: 10.0 for rank_type in RANK_TYPES} for side in SIDES } dummy_2 = { side: {rank_type: 1.0 for rank_type in RANK_TYPES} for side in SIDES } return RankBasedMetricResults( arithmetic_mean_rank=dummy_1, geometric_mean_rank=dummy_1, harmonic_mean_rank=dummy_1, median_rank=dummy_1, inverse_arithmetic_mean_rank=dummy_2, inverse_harmonic_mean_rank=dummy_2, inverse_geometric_mean_rank=dummy_2, inverse_median_rank=dummy_2, adjusted_arithmetic_mean_rank=dummy_2, adjusted_arithmetic_mean_rank_index={ side: { RANK_REALISTIC: 0.0, } for side in SIDES }, rank_count={ side: {rank_type: 1 for rank_type in RANK_TYPES} for side in SIDES }, rank_std=dummy_1, rank_var=dummy_1, rank_mad=dummy_1, hits_at_k={ side: {rank_type: { 10: hits, } for rank_type in RANK_TYPES} for side in SIDES }, )
def _pre_instantiation_hook( self, kwargs: MutableMapping[str, Any]) -> MutableMapping[str, Any]: kwargs = super()._pre_instantiation_hook(kwargs=kwargs) kwargs["data"] = RankBasedMetricResults.create_random().data return kwargs