pydantic_evals.reporting
ReportCase
dataclass
Bases: Generic[InputsT, OutputT, MetadataT]
A single case in an evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
metadata
instance-attribute
metadata: MetadataT | None
Any metadata associated with the case, from Case.metadata
.
expected_output
instance-attribute
expected_output: OutputT | None
The expected output of the task, from Case.expected_output
.
output
instance-attribute
output: OutputT
The output of the task execution.
ReportCaseAggregate
Bases: BaseModel
A synthetic case that summarizes a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 143 144 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 |
|
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
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 143 144 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 |
|
EvaluationReport
dataclass
Bases: Generic[InputsT, OutputT, MetadataT]
A report of the results of evaluating a model on a set of cases.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 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 |
|
cases
instance-attribute
cases: list[ReportCase[InputsT, OutputT, MetadataT]]
The cases in the report.
failures
class-attribute
instance-attribute
The failures in the report. These are cases where task execution raised an exception.
print(
width: int | None = None,
baseline: (
EvaluationReport[InputsT, OutputT, MetadataT] | None
) = None,
*,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: bool = False,
include_output: bool = False,
include_durations: bool = True,
include_total_duration: bool = False,
include_removed_cases: bool = False,
include_averages: bool = True,
include_errors: bool = True,
include_error_stacktrace: bool = False,
input_config: RenderValueConfig | None = None,
metadata_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,
include_reasons: bool = False
)
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
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 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
console_table
console_table(
baseline: (
EvaluationReport[InputsT, OutputT, MetadataT] | None
) = None,
*,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: 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,
metadata_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,
include_reasons: bool = False
) -> 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
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 |
|
failures_table
failures_table(
*,
include_input: bool = False,
include_metadata: bool = False,
include_expected_output: bool = False,
include_error_message: bool = True,
include_error_stacktrace: bool = True,
input_config: RenderValueConfig | None = None,
metadata_config: RenderValueConfig | None = None
) -> Table
Return a table containing the failures in this report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
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 |
|
__str__
__str__() -> str
Return a string representation of the report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
341 342 343 344 345 346 |
|
RenderValueConfig
Bases: TypedDict
A configuration for rendering a values in an Evaluation report.
Source code in pydantic_evals/pydantic_evals/reporting/__init__.py
352 353 354 355 356 357 358 |
|
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
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 |
|
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
977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 |
|