evalsuite-python 1.4.0__py3-none-any.whl → 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- evalsuite/__init__.py +158 -1
- evalsuite/_bench_metrics.py +118 -1
- evalsuite/agreement.py +8 -0
- evalsuite/api.py +15 -2
- evalsuite/auto_report.py +258 -0
- evalsuite/bayes.py +23 -6
- evalsuite/benchmarks.py +13 -0
- evalsuite/calibration.py +4 -0
- evalsuite/cards.py +54 -9
- evalsuite/cli/main.py +89 -2
- evalsuite/clinical/report.py +4 -0
- evalsuite/comparisons.py +415 -0
- evalsuite/conformal.py +502 -0
- evalsuite/core/exceptions.py +17 -0
- evalsuite/core/result.py +8 -0
- evalsuite/data_quality.py +583 -0
- evalsuite/dataframe.py +123 -0
- evalsuite/drift.py +4 -0
- evalsuite/fairness.py +4 -0
- evalsuite/forecasting.py +4 -0
- evalsuite/harness.py +6 -1
- evalsuite/judging.py +8 -0
- evalsuite/llm_eval.py +630 -0
- evalsuite/multilabel.py +8 -0
- evalsuite/plot.py +92 -0
- evalsuite/rag_report.py +4 -0
- evalsuite/recalibration.py +7 -0
- evalsuite/reclassification.py +366 -0
- evalsuite/reporting.py +4 -0
- evalsuite/stats/_resolve.py +6 -1
- evalsuite/stats/compare.py +4 -0
- evalsuite/stats/paired.py +53 -21
- evalsuite/text/report.py +4 -0
- evalsuite/version.py +1 -1
- evalsuite/vision/detection.py +4 -0
- evalsuite/vision/segmentation.py +4 -0
- evalsuite/workflow.py +305 -0
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/METADATA +21 -8
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/RECORD +43 -35
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/WHEEL +0 -0
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/entry_points.txt +0 -0
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {evalsuite_python-1.4.0.dist-info → evalsuite_python-2.0.0.dist-info}/licenses/LICENSE-APACHE +0 -0
evalsuite/__init__.py
CHANGED
|
@@ -41,6 +41,11 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
41
41
|
from .api import (
|
|
42
42
|
evaluate,
|
|
43
43
|
)
|
|
44
|
+
from .auto_report import (
|
|
45
|
+
AutoReport,
|
|
46
|
+
auto_report,
|
|
47
|
+
detect_columns,
|
|
48
|
+
)
|
|
44
49
|
from .bayes import (
|
|
45
50
|
BayesComparison,
|
|
46
51
|
bayes_compare,
|
|
@@ -101,7 +106,22 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
101
106
|
sensitivity,
|
|
102
107
|
youden_j,
|
|
103
108
|
)
|
|
109
|
+
from .comparisons import (
|
|
110
|
+
NemenyiResult,
|
|
111
|
+
equivalence_test,
|
|
112
|
+
ipw_metric,
|
|
113
|
+
nemenyi_test,
|
|
114
|
+
noninferiority_test,
|
|
115
|
+
)
|
|
116
|
+
from .conformal import (
|
|
117
|
+
ConformalIntervals,
|
|
118
|
+
ConformalSets,
|
|
119
|
+
conformal_classification,
|
|
120
|
+
conformal_quantile,
|
|
121
|
+
conformal_regression,
|
|
122
|
+
)
|
|
104
123
|
from .core.exceptions import (
|
|
124
|
+
EvalSuiteDeprecationWarning,
|
|
105
125
|
EvalSuiteError,
|
|
106
126
|
InputValidationError,
|
|
107
127
|
MetricInputError,
|
|
@@ -119,6 +139,17 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
119
139
|
EvaluationResult,
|
|
120
140
|
MetricResult,
|
|
121
141
|
)
|
|
142
|
+
from .data_quality import (
|
|
143
|
+
DatasetCard,
|
|
144
|
+
LabelIssues,
|
|
145
|
+
LeakageReport,
|
|
146
|
+
dataset_card,
|
|
147
|
+
label_issues,
|
|
148
|
+
leakage_report,
|
|
149
|
+
)
|
|
150
|
+
from .dataframe import (
|
|
151
|
+
register_accessors,
|
|
152
|
+
)
|
|
122
153
|
from .drift import (
|
|
123
154
|
DriftReport,
|
|
124
155
|
drift_report,
|
|
@@ -157,6 +188,17 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
157
188
|
format_multiple_choice,
|
|
158
189
|
load_benchmark,
|
|
159
190
|
)
|
|
191
|
+
from .llm_eval import (
|
|
192
|
+
AgentReport,
|
|
193
|
+
ContaminationReport,
|
|
194
|
+
ConversationReport,
|
|
195
|
+
CostQualityReport,
|
|
196
|
+
agent_report,
|
|
197
|
+
contamination_check,
|
|
198
|
+
conversation_report,
|
|
199
|
+
cost_quality_report,
|
|
200
|
+
run_model,
|
|
201
|
+
)
|
|
160
202
|
from .llmsys import *
|
|
161
203
|
from .monitor import (
|
|
162
204
|
Alert,
|
|
@@ -178,6 +220,12 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
178
220
|
Calibrator,
|
|
179
221
|
recalibrate,
|
|
180
222
|
)
|
|
223
|
+
from .reclassification import (
|
|
224
|
+
ExternalValidation,
|
|
225
|
+
ReclassificationResult,
|
|
226
|
+
external_validation,
|
|
227
|
+
reclassification,
|
|
228
|
+
)
|
|
181
229
|
from .regression import (
|
|
182
230
|
adjusted_r2,
|
|
183
231
|
explained_variance,
|
|
@@ -267,6 +315,15 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
267
315
|
segmentation_confusion,
|
|
268
316
|
segmentation_report,
|
|
269
317
|
)
|
|
318
|
+
from .workflow import (
|
|
319
|
+
check_regression,
|
|
320
|
+
load_history,
|
|
321
|
+
log_to_mlflow,
|
|
322
|
+
log_to_wandb,
|
|
323
|
+
metrics_dict,
|
|
324
|
+
record_history,
|
|
325
|
+
serve,
|
|
326
|
+
)
|
|
270
327
|
|
|
271
328
|
# Submodules available as attributes (``es.stats``, ``es.plot``, ...).
|
|
272
329
|
_SUBMODULES = (
|
|
@@ -334,6 +391,7 @@ _EXPORTS: dict[str, tuple[str, ...]] = {
|
|
|
334
391
|
"youden_j",
|
|
335
392
|
),
|
|
336
393
|
".core.exceptions": (
|
|
394
|
+
"EvalSuiteDeprecationWarning",
|
|
337
395
|
"EvalSuiteError",
|
|
338
396
|
"InputValidationError",
|
|
339
397
|
"MetricInputError",
|
|
@@ -396,6 +454,60 @@ _EXPORTS: dict[str, tuple[str, ...]] = {
|
|
|
396
454
|
"cache_info",
|
|
397
455
|
"clear_cache",
|
|
398
456
|
),
|
|
457
|
+
".auto_report": (
|
|
458
|
+
"AutoReport",
|
|
459
|
+
"auto_report",
|
|
460
|
+
"detect_columns",
|
|
461
|
+
),
|
|
462
|
+
".comparisons": (
|
|
463
|
+
"NemenyiResult",
|
|
464
|
+
"equivalence_test",
|
|
465
|
+
"ipw_metric",
|
|
466
|
+
"nemenyi_test",
|
|
467
|
+
"noninferiority_test",
|
|
468
|
+
),
|
|
469
|
+
".conformal": (
|
|
470
|
+
"ConformalIntervals",
|
|
471
|
+
"ConformalSets",
|
|
472
|
+
"conformal_classification",
|
|
473
|
+
"conformal_quantile",
|
|
474
|
+
"conformal_regression",
|
|
475
|
+
),
|
|
476
|
+
".data_quality": (
|
|
477
|
+
"DatasetCard",
|
|
478
|
+
"LabelIssues",
|
|
479
|
+
"LeakageReport",
|
|
480
|
+
"dataset_card",
|
|
481
|
+
"label_issues",
|
|
482
|
+
"leakage_report",
|
|
483
|
+
),
|
|
484
|
+
".reclassification": (
|
|
485
|
+
"ExternalValidation",
|
|
486
|
+
"ReclassificationResult",
|
|
487
|
+
"external_validation",
|
|
488
|
+
"reclassification",
|
|
489
|
+
),
|
|
490
|
+
".llm_eval": (
|
|
491
|
+
"AgentReport",
|
|
492
|
+
"ContaminationReport",
|
|
493
|
+
"ConversationReport",
|
|
494
|
+
"CostQualityReport",
|
|
495
|
+
"agent_report",
|
|
496
|
+
"contamination_check",
|
|
497
|
+
"conversation_report",
|
|
498
|
+
"cost_quality_report",
|
|
499
|
+
"run_model",
|
|
500
|
+
),
|
|
501
|
+
".dataframe": ("register_accessors",),
|
|
502
|
+
".workflow": (
|
|
503
|
+
"check_regression",
|
|
504
|
+
"load_history",
|
|
505
|
+
"log_to_mlflow",
|
|
506
|
+
"log_to_wandb",
|
|
507
|
+
"metrics_dict",
|
|
508
|
+
"record_history",
|
|
509
|
+
"serve",
|
|
510
|
+
),
|
|
399
511
|
".fairness": (
|
|
400
512
|
"FairnessReport",
|
|
401
513
|
"fairness_report",
|
|
@@ -682,7 +794,10 @@ _LAZY: dict[str, str] = {name: mod for mod, names in _EXPORTS.items() for name i
|
|
|
682
794
|
_LAZY.update({"UpdateInfo": "._update", "check_for_update": "._update", "upgrade": "._update"})
|
|
683
795
|
|
|
684
796
|
__all__ = [
|
|
797
|
+
"EvalSuiteDeprecationWarning",
|
|
798
|
+
"AgentReport",
|
|
685
799
|
"Alert",
|
|
800
|
+
"AutoReport",
|
|
686
801
|
"BENCHMARKS",
|
|
687
802
|
"BayesComparison",
|
|
688
803
|
"BlandAltman",
|
|
@@ -692,29 +807,40 @@ __all__ = [
|
|
|
692
807
|
"ClassificationReport",
|
|
693
808
|
"ComparisonResult",
|
|
694
809
|
"ConfidenceInterval",
|
|
810
|
+
"ConformalIntervals",
|
|
811
|
+
"ConformalSets",
|
|
812
|
+
"ContaminationReport",
|
|
813
|
+
"ConversationReport",
|
|
814
|
+
"CostQualityReport",
|
|
815
|
+
"DatasetCard",
|
|
695
816
|
"DecisionCurve",
|
|
696
817
|
"DetectionReport",
|
|
697
818
|
"DiagnosticReport",
|
|
698
819
|
"DriftReport",
|
|
699
820
|
"EvalSuiteError",
|
|
700
821
|
"EvaluationResult",
|
|
822
|
+
"ExternalValidation",
|
|
701
823
|
"FairnessReport",
|
|
702
824
|
"ForecastReport",
|
|
703
825
|
"ICCForm",
|
|
704
826
|
"ICCResult",
|
|
705
827
|
"InputValidationError",
|
|
706
828
|
"JudgeReport",
|
|
829
|
+
"LabelIssues",
|
|
707
830
|
"Leaderboard",
|
|
831
|
+
"LeakageReport",
|
|
708
832
|
"MetricInfo",
|
|
709
833
|
"MetricInputError",
|
|
710
834
|
"MetricResult",
|
|
711
835
|
"Monitor",
|
|
712
836
|
"MultilabelReport",
|
|
837
|
+
"NemenyiResult",
|
|
713
838
|
"OptionalDependencyError",
|
|
714
839
|
"PII_PATTERNS",
|
|
715
840
|
"PYTHON_KEYWORDS",
|
|
716
841
|
"RAGReport",
|
|
717
842
|
"RankingReport",
|
|
843
|
+
"ReclassificationResult",
|
|
718
844
|
"ReportCard",
|
|
719
845
|
"RubricReport",
|
|
720
846
|
"SampleSize",
|
|
@@ -735,11 +861,13 @@ __all__ = [
|
|
|
735
861
|
"adjusted_r2",
|
|
736
862
|
"adversarial_robustness",
|
|
737
863
|
"agent_cost_per_task",
|
|
864
|
+
"agent_report",
|
|
738
865
|
"answer_correctness",
|
|
739
866
|
"answer_relevance",
|
|
740
867
|
"api_call_success_rate",
|
|
741
868
|
"attack_success_rate",
|
|
742
869
|
"aurc",
|
|
870
|
+
"auto_report",
|
|
743
871
|
"availability",
|
|
744
872
|
"average_precision",
|
|
745
873
|
"average_precision_detection",
|
|
@@ -766,6 +894,7 @@ __all__ = [
|
|
|
766
894
|
"calibration_report",
|
|
767
895
|
"calibration_slope",
|
|
768
896
|
"check_for_update",
|
|
897
|
+
"check_regression",
|
|
769
898
|
"chi_square_test",
|
|
770
899
|
"chrf",
|
|
771
900
|
"cider",
|
|
@@ -787,13 +916,19 @@ __all__ = [
|
|
|
787
916
|
"compression_ratio",
|
|
788
917
|
"concordance_index",
|
|
789
918
|
"confidence_accuracy_correlation",
|
|
919
|
+
"conformal_classification",
|
|
920
|
+
"conformal_quantile",
|
|
921
|
+
"conformal_regression",
|
|
790
922
|
"confusion_matrix",
|
|
791
923
|
"constraint_satisfaction_rate",
|
|
924
|
+
"contamination_check",
|
|
792
925
|
"context_precision",
|
|
793
926
|
"context_recall",
|
|
794
927
|
"context_relevance",
|
|
795
928
|
"context_utilization",
|
|
796
929
|
"contradiction_rate",
|
|
930
|
+
"conversation_report",
|
|
931
|
+
"cost_quality_report",
|
|
797
932
|
"coverage_at_risk",
|
|
798
933
|
"coverage_rate",
|
|
799
934
|
"cramers_v",
|
|
@@ -802,8 +937,10 @@ __all__ = [
|
|
|
802
937
|
"cross_lingual_consistency",
|
|
803
938
|
"crps",
|
|
804
939
|
"cultural_appropriateness",
|
|
940
|
+
"dataset_card",
|
|
805
941
|
"decision_curve",
|
|
806
942
|
"delong_test",
|
|
943
|
+
"detect_columns",
|
|
807
944
|
"detect_pii",
|
|
808
945
|
"detection_pr_curve",
|
|
809
946
|
"detection_report",
|
|
@@ -818,6 +955,7 @@ __all__ = [
|
|
|
818
955
|
"elo_ratings",
|
|
819
956
|
"embedding_similarity",
|
|
820
957
|
"energy_per_request",
|
|
958
|
+
"equivalence_test",
|
|
821
959
|
"error_rate",
|
|
822
960
|
"evaluate",
|
|
823
961
|
"exact_match",
|
|
@@ -825,6 +963,7 @@ __all__ = [
|
|
|
825
963
|
"expected_calibration_error",
|
|
826
964
|
"explained_variance",
|
|
827
965
|
"exposure",
|
|
966
|
+
"external_validation",
|
|
828
967
|
"extra_content_rate",
|
|
829
968
|
"extract_answer",
|
|
830
969
|
"extract_json",
|
|
@@ -861,6 +1000,7 @@ __all__ = [
|
|
|
861
1000
|
"invalid_tool_call_rate",
|
|
862
1001
|
"invariance_violation_rate",
|
|
863
1002
|
"iou",
|
|
1003
|
+
"ipw_metric",
|
|
864
1004
|
"jaccard",
|
|
865
1005
|
"json_schema_compliance",
|
|
866
1006
|
"json_validity",
|
|
@@ -871,17 +1011,22 @@ __all__ = [
|
|
|
871
1011
|
"krippendorff_alpha",
|
|
872
1012
|
"kruskal_wallis_test",
|
|
873
1013
|
"ks_drift",
|
|
1014
|
+
"label_issues",
|
|
874
1015
|
"language_consistency",
|
|
875
1016
|
"language_id_accuracy",
|
|
876
1017
|
"language_parity",
|
|
877
1018
|
"latency_percentiles",
|
|
878
1019
|
"latency_summary",
|
|
879
1020
|
"leaderboard",
|
|
1021
|
+
"leakage_report",
|
|
880
1022
|
"lins_ccc",
|
|
881
1023
|
"list_metrics",
|
|
882
1024
|
"llmsys",
|
|
883
1025
|
"load_benchmark",
|
|
1026
|
+
"load_history",
|
|
884
1027
|
"log_loss",
|
|
1028
|
+
"log_to_mlflow",
|
|
1029
|
+
"log_to_wandb",
|
|
885
1030
|
"lost_in_the_middle",
|
|
886
1031
|
"lr_negative",
|
|
887
1032
|
"lr_positive",
|
|
@@ -902,6 +1047,7 @@ __all__ = [
|
|
|
902
1047
|
"median_absolute_error",
|
|
903
1048
|
"meteor",
|
|
904
1049
|
"metric_info",
|
|
1050
|
+
"metrics_dict",
|
|
905
1051
|
"miou",
|
|
906
1052
|
"model_score",
|
|
907
1053
|
"moverscore",
|
|
@@ -912,8 +1058,10 @@ __all__ = [
|
|
|
912
1058
|
"multilabel_report",
|
|
913
1059
|
"ndcg_at_k",
|
|
914
1060
|
"needle_in_haystack",
|
|
1061
|
+
"nemenyi_test",
|
|
915
1062
|
"net_benefit",
|
|
916
1063
|
"noise_robustness",
|
|
1064
|
+
"noninferiority_test",
|
|
917
1065
|
"normalize_answer",
|
|
918
1066
|
"npv",
|
|
919
1067
|
"ood_accuracy",
|
|
@@ -951,9 +1099,12 @@ __all__ = [
|
|
|
951
1099
|
"recalibrate",
|
|
952
1100
|
"recall",
|
|
953
1101
|
"recall_at_k",
|
|
1102
|
+
"reclassification",
|
|
1103
|
+
"record_history",
|
|
954
1104
|
"recovery_success_rate",
|
|
955
1105
|
"red_team_success_rate",
|
|
956
1106
|
"refusal_rate",
|
|
1107
|
+
"register_accessors",
|
|
957
1108
|
"regression",
|
|
958
1109
|
"report_card",
|
|
959
1110
|
"requests_per_second",
|
|
@@ -977,6 +1128,7 @@ __all__ = [
|
|
|
977
1128
|
"rse",
|
|
978
1129
|
"rubric_report",
|
|
979
1130
|
"rubric_score",
|
|
1131
|
+
"run_model",
|
|
980
1132
|
"runtime_efficiency",
|
|
981
1133
|
"sample_size_auc",
|
|
982
1134
|
"sample_size_mean_difference",
|
|
@@ -990,6 +1142,7 @@ __all__ = [
|
|
|
990
1142
|
"self_preference_bias",
|
|
991
1143
|
"sensitivity",
|
|
992
1144
|
"sentence_bleu",
|
|
1145
|
+
"serve",
|
|
993
1146
|
"shapiro_wilk_test",
|
|
994
1147
|
"smape",
|
|
995
1148
|
"specificity",
|
|
@@ -1041,7 +1194,11 @@ def __getattr__(name: str) -> Any:
|
|
|
1041
1194
|
elif name in _LAZY:
|
|
1042
1195
|
value = getattr(_importlib.import_module(_LAZY[name], __name__), name)
|
|
1043
1196
|
else:
|
|
1044
|
-
|
|
1197
|
+
import difflib
|
|
1198
|
+
|
|
1199
|
+
close = difflib.get_close_matches(name, __all__, n=3, cutoff=0.75)
|
|
1200
|
+
hint = f" Did you mean {', '.join(repr(c) for c in close)}?" if close else ""
|
|
1201
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}.{hint}")
|
|
1045
1202
|
globals()[name] = value # cache: later look-ups are plain attribute access
|
|
1046
1203
|
return value
|
|
1047
1204
|
|
evalsuite/_bench_metrics.py
CHANGED
|
@@ -2068,6 +2068,123 @@ def _llmsys(c: _Cases, n: int, rng: np.random.Generator) -> None:
|
|
|
2068
2068
|
c.add("text.spice", lambda: _f(es.spice(sp_r, sp_c)), "Python stdlib", spice_ref)
|
|
2069
2069
|
|
|
2070
2070
|
|
|
2071
|
+
def _v13(c: _Cases, n: int, rng: np.random.Generator) -> None:
|
|
2072
|
+
"""1.3 / 2.0 functions: recalibration, multi-label, forecasting, agreement, Bayes, conformal, data quality."""
|
|
2073
|
+
import evalsuite as es
|
|
2074
|
+
|
|
2075
|
+
skm = _opt("sklearn.metrics")
|
|
2076
|
+
iso = _opt("sklearn.isotonic")
|
|
2077
|
+
# recalibration
|
|
2078
|
+
p = rng.random(n)
|
|
2079
|
+
y = (rng.random(n) < p**1.5).astype(int)
|
|
2080
|
+
if iso is not None:
|
|
2081
|
+
c.add(
|
|
2082
|
+
"recalibration.isotonic",
|
|
2083
|
+
lambda: es.recalibrate(y, p, method="isotonic")(p),
|
|
2084
|
+
"scikit-learn",
|
|
2085
|
+
lambda: iso.IsotonicRegression(out_of_bounds="clip", y_min=0, y_max=1).fit(p, y).predict(p),
|
|
2086
|
+
)
|
|
2087
|
+
else:
|
|
2088
|
+
c.add("recalibration.isotonic", lambda: es.recalibrate(y, p, method="isotonic")(p))
|
|
2089
|
+
c.add("recalibration.platt", lambda: es.recalibrate(y, p, method="platt")(p))
|
|
2090
|
+
# multi-label (n / 10 examples × 10 labels)
|
|
2091
|
+
m = max(20, n // 10)
|
|
2092
|
+
Y = (rng.random((m, 10)) < 0.3).astype(int)
|
|
2093
|
+
S = np.clip(0.4 * Y + rng.random((m, 10)), 0, 1)
|
|
2094
|
+
if skm is not None:
|
|
2095
|
+
c.add(
|
|
2096
|
+
"multilabel.label_ranking_average_precision",
|
|
2097
|
+
lambda: es.multilabel_report(Y, y_score=S, n_resamples=1)["label_ranking_average_precision"],
|
|
2098
|
+
"scikit-learn",
|
|
2099
|
+
lambda: skm.label_ranking_average_precision_score(Y, S),
|
|
2100
|
+
)
|
|
2101
|
+
c.add(
|
|
2102
|
+
"multilabel.coverage_error",
|
|
2103
|
+
lambda: es.multilabel_report(Y, y_score=S, n_resamples=1)["coverage_error"],
|
|
2104
|
+
"scikit-learn",
|
|
2105
|
+
lambda: skm.coverage_error(Y, S),
|
|
2106
|
+
)
|
|
2107
|
+
# forecasting
|
|
2108
|
+
yt, ya, yb = rng.normal(size=n), rng.normal(size=n), rng.normal(size=n)
|
|
2109
|
+
train = np.cumsum(rng.normal(size=n))
|
|
2110
|
+
c.add(
|
|
2111
|
+
"forecasting.mase",
|
|
2112
|
+
lambda: es.mase(yt, ya, y_train=train, m=1),
|
|
2113
|
+
"NumPy formula",
|
|
2114
|
+
lambda: float(np.mean(np.abs(yt - ya)) / np.mean(np.abs(np.diff(train)))),
|
|
2115
|
+
)
|
|
2116
|
+
ens = yt[:, None] + rng.normal(size=(n, 20))
|
|
2117
|
+
ps = _opt("properscoring")
|
|
2118
|
+
c.add(
|
|
2119
|
+
"forecasting.crps",
|
|
2120
|
+
lambda: es.crps(yt, ensemble=ens),
|
|
2121
|
+
"properscoring" if ps is not None else "",
|
|
2122
|
+
(lambda: float(ps.crps_ensemble(yt, ens).mean())) if ps is not None else None,
|
|
2123
|
+
)
|
|
2124
|
+
c.add("forecasting.diebold_mariano", lambda: es.diebold_mariano(yt, ya, yb, h=1))
|
|
2125
|
+
# agreement
|
|
2126
|
+
ratings = rng.normal(size=(max(10, n // 10), 1)) + rng.normal(0, 0.5, size=(max(10, n // 10), 4))
|
|
2127
|
+
pg = _opt("pingouin")
|
|
2128
|
+
|
|
2129
|
+
def icc_ref() -> Any:
|
|
2130
|
+
import pandas as pd
|
|
2131
|
+
|
|
2132
|
+
r, k = ratings.shape
|
|
2133
|
+
df = pd.DataFrame({"t": np.repeat(np.arange(r), k), "r": np.tile(np.arange(k), r), "s": ratings.ravel()})
|
|
2134
|
+
return pg.intraclass_corr(df, "t", "r", "s")["ICC"].to_numpy()
|
|
2135
|
+
|
|
2136
|
+
c.add(
|
|
2137
|
+
"method_agreement.icc",
|
|
2138
|
+
lambda: [f.value for f in es.icc(ratings).forms],
|
|
2139
|
+
"pingouin" if pg is not None else "",
|
|
2140
|
+
icc_ref if pg is not None else None,
|
|
2141
|
+
)
|
|
2142
|
+
a, b = rng.normal(size=n), rng.normal(size=n)
|
|
2143
|
+
c.add(
|
|
2144
|
+
"method_agreement.bland_altman",
|
|
2145
|
+
lambda: es.bland_altman(a, b).bias,
|
|
2146
|
+
"NumPy formula",
|
|
2147
|
+
lambda: float(np.mean(a - b)),
|
|
2148
|
+
)
|
|
2149
|
+
# Bayesian
|
|
2150
|
+
folds_a, folds_b = rng.normal(0.8, 0.02, 10), rng.normal(0.79, 0.02, 10)
|
|
2151
|
+
bc = _opt("baycomp")
|
|
2152
|
+
c.add(
|
|
2153
|
+
"bayes.correlated_ttest",
|
|
2154
|
+
lambda: [(r := es.bayes_correlated_ttest(folds_a, folds_b, rope=0.01)).p_a_better, r.p_rope, r.p_b_better],
|
|
2155
|
+
"baycomp" if bc is not None else "",
|
|
2156
|
+
(lambda: list(bc.CorrelatedTTest.probs(folds_a, folds_b, rope=0.01, runs=1))) if bc is not None else None,
|
|
2157
|
+
)
|
|
2158
|
+
# conformal
|
|
2159
|
+
k = 5
|
|
2160
|
+
P = rng.dirichlet(np.ones(k), n)
|
|
2161
|
+
yc = np.array([rng.choice(k, p=q) for q in P[: min(n, 2000)]])
|
|
2162
|
+
c.add(
|
|
2163
|
+
"conformal.classification_sets",
|
|
2164
|
+
lambda: es.conformal_classification(yc, P[: yc.size], P, alpha=0.1, method="lac").mean_size,
|
|
2165
|
+
)
|
|
2166
|
+
# data quality
|
|
2167
|
+
cl = _opt("cleanlab.filter")
|
|
2168
|
+
yn = yc.copy()
|
|
2169
|
+
yn[: yc.size // 10] = (yn[: yc.size // 10] + 1) % k
|
|
2170
|
+
c.add(
|
|
2171
|
+
"data_quality.label_issues",
|
|
2172
|
+
lambda: sorted(es.label_issues(yn, P[: yc.size]).indices.tolist()),
|
|
2173
|
+
"cleanlab" if cl is not None else "",
|
|
2174
|
+
(lambda: np.flatnonzero(cl.find_label_issues(yn, P[: yc.size], filter_by="confident_learning")).tolist())
|
|
2175
|
+
if cl is not None
|
|
2176
|
+
else None,
|
|
2177
|
+
)
|
|
2178
|
+
sp = _opt("scikit_posthocs")
|
|
2179
|
+
scores = rng.random((20, 5)) + np.linspace(0, 0.3, 5)
|
|
2180
|
+
c.add(
|
|
2181
|
+
"comparisons.nemenyi",
|
|
2182
|
+
lambda: es.nemenyi_test(scores).p_values.ravel(),
|
|
2183
|
+
"scikit-posthocs" if sp is not None else "",
|
|
2184
|
+
(lambda: sp.posthoc_nemenyi_friedman(scores).to_numpy().ravel()) if sp is not None else None,
|
|
2185
|
+
)
|
|
2186
|
+
|
|
2187
|
+
|
|
2071
2188
|
def _numeric_params(r: Any, keys: tuple[str, ...]) -> list[float]:
|
|
2072
2189
|
return [float(r.params[k]) for k in keys]
|
|
2073
2190
|
|
|
@@ -2075,6 +2192,6 @@ def _numeric_params(r: Any, keys: tuple[str, ...]) -> list[float]:
|
|
|
2075
2192
|
def metric_cases(n: int, rng: np.random.Generator) -> list[Case]:
|
|
2076
2193
|
"""One benchmark case for every registered metric and every statistics function."""
|
|
2077
2194
|
c = _Cases()
|
|
2078
|
-
for build in (_classification, _regression, _clinical, _statistics, _vision, _llm, _llmsys):
|
|
2195
|
+
for build in (_classification, _regression, _clinical, _statistics, _vision, _llm, _llmsys, _v13):
|
|
2079
2196
|
build(c, n, rng)
|
|
2080
2197
|
return sorted(c.rows, key=lambda r: r[0])
|
evalsuite/agreement.py
CHANGED
|
@@ -66,6 +66,10 @@ class ICCResult:
|
|
|
66
66
|
level: float
|
|
67
67
|
anova: dict[str, float] = field(default_factory=dict)
|
|
68
68
|
|
|
69
|
+
def _repr_html_(self) -> str:
|
|
70
|
+
"""Rich display in Jupyter and other notebooks."""
|
|
71
|
+
return str(self.to_html())
|
|
72
|
+
|
|
69
73
|
def __getitem__(self, name: str) -> ICCForm:
|
|
70
74
|
for f in self.forms:
|
|
71
75
|
if f.name.lower() == name.lower():
|
|
@@ -265,6 +269,10 @@ class BlandAltman:
|
|
|
265
269
|
means: np.ndarray = field(repr=False)
|
|
266
270
|
differences: np.ndarray = field(repr=False)
|
|
267
271
|
|
|
272
|
+
def _repr_html_(self) -> str:
|
|
273
|
+
"""Rich display in Jupyter and other notebooks."""
|
|
274
|
+
return str(self.to_html())
|
|
275
|
+
|
|
268
276
|
def summary(self, *, digits: int = 3) -> str:
|
|
269
277
|
d = digits
|
|
270
278
|
pct = f"{self.level * 100:g}%"
|
evalsuite/api.py
CHANGED
|
@@ -23,6 +23,17 @@ __all__ = ["evaluate"]
|
|
|
23
23
|
CtxMetric = Callable[[ClassificationContext], MetricResult]
|
|
24
24
|
|
|
25
25
|
|
|
26
|
+
def _did_you_mean(unknown: Any, known: Any) -> str:
|
|
27
|
+
import difflib
|
|
28
|
+
|
|
29
|
+
tips = []
|
|
30
|
+
for u in unknown:
|
|
31
|
+
close = difflib.get_close_matches(str(u), [str(k) for k in known], n=1, cutoff=0.6)
|
|
32
|
+
if close:
|
|
33
|
+
tips.append(f"{u!r} → {close[0]!r}")
|
|
34
|
+
return f" Did you mean {', '.join(tips)}?" if tips else ""
|
|
35
|
+
|
|
36
|
+
|
|
26
37
|
def _classification_registry(
|
|
27
38
|
average: Optional[str], pos_label: Any, zero_division: ZeroDivision
|
|
28
39
|
) -> dict[str, tuple[CtxMetric, bool]]:
|
|
@@ -270,7 +281,8 @@ def _evaluate_classification(
|
|
|
270
281
|
unknown = [m for m in names if m not in registry]
|
|
271
282
|
if unknown:
|
|
272
283
|
raise InputValidationError(
|
|
273
|
-
f"Unknown classification metric(s): {', '.join(unknown)}.
|
|
284
|
+
f"Unknown classification metric(s): {', '.join(unknown)}.{_did_you_mean(unknown, registry)} "
|
|
285
|
+
f"Available: {', '.join(registry)}."
|
|
274
286
|
)
|
|
275
287
|
out: dict[str, MetricResult] = {}
|
|
276
288
|
for name in names:
|
|
@@ -304,7 +316,8 @@ def _evaluate_regression(
|
|
|
304
316
|
unknown = [m for m in names if m not in _REGRESSION]
|
|
305
317
|
if unknown:
|
|
306
318
|
raise InputValidationError(
|
|
307
|
-
f"Unknown regression metric(s): {', '.join(unknown)}.
|
|
319
|
+
f"Unknown regression metric(s): {', '.join(unknown)}.{_did_you_mean(unknown, _REGRESSION)} "
|
|
320
|
+
f"Available: {', '.join(_REGRESSION)}."
|
|
308
321
|
)
|
|
309
322
|
out: dict[str, MetricResult] = {}
|
|
310
323
|
shared = reg._Inputs(y_true, y_pred, sample_weight) # validate once for every metric
|