Repository: deepset-ai/haystack

Issue:
`EvaluationRunResult.score_result()` is not documented in API reference
**Is your feature request related to a problem? Please describe.**
`EvaluationRunResult.score_result()` is not documented in the API docs https://docs.haystack.deepset.ai/reference/evaluation-api#evaluationrunresult, it's documented under `BaseEvaluationRunResult.score_report`

**Describe the solution you'd like**
`score_report` method should be documented under `EvaluationRunResult`

**Describe alternatives you've considered**
N/A

**Additional context**
It'd be even better to have a documentation page for this feature



Discussion:
This is expected behaviour, the derived class doesn't have a docstring and `pydoc-markdown` doesn't have a mechanism (like for example sphynx does) to infer the docstring from the base class. I'll fix it by adding the appropriate docstrings to the derived class.

Resolving patch:
diff --git a/haystack/evaluation/__init__.py b/haystack/evaluation/__init__.py
--- a/haystack/evaluation/__init__.py
+++ b/haystack/evaluation/__init__.py
@@ -2,6 +2,7 @@
 #
 # SPDX-License-Identifier: Apache-2.0
 
-from .eval_run_result import BaseEvaluationRunResult, EvaluationRunResult
+from .base import BaseEvaluationRunResult
+from .eval_run_result import EvaluationRunResult
 
 __all__ = ["BaseEvaluationRunResult", "EvaluationRunResult"]
diff --git a/haystack/evaluation/base.py b/haystack/evaluation/base.py
new file mode 100644
--- /dev/null
+++ b/haystack/evaluation/base.py
@@ -0,0 +1,49 @@
+# SPDX-FileCopyrightText: 2022-present deepset GmbH <info@deepset.ai>
+#
+# SPDX-License-Identifier: Apache-2.0
+
+from abc import ABC, abstractmethod
+from typing import List, Optional
+
+from pandas import DataFrame
+
+
+class BaseEvaluationRunResult(ABC):
+    """
+    Represents the results of an evaluation run.
+    """
+
+    @abstractmethod
+    def to_pandas(self) -> "DataFrame":
+        """
+        Creates a Pandas DataFrame containing the scores of each metric for every input sample.
+
+        :returns:
+            Pandas DataFrame with the scores.
+        """
+
+    @abstractmethod
+    def score_report(self) -> "DataFrame":
+        """
+        Transforms the results into a Pandas DataFrame with the aggregated scores for each metric.
+
+        :returns:
+            Pandas DataFrame with the aggregated scores.
+        """
+
+    @abstractmethod
+    def comparative_individual_scores_report(
+        self, other: "BaseEvaluationRunResult", keep_columns: Optional[List[str]] = None
+    ) -> "DataFrame":
+        """
+        Creates a Pandas DataFrame with the scores for each metric in the results of two different evaluation runs.
+
+        The inputs to both evaluation runs is assumed to be the same.
+
+        :param other:
+            Results of another evaluation run to compare with.
+        :param keep_columns:
+            List of common column names to keep from the inputs of the evaluation runs to compare.
+        :returns:
+            Pandas DataFrame with the score comparison.
+        """
diff --git a/haystack/evaluation/eval_run_result.py b/haystack/evaluation/eval_run_result.py
--- a/haystack/evaluation/eval_run_result.py
+++ b/haystack/evaluation/eval_run_result.py
@@ -2,7 +2,6 @@
 #
 # SPDX-License-Identifier: Apache-2.0
 
-from abc import ABC, abstractmethod
 from copy import deepcopy
 from typing import Any, Dict, List, Optional
 from warnings import warn
@@ -10,46 +9,7 @@
 from pandas import DataFrame
 from pandas import concat as pd_concat
 
