add avg feedback (#10509)

in run_on_dataset agg feedback printout
This commit is contained in:
William FH 2023-09-12 14:05:18 -07:00 committed by GitHub
parent f7f3c02585
commit 57e2de2077
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -82,6 +82,8 @@ class TestResult(dict):
_quantiles = df[feedback_cols].quantile( _quantiles = df[feedback_cols].quantile(
quantiles or [0.25, 0.5, 0.75], numeric_only=True quantiles or [0.25, 0.5, 0.75], numeric_only=True
) )
_quantiles.loc["mean"] = df[feedback_cols].mean()
_quantiles.loc["mode"] = df[feedback_cols].mode().iloc[0]
return _quantiles.transpose() return _quantiles.transpose()
def to_dataframe(self) -> pd.DataFrame: def to_dataframe(self) -> pd.DataFrame:

View File

@ -1,6 +1,7 @@
"""Generic utility functions.""" """Generic utility functions."""
import contextlib import contextlib
import datetime import datetime
import functools
import importlib import importlib
import warnings import warnings
from importlib.metadata import version from importlib.metadata import version
@ -14,7 +15,8 @@ def xor_args(*arg_groups: Tuple[str, ...]) -> Callable:
"""Validate specified keyword args are mutually exclusive.""" """Validate specified keyword args are mutually exclusive."""
def decorator(func: Callable) -> Callable: def decorator(func: Callable) -> Callable:
def wrapper(*args: Any, **kwargs: Any) -> Callable: @functools.wraps(func)
def wrapper(*args: Any, **kwargs: Any) -> Any:
"""Validate exactly one arg in each group is not None.""" """Validate exactly one arg in each group is not None."""
counts = [ counts = [
sum(1 for arg in arg_group if kwargs.get(arg) is not None) sum(1 for arg in arg_group if kwargs.get(arg) is not None)