evalsuite-python 1.3.5__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 +174 -1
- evalsuite/_bench_metrics.py +118 -1
- evalsuite/_update.py +40 -10
- evalsuite/agreement.py +10 -1
- evalsuite/api.py +15 -2
- evalsuite/auto_report.py +258 -0
- evalsuite/bayes.py +26 -8
- evalsuite/benchmarks.py +13 -0
- evalsuite/cache.py +258 -0
- evalsuite/calibration.py +4 -0
- evalsuite/cards.py +55 -10
- evalsuite/cli/main.py +126 -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/registry.py +4 -0
- evalsuite/core/result.py +8 -0
- evalsuite/core/validation.py +21 -1
- 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_benchmarks.py +8 -1
- evalsuite/llm_eval.py +630 -0
- evalsuite/llmsys/longcontext.py +4 -3
- evalsuite/llmsys/multilingual.py +2 -1
- evalsuite/llmsys/robustness.py +4 -6
- evalsuite/llmsys/safety.py +2 -1
- evalsuite/monitor.py +5 -4
- evalsuite/multilabel.py +12 -0
- evalsuite/plot.py +92 -0
- evalsuite/rag_report.py +4 -0
- evalsuite/recalibration.py +11 -3
- evalsuite/reclassification.py +366 -0
- evalsuite/reporting.py +4 -0
- evalsuite/stats/_resolve.py +6 -1
- evalsuite/stats/compare.py +14 -3
- evalsuite/stats/effect.py +5 -5
- evalsuite/stats/hypothesis.py +3 -3
- evalsuite/stats/intervals.py +2 -2
- evalsuite/stats/paired.py +53 -21
- evalsuite/stats/planning.py +9 -2
- evalsuite/survival.py +2 -1
- evalsuite/text/factuality.py +4 -3
- evalsuite/text/generation.py +2 -1
- evalsuite/text/judge.py +3 -2
- evalsuite/text/qa.py +2 -0
- evalsuite/text/rag.py +2 -1
- evalsuite/text/report.py +4 -0
- evalsuite/text/semantic.py +3 -2
- evalsuite/text/structured.py +3 -1
- evalsuite/version.py +1 -1
- evalsuite/vision/detection.py +7 -2
- evalsuite/vision/segmentation.py +4 -0
- evalsuite/workflow.py +305 -0
- {evalsuite_python-1.3.5.dist-info → evalsuite_python-2.0.0.dist-info}/METADATA +38 -8
- evalsuite_python-2.0.0.dist-info/RECORD +98 -0
- evalsuite_python-1.3.5.dist-info/RECORD +0 -89
- {evalsuite_python-1.3.5.dist-info → evalsuite_python-2.0.0.dist-info}/WHEEL +0 -0
- {evalsuite_python-1.3.5.dist-info → evalsuite_python-2.0.0.dist-info}/entry_points.txt +0 -0
- {evalsuite_python-1.3.5.dist-info → evalsuite_python-2.0.0.dist-info}/licenses/LICENSE +0 -0
- {evalsuite_python-1.3.5.dist-info → evalsuite_python-2.0.0.dist-info}/licenses/LICENSE-APACHE +0 -0
evalsuite/__init__.py
CHANGED
|
@@ -41,11 +41,22 @@ 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,
|
|
47
52
|
bayes_correlated_ttest,
|
|
48
53
|
)
|
|
54
|
+
from .cache import (
|
|
55
|
+
CacheInfo,
|
|
56
|
+
cache_dir,
|
|
57
|
+
cache_info,
|
|
58
|
+
clear_cache,
|
|
59
|
+
)
|
|
49
60
|
from .calibration import (
|
|
50
61
|
CalibrationReport,
|
|
51
62
|
calibration_intercept,
|
|
@@ -95,7 +106,22 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
95
106
|
sensitivity,
|
|
96
107
|
youden_j,
|
|
97
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
|
+
)
|
|
98
123
|
from .core.exceptions import (
|
|
124
|
+
EvalSuiteDeprecationWarning,
|
|
99
125
|
EvalSuiteError,
|
|
100
126
|
InputValidationError,
|
|
101
127
|
MetricInputError,
|
|
@@ -113,6 +139,17 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
113
139
|
EvaluationResult,
|
|
114
140
|
MetricResult,
|
|
115
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
|
+
)
|
|
116
153
|
from .drift import (
|
|
117
154
|
DriftReport,
|
|
118
155
|
drift_report,
|
|
@@ -151,6 +188,17 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
151
188
|
format_multiple_choice,
|
|
152
189
|
load_benchmark,
|
|
153
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
|
+
)
|
|
154
202
|
from .llmsys import *
|
|
155
203
|
from .monitor import (
|
|
156
204
|
Alert,
|
|
@@ -172,6 +220,12 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
172
220
|
Calibrator,
|
|
173
221
|
recalibrate,
|
|
174
222
|
)
|
|
223
|
+
from .reclassification import (
|
|
224
|
+
ExternalValidation,
|
|
225
|
+
ReclassificationResult,
|
|
226
|
+
external_validation,
|
|
227
|
+
reclassification,
|
|
228
|
+
)
|
|
175
229
|
from .regression import (
|
|
176
230
|
adjusted_r2,
|
|
177
231
|
explained_variance,
|
|
@@ -261,6 +315,15 @@ if TYPE_CHECKING: # static analysers and IDEs see the full eager API
|
|
|
261
315
|
segmentation_confusion,
|
|
262
316
|
segmentation_report,
|
|
263
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
|
+
)
|
|
264
327
|
|
|
265
328
|
# Submodules available as attributes (``es.stats``, ``es.plot``, ...).
|
|
266
329
|
_SUBMODULES = (
|
|
@@ -328,6 +391,7 @@ _EXPORTS: dict[str, tuple[str, ...]] = {
|
|
|
328
391
|
"youden_j",
|
|
329
392
|
),
|
|
330
393
|
".core.exceptions": (
|
|
394
|
+
"EvalSuiteDeprecationWarning",
|
|
331
395
|
"EvalSuiteError",
|
|
332
396
|
"InputValidationError",
|
|
333
397
|
"MetricInputError",
|
|
@@ -384,6 +448,66 @@ _EXPORTS: dict[str, tuple[str, ...]] = {
|
|
|
384
448
|
"Calibrator",
|
|
385
449
|
"recalibrate",
|
|
386
450
|
),
|
|
451
|
+
".cache": (
|
|
452
|
+
"CacheInfo",
|
|
453
|
+
"cache_dir",
|
|
454
|
+
"cache_info",
|
|
455
|
+
"clear_cache",
|
|
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
|
+
),
|
|
387
511
|
".fairness": (
|
|
388
512
|
"FairnessReport",
|
|
389
513
|
"fairness_report",
|
|
@@ -670,38 +794,53 @@ _LAZY: dict[str, str] = {name: mod for mod, names in _EXPORTS.items() for name i
|
|
|
670
794
|
_LAZY.update({"UpdateInfo": "._update", "check_for_update": "._update", "upgrade": "._update"})
|
|
671
795
|
|
|
672
796
|
__all__ = [
|
|
797
|
+
"EvalSuiteDeprecationWarning",
|
|
798
|
+
"AgentReport",
|
|
673
799
|
"Alert",
|
|
800
|
+
"AutoReport",
|
|
674
801
|
"BENCHMARKS",
|
|
675
802
|
"BayesComparison",
|
|
676
803
|
"BlandAltman",
|
|
804
|
+
"CacheInfo",
|
|
677
805
|
"CalibrationReport",
|
|
678
806
|
"Calibrator",
|
|
679
807
|
"ClassificationReport",
|
|
680
808
|
"ComparisonResult",
|
|
681
809
|
"ConfidenceInterval",
|
|
810
|
+
"ConformalIntervals",
|
|
811
|
+
"ConformalSets",
|
|
812
|
+
"ContaminationReport",
|
|
813
|
+
"ConversationReport",
|
|
814
|
+
"CostQualityReport",
|
|
815
|
+
"DatasetCard",
|
|
682
816
|
"DecisionCurve",
|
|
683
817
|
"DetectionReport",
|
|
684
818
|
"DiagnosticReport",
|
|
685
819
|
"DriftReport",
|
|
686
820
|
"EvalSuiteError",
|
|
687
821
|
"EvaluationResult",
|
|
822
|
+
"ExternalValidation",
|
|
688
823
|
"FairnessReport",
|
|
689
824
|
"ForecastReport",
|
|
690
825
|
"ICCForm",
|
|
691
826
|
"ICCResult",
|
|
692
827
|
"InputValidationError",
|
|
693
828
|
"JudgeReport",
|
|
829
|
+
"LabelIssues",
|
|
694
830
|
"Leaderboard",
|
|
831
|
+
"LeakageReport",
|
|
695
832
|
"MetricInfo",
|
|
696
833
|
"MetricInputError",
|
|
697
834
|
"MetricResult",
|
|
698
835
|
"Monitor",
|
|
699
836
|
"MultilabelReport",
|
|
837
|
+
"NemenyiResult",
|
|
700
838
|
"OptionalDependencyError",
|
|
701
839
|
"PII_PATTERNS",
|
|
702
840
|
"PYTHON_KEYWORDS",
|
|
703
841
|
"RAGReport",
|
|
704
842
|
"RankingReport",
|
|
843
|
+
"ReclassificationResult",
|
|
705
844
|
"ReportCard",
|
|
706
845
|
"RubricReport",
|
|
707
846
|
"SampleSize",
|
|
@@ -722,11 +861,13 @@ __all__ = [
|
|
|
722
861
|
"adjusted_r2",
|
|
723
862
|
"adversarial_robustness",
|
|
724
863
|
"agent_cost_per_task",
|
|
864
|
+
"agent_report",
|
|
725
865
|
"answer_correctness",
|
|
726
866
|
"answer_relevance",
|
|
727
867
|
"api_call_success_rate",
|
|
728
868
|
"attack_success_rate",
|
|
729
869
|
"aurc",
|
|
870
|
+
"auto_report",
|
|
730
871
|
"availability",
|
|
731
872
|
"average_precision",
|
|
732
873
|
"average_precision_detection",
|
|
@@ -745,12 +886,15 @@ __all__ = [
|
|
|
745
886
|
"bradley_terry",
|
|
746
887
|
"brier_score",
|
|
747
888
|
"brier_score_survival",
|
|
889
|
+
"cache_dir",
|
|
890
|
+
"cache_info",
|
|
748
891
|
"calibration",
|
|
749
892
|
"calibration_curve",
|
|
750
893
|
"calibration_intercept",
|
|
751
894
|
"calibration_report",
|
|
752
895
|
"calibration_slope",
|
|
753
896
|
"check_for_update",
|
|
897
|
+
"check_regression",
|
|
754
898
|
"chi_square_test",
|
|
755
899
|
"chrf",
|
|
756
900
|
"cider",
|
|
@@ -760,6 +904,7 @@ __all__ = [
|
|
|
760
904
|
"claim_verification_accuracy",
|
|
761
905
|
"classification",
|
|
762
906
|
"classification_report",
|
|
907
|
+
"clear_cache",
|
|
763
908
|
"cliffs_delta",
|
|
764
909
|
"clinical",
|
|
765
910
|
"code_complexity",
|
|
@@ -771,13 +916,19 @@ __all__ = [
|
|
|
771
916
|
"compression_ratio",
|
|
772
917
|
"concordance_index",
|
|
773
918
|
"confidence_accuracy_correlation",
|
|
919
|
+
"conformal_classification",
|
|
920
|
+
"conformal_quantile",
|
|
921
|
+
"conformal_regression",
|
|
774
922
|
"confusion_matrix",
|
|
775
923
|
"constraint_satisfaction_rate",
|
|
924
|
+
"contamination_check",
|
|
776
925
|
"context_precision",
|
|
777
926
|
"context_recall",
|
|
778
927
|
"context_relevance",
|
|
779
928
|
"context_utilization",
|
|
780
929
|
"contradiction_rate",
|
|
930
|
+
"conversation_report",
|
|
931
|
+
"cost_quality_report",
|
|
781
932
|
"coverage_at_risk",
|
|
782
933
|
"coverage_rate",
|
|
783
934
|
"cramers_v",
|
|
@@ -786,8 +937,10 @@ __all__ = [
|
|
|
786
937
|
"cross_lingual_consistency",
|
|
787
938
|
"crps",
|
|
788
939
|
"cultural_appropriateness",
|
|
940
|
+
"dataset_card",
|
|
789
941
|
"decision_curve",
|
|
790
942
|
"delong_test",
|
|
943
|
+
"detect_columns",
|
|
791
944
|
"detect_pii",
|
|
792
945
|
"detection_pr_curve",
|
|
793
946
|
"detection_report",
|
|
@@ -802,6 +955,7 @@ __all__ = [
|
|
|
802
955
|
"elo_ratings",
|
|
803
956
|
"embedding_similarity",
|
|
804
957
|
"energy_per_request",
|
|
958
|
+
"equivalence_test",
|
|
805
959
|
"error_rate",
|
|
806
960
|
"evaluate",
|
|
807
961
|
"exact_match",
|
|
@@ -809,6 +963,7 @@ __all__ = [
|
|
|
809
963
|
"expected_calibration_error",
|
|
810
964
|
"explained_variance",
|
|
811
965
|
"exposure",
|
|
966
|
+
"external_validation",
|
|
812
967
|
"extra_content_rate",
|
|
813
968
|
"extract_answer",
|
|
814
969
|
"extract_json",
|
|
@@ -845,6 +1000,7 @@ __all__ = [
|
|
|
845
1000
|
"invalid_tool_call_rate",
|
|
846
1001
|
"invariance_violation_rate",
|
|
847
1002
|
"iou",
|
|
1003
|
+
"ipw_metric",
|
|
848
1004
|
"jaccard",
|
|
849
1005
|
"json_schema_compliance",
|
|
850
1006
|
"json_validity",
|
|
@@ -855,17 +1011,22 @@ __all__ = [
|
|
|
855
1011
|
"krippendorff_alpha",
|
|
856
1012
|
"kruskal_wallis_test",
|
|
857
1013
|
"ks_drift",
|
|
1014
|
+
"label_issues",
|
|
858
1015
|
"language_consistency",
|
|
859
1016
|
"language_id_accuracy",
|
|
860
1017
|
"language_parity",
|
|
861
1018
|
"latency_percentiles",
|
|
862
1019
|
"latency_summary",
|
|
863
1020
|
"leaderboard",
|
|
1021
|
+
"leakage_report",
|
|
864
1022
|
"lins_ccc",
|
|
865
1023
|
"list_metrics",
|
|
866
1024
|
"llmsys",
|
|
867
1025
|
"load_benchmark",
|
|
1026
|
+
"load_history",
|
|
868
1027
|
"log_loss",
|
|
1028
|
+
"log_to_mlflow",
|
|
1029
|
+
"log_to_wandb",
|
|
869
1030
|
"lost_in_the_middle",
|
|
870
1031
|
"lr_negative",
|
|
871
1032
|
"lr_positive",
|
|
@@ -886,6 +1047,7 @@ __all__ = [
|
|
|
886
1047
|
"median_absolute_error",
|
|
887
1048
|
"meteor",
|
|
888
1049
|
"metric_info",
|
|
1050
|
+
"metrics_dict",
|
|
889
1051
|
"miou",
|
|
890
1052
|
"model_score",
|
|
891
1053
|
"moverscore",
|
|
@@ -896,8 +1058,10 @@ __all__ = [
|
|
|
896
1058
|
"multilabel_report",
|
|
897
1059
|
"ndcg_at_k",
|
|
898
1060
|
"needle_in_haystack",
|
|
1061
|
+
"nemenyi_test",
|
|
899
1062
|
"net_benefit",
|
|
900
1063
|
"noise_robustness",
|
|
1064
|
+
"noninferiority_test",
|
|
901
1065
|
"normalize_answer",
|
|
902
1066
|
"npv",
|
|
903
1067
|
"ood_accuracy",
|
|
@@ -935,9 +1099,12 @@ __all__ = [
|
|
|
935
1099
|
"recalibrate",
|
|
936
1100
|
"recall",
|
|
937
1101
|
"recall_at_k",
|
|
1102
|
+
"reclassification",
|
|
1103
|
+
"record_history",
|
|
938
1104
|
"recovery_success_rate",
|
|
939
1105
|
"red_team_success_rate",
|
|
940
1106
|
"refusal_rate",
|
|
1107
|
+
"register_accessors",
|
|
941
1108
|
"regression",
|
|
942
1109
|
"report_card",
|
|
943
1110
|
"requests_per_second",
|
|
@@ -961,6 +1128,7 @@ __all__ = [
|
|
|
961
1128
|
"rse",
|
|
962
1129
|
"rubric_report",
|
|
963
1130
|
"rubric_score",
|
|
1131
|
+
"run_model",
|
|
964
1132
|
"runtime_efficiency",
|
|
965
1133
|
"sample_size_auc",
|
|
966
1134
|
"sample_size_mean_difference",
|
|
@@ -974,6 +1142,7 @@ __all__ = [
|
|
|
974
1142
|
"self_preference_bias",
|
|
975
1143
|
"sensitivity",
|
|
976
1144
|
"sentence_bleu",
|
|
1145
|
+
"serve",
|
|
977
1146
|
"shapiro_wilk_test",
|
|
978
1147
|
"smape",
|
|
979
1148
|
"specificity",
|
|
@@ -1025,7 +1194,11 @@ def __getattr__(name: str) -> Any:
|
|
|
1025
1194
|
elif name in _LAZY:
|
|
1026
1195
|
value = getattr(_importlib.import_module(_LAZY[name], __name__), name)
|
|
1027
1196
|
else:
|
|
1028
|
-
|
|
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}")
|
|
1029
1202
|
globals()[name] = value # cache: later look-ups are plain attribute access
|
|
1030
1203
|
return value
|
|
1031
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/_update.py
CHANGED
|
@@ -68,13 +68,20 @@ def _installed() -> str:
|
|
|
68
68
|
return __version__
|
|
69
69
|
|
|
70
70
|
|
|
71
|
+
def _cache_root() -> Path:
|
|
72
|
+
"""EvalSuite's cache folder (documented in :mod:`evalsuite.cache`); kept here so importing stays light."""
|
|
73
|
+
env = os.environ.get("EVALSUITE_CACHE")
|
|
74
|
+
if env:
|
|
75
|
+
return Path(env).expanduser()
|
|
76
|
+
if os.environ.get("XDG_CACHE_HOME"):
|
|
77
|
+
return Path(os.environ["XDG_CACHE_HOME"]) / "evalsuite"
|
|
78
|
+
if sys.platform == "win32" and os.environ.get("LOCALAPPDATA"):
|
|
79
|
+
return Path(os.environ["LOCALAPPDATA"]) / "evalsuite"
|
|
80
|
+
return Path.home() / ".cache" / "evalsuite"
|
|
81
|
+
|
|
82
|
+
|
|
71
83
|
def _cache_file() -> Path:
|
|
72
|
-
|
|
73
|
-
os.path.join(os.environ.get("LOCALAPPDATA", ""), "evalsuite")
|
|
74
|
-
if sys.platform == "win32" and os.environ.get("LOCALAPPDATA")
|
|
75
|
-
else os.path.join(os.path.expanduser("~"), ".cache")
|
|
76
|
-
)
|
|
77
|
-
return Path(base) / "evalsuite" / "update-check.json"
|
|
84
|
+
return _cache_root() / "update-check.json"
|
|
78
85
|
|
|
79
86
|
|
|
80
87
|
def _read_cache() -> dict[str, Any]:
|
|
@@ -87,9 +94,10 @@ def _read_cache() -> dict[str, Any]:
|
|
|
87
94
|
|
|
88
95
|
def _write_cache(data: dict[str, Any]) -> None:
|
|
89
96
|
try:
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
from .cache import cache_dir
|
|
98
|
+
|
|
99
|
+
cache_dir(create=True)
|
|
100
|
+
_cache_file().write_text(json.dumps(data))
|
|
93
101
|
except OSError:
|
|
94
102
|
pass
|
|
95
103
|
|
|
@@ -148,8 +156,30 @@ def _background_refresh() -> None:
|
|
|
148
156
|
_write_cache(data)
|
|
149
157
|
|
|
150
158
|
|
|
159
|
+
def _clean_in_background() -> None:
|
|
160
|
+
"""Start the automatic cache clearing (evalsuite.cache) in a background thread when it is due (daily)."""
|
|
161
|
+
try:
|
|
162
|
+
root = _cache_root()
|
|
163
|
+
stamp = root / ".last-clean"
|
|
164
|
+
if not (root / ".evalsuite-cache").is_file():
|
|
165
|
+
return
|
|
166
|
+
if stamp.exists() and time.time() - stamp.stat().st_mtime < DAY:
|
|
167
|
+
return
|
|
168
|
+
except OSError:
|
|
169
|
+
return
|
|
170
|
+
|
|
171
|
+
def run() -> None:
|
|
172
|
+
from .cache import auto_clean
|
|
173
|
+
|
|
174
|
+
auto_clean()
|
|
175
|
+
|
|
176
|
+
threading.Thread(target=run, name="evalsuite-cache-clean", daemon=True).start()
|
|
177
|
+
|
|
178
|
+
|
|
151
179
|
def notify_on_import() -> None:
|
|
152
|
-
"""Print the cached notice (at most once a day) and refresh the cache in the background when stale
|
|
180
|
+
"""Print the cached notice (at most once a day) and refresh the cache in the background when stale; also
|
|
181
|
+
start the daily automatic cache clearing when due."""
|
|
182
|
+
_clean_in_background()
|
|
153
183
|
if _disabled():
|
|
154
184
|
return
|
|
155
185
|
data = _read_cache()
|
evalsuite/agreement.py
CHANGED
|
@@ -21,6 +21,7 @@ from typing import Any, Optional
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
|
|
23
23
|
from .core.exceptions import InputValidationError
|
|
24
|
+
from .core.validation import numeric
|
|
24
25
|
|
|
25
26
|
__all__ = ["ICCResult", "ICCForm", "BlandAltman", "icc", "bland_altman", "lins_ccc"]
|
|
26
27
|
|
|
@@ -65,6 +66,10 @@ class ICCResult:
|
|
|
65
66
|
level: float
|
|
66
67
|
anova: dict[str, float] = field(default_factory=dict)
|
|
67
68
|
|
|
69
|
+
def _repr_html_(self) -> str:
|
|
70
|
+
"""Rich display in Jupyter and other notebooks."""
|
|
71
|
+
return str(self.to_html())
|
|
72
|
+
|
|
68
73
|
def __getitem__(self, name: str) -> ICCForm:
|
|
69
74
|
for f in self.forms:
|
|
70
75
|
if f.name.lower() == name.lower():
|
|
@@ -136,7 +141,7 @@ def _table(ratings: Any, subjects: Any, raters: Any) -> np.ndarray:
|
|
|
136
141
|
return x
|
|
137
142
|
if subjects is None or raters is None:
|
|
138
143
|
raise InputValidationError("Long format needs both subjects= and raters=.")
|
|
139
|
-
vals =
|
|
144
|
+
vals = numeric(ratings, "ratings").ravel()
|
|
140
145
|
s = np.asarray(subjects).ravel()
|
|
141
146
|
r = np.asarray(raters).ravel()
|
|
142
147
|
if not (vals.size == s.size == r.size):
|
|
@@ -264,6 +269,10 @@ class BlandAltman:
|
|
|
264
269
|
means: np.ndarray = field(repr=False)
|
|
265
270
|
differences: np.ndarray = field(repr=False)
|
|
266
271
|
|
|
272
|
+
def _repr_html_(self) -> str:
|
|
273
|
+
"""Rich display in Jupyter and other notebooks."""
|
|
274
|
+
return str(self.to_html())
|
|
275
|
+
|
|
267
276
|
def summary(self, *, digits: int = 3) -> str:
|
|
268
277
|
d = digits
|
|
269
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
|