-
-class BaseEvaluationRunResult(ABC):
-    """
-    Represents the results of an evaluation run.
-    """
-
-    @abstractmethod
-    def to_pandas(self) -> "DataFrame":
-        """
-        Creates a Pandas DataFrame containing the scores of each metric for every input sample.
-
-        :returns:
-            Pandas DataFrame with the scores.
-        """
-
-    @abstractmethod
-    def score_report(self) -> "DataFrame":
-        """
-        Transforms the results into a Pandas DataFrame with the aggregated scores for each metric.
-
-        :returns:
-            Pandas DataFrame with the aggregated scores.
-        """
-
-    @abstractmethod
-    def comparative_individual_scores_report(
-        self, other: "BaseEvaluationRunResult", keep_columns: Optional[List[str]] = None
-    ) -> "DataFrame":
-        """
-        Creates a Pandas DataFrame with the scores for each metric in the results of two different evaluation runs.
-
-        The inputs to both evaluation runs is assumed to be the same.
-
-        :param other:
-            Results of another evaluation run to compare with.
-        :param keep_columns:
-            List of common column names to keep from the inputs of the evaluation runs to compare.
-        :returns:
-            Pandas DataFrame with the score comparison.
-        """
+from .base import BaseEvaluationRunResult
 
 
 class EvaluationRunResult(BaseEvaluationRunResult):
@@ -99,13 +59,25 @@ def __init__(self, run_name: str, inputs: Dict[str, List[Any]], results: Dict[st
                     f"Got {len(outputs['individual_scores'])} but expected {expected_len}."
                 )
 
-    def score_report(self) -> DataFrame:  # noqa: D102
+    def score_report(self) -> DataFrame:
+        """
+        Transforms the results into a Pandas DataFrame with the aggregated scores for each metric.
+
+        :returns:
+            Pandas DataFrame with the aggregated scores.
+        """
         results = {k: v["score"] for k, v in self.results.items()}
         df = DataFrame.from_dict(results, orient="index", columns=["score"]).reset_index()
         df.columns = ["metrics", "score"]
         return df
 
-    def to_pandas(self) -> DataFrame:  # noqa: D102
+    def to_pandas(self) -> DataFrame:
+        """
+        Creates a Pandas DataFrame containing the scores of each metric for every input sample.
+
+        :returns:
+            Pandas DataFrame with the scores.
+        """
         inputs_columns = list(self.inputs.keys())
         inputs_values = list(self.inputs.values())
         inputs_values = list(map(list, zip(*inputs_values)))  # transpose the values
@@ -118,9 +90,21 @@ def to_pandas(self) -> DataFrame:  # noqa: D102
 
         return df_inputs.join(df_scores)
 
-    def comparative_individual_scores_report(  # noqa: D102
+    def comparative_individual_scores_report(
         self, other: "BaseEvaluationRunResult", keep_columns: Optional[List[str]] = None
     ) -> DataFrame:
+        """
+        Creates a Pandas DataFrame with the scores for each metric in the results of two different evaluation runs.
+
+        The inputs to both evaluation runs is assumed to be the same.
+
+        :param other:
+            Results of another evaluation run to compare with.
+        :param keep_columns:
+            List of common column names to keep from the inputs of the evaluation runs to compare.
+        :returns:
+            Pandas DataFrame with the score comparison.
+        """
         if not isinstance(other, EvaluationRunResult):
             raise ValueError("Comparative scores can only be computed between EvaluationRunResults.")
 
@@ -144,9 +128,7 @@ def comparative_individual_scores_report(  # noqa: D102
 
         pipe_b_df.drop(columns=ignore, inplace=True, errors="ignore")
         pipe_b_df.columns = [f"{other_name}_{column}" for column in pipe_b_df.columns]  # type: ignore
-        pipe_a_df.columns = [
-            f"{this_name}_{col}" if col not in ignore else col for col in pipe_a_df.columns
-        ]  # type: ignore
+        pipe_a_df.columns = [f"{this_name}_{col}" if col not in ignore else col for col in pipe_a_df.columns]  # type: ignore
 
         results_df = pd_concat([pipe_a_df, pipe_b_df], axis=1)
         return results_df


Test patch: