コード例 #1
0
 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
         },
     )
コード例 #2
0
ファイル: test_evaluators.py プロジェクト: zxlzr/pykeen
 def finalize(self) -> MetricResults:  # noqa: D102
     return RankBasedMetricResults(
         mean_rank=self.counter,
         mean_reciprocal_rank=None,
         adjusted_mean_rank=None,
         hits_at_k=dict(),
     )
コード例 #3
0
ファイル: mocks.py プロジェクト: pykeen/pykeen
 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
コード例 #4
0
 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),
             },
         },
     )
コード例 #5
0
ファイル: test_evaluators.py プロジェクト: tgebhart/pykeen
 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(),
     )
コード例 #6
0
ファイル: mocks.py プロジェクト: vishalbelsare/pykeen
 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
         },
     )
コード例 #7
0
 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