pydantic_evals.reporting
ReportCase
Bases: BaseModel
A single case in an evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
metadata
instance-attribute
metadata: Any
Any metadata associated with the case, from Case.metadata
.
expected_output
instance-attribute
expected_output: Any
The expected output of the task, from Case.expected_output
.
ReportCaseAggregate
Bases: BaseModel
A synthetic case that summarizes a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
average
staticmethod
average(cases: list[ReportCase]) -> ReportCaseAggregate
Produce a synthetic "summary" case by averaging quantitative attributes.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
|
EvaluationReport
Bases: BaseModel
A report of the results of evaluating a model on a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
|
print(
width: int | None = None,
baseline: EvaluationReport | None = None,
include_input: bool = False,
include_output: bool = False,
include_durations: bool = True,
include_total_duration: bool = False,
include_removed_cases: bool = False,
include_averages: bool = True,
input_config: RenderValueConfig | None = None,
output_config: RenderValueConfig | None = None,
score_configs: (
dict[str, RenderNumberConfig] | None
) = None,
label_configs: (
dict[str, RenderValueConfig] | None
) = None,
metric_configs: (
dict[str, RenderNumberConfig] | None
) = None,
duration_config: RenderNumberConfig | None = None,
)
Print this report to the console, optionally comparing it to a baseline report.
If you want more control over the output, use console_table
instead and pass it to rich.Console.print
.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
console_table
console_table(
baseline: EvaluationReport | None = None,
include_input: bool = False,
include_output: bool = False,
include_durations: bool = True,
include_total_duration: bool = False,
include_removed_cases: bool = False,
include_averages: bool = True,
input_config: RenderValueConfig | None = None,
output_config: RenderValueConfig | None = None,
score_configs: (
dict[str, RenderNumberConfig] | None
) = None,
label_configs: (
dict[str, RenderValueConfig] | None
) = None,
metric_configs: (
dict[str, RenderNumberConfig] | None
) = None,
duration_config: RenderNumberConfig | None = None,
) -> Table
Return a table containing the data from this report, or the diff between this report and a baseline report.
Optionally include input and output details.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
|
__str__
__str__() -> str
Return a string representation of the report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
233 234 235 236 237 238 |
|
RenderValueConfig
Bases: TypedDict
A configuration for rendering a values in an Evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
241 242 243 244 245 246 247 |
|
RenderNumberConfig
Bases: TypedDict
A configuration for rendering a particular score or metric in an Evaluation report.
See the implementation of _RenderNumber
for more clarity on how these parameters affect the rendering.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 |
|
value_formatter
instance-attribute
The logic to use for formatting values.
- If not provided, format as ints if all values are ints, otherwise at least one decimal place and at least four significant figures.
- You can also use a custom string format spec, e.g. '{:.3f}'
- You can also use a custom function, e.g. lambda x: f'{x:.3f}'
diff_formatter
instance-attribute
The logic to use for formatting details about the diff.
The strings produced by the value_formatter will always be included in the reports, but the diff_formatter is used to produce additional text about the difference between the old and new values, such as the absolute or relative difference.
- If not provided, format as ints if all values are ints, otherwise at least one decimal place and at least four significant figures, and will include the percentage change.
- You can also use a custom string format spec, e.g. '{:+.3f}'
- You can also use a custom function, e.g. lambda x: f'{x:+.3f}'. If this function returns None, no extra diff text will be added.
- You can also use None to never generate extra diff text.
diff_atol
instance-attribute
diff_atol: float
The absolute tolerance for considering a difference "significant".
A difference is "significant" if abs(new - old) < self.diff_atol + self.diff_rtol * abs(old)
.
If a difference is not significant, it will not have the diff styles applied. Note that we still show both the rendered before and after values in the diff any time they differ, even if the difference is not significant. (If the rendered values are exactly the same, we only show the value once.)
If not provided, use 1e-6.
diff_rtol
instance-attribute
diff_rtol: float
The relative tolerance for considering a difference "significant".
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use 0.001 if all values are ints, otherwise 0.05.
diff_increase_style
instance-attribute
diff_increase_style: str
The style to apply to diffed values that have a significant increase.
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use green for scores and red for metrics. You can also use arbitrary rich
styles, such as "bold red".
diff_decrease_style
instance-attribute
diff_decrease_style: str
The style to apply to diffed values that have significant decrease.
See the description of diff_atol
for more details about what makes a difference "significant".
If not provided, use red for scores and green for metrics. You can also use arbitrary rich
styles, such as "bold red".
EvaluationRenderer
dataclass
A class for rendering an EvalReport or the diff between two EvalReports.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
|