ml4t-diagnostic 0.1.0a1__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.
- ml4t/diagnostic/AGENT.md +25 -0
- ml4t/diagnostic/__init__.py +166 -0
- ml4t/diagnostic/backends/__init__.py +10 -0
- ml4t/diagnostic/backends/adapter.py +192 -0
- ml4t/diagnostic/backends/polars_backend.py +899 -0
- ml4t/diagnostic/caching/__init__.py +40 -0
- ml4t/diagnostic/caching/cache.py +331 -0
- ml4t/diagnostic/caching/decorators.py +131 -0
- ml4t/diagnostic/caching/smart_cache.py +339 -0
- ml4t/diagnostic/config/AGENT.md +24 -0
- ml4t/diagnostic/config/README.md +267 -0
- ml4t/diagnostic/config/__init__.py +219 -0
- ml4t/diagnostic/config/barrier_config.py +277 -0
- ml4t/diagnostic/config/base.py +301 -0
- ml4t/diagnostic/config/event_config.py +148 -0
- ml4t/diagnostic/config/feature_config.py +404 -0
- ml4t/diagnostic/config/multi_signal_config.py +55 -0
- ml4t/diagnostic/config/portfolio_config.py +215 -0
- ml4t/diagnostic/config/report_config.py +391 -0
- ml4t/diagnostic/config/sharpe_config.py +202 -0
- ml4t/diagnostic/config/signal_config.py +206 -0
- ml4t/diagnostic/config/trade_analysis_config.py +310 -0
- ml4t/diagnostic/config/validation.py +279 -0
- ml4t/diagnostic/core/__init__.py +29 -0
- ml4t/diagnostic/core/numba_utils.py +315 -0
- ml4t/diagnostic/core/purging.py +372 -0
- ml4t/diagnostic/core/sampling.py +471 -0
- ml4t/diagnostic/errors/__init__.py +205 -0
- ml4t/diagnostic/evaluation/AGENT.md +26 -0
- ml4t/diagnostic/evaluation/__init__.py +437 -0
- ml4t/diagnostic/evaluation/autocorrelation.py +531 -0
- ml4t/diagnostic/evaluation/barrier_analysis.py +1050 -0
- ml4t/diagnostic/evaluation/binary_metrics.py +910 -0
- ml4t/diagnostic/evaluation/dashboard.py +715 -0
- ml4t/diagnostic/evaluation/diagnostic_plots.py +1037 -0
- ml4t/diagnostic/evaluation/distribution/__init__.py +499 -0
- ml4t/diagnostic/evaluation/distribution/moments.py +299 -0
- ml4t/diagnostic/evaluation/distribution/tails.py +777 -0
- ml4t/diagnostic/evaluation/distribution/tests.py +470 -0
- ml4t/diagnostic/evaluation/drift/__init__.py +139 -0
- ml4t/diagnostic/evaluation/drift/analysis.py +432 -0
- ml4t/diagnostic/evaluation/drift/domain_classifier.py +517 -0
- ml4t/diagnostic/evaluation/drift/population_stability_index.py +310 -0
- ml4t/diagnostic/evaluation/drift/wasserstein.py +388 -0
- ml4t/diagnostic/evaluation/event_analysis.py +647 -0
- ml4t/diagnostic/evaluation/excursion.py +390 -0
- ml4t/diagnostic/evaluation/feature_diagnostics.py +873 -0
- ml4t/diagnostic/evaluation/feature_outcome.py +666 -0
- ml4t/diagnostic/evaluation/framework.py +935 -0
- ml4t/diagnostic/evaluation/metric_registry.py +255 -0
- ml4t/diagnostic/evaluation/metrics/AGENT.md +23 -0
- ml4t/diagnostic/evaluation/metrics/__init__.py +133 -0
- ml4t/diagnostic/evaluation/metrics/basic.py +160 -0
- ml4t/diagnostic/evaluation/metrics/conditional_ic.py +469 -0
- ml4t/diagnostic/evaluation/metrics/feature_outcome.py +475 -0
- ml4t/diagnostic/evaluation/metrics/ic_statistics.py +446 -0
- ml4t/diagnostic/evaluation/metrics/importance_analysis.py +338 -0
- ml4t/diagnostic/evaluation/metrics/importance_classical.py +375 -0
- ml4t/diagnostic/evaluation/metrics/importance_mda.py +371 -0
- ml4t/diagnostic/evaluation/metrics/importance_shap.py +715 -0
- ml4t/diagnostic/evaluation/metrics/information_coefficient.py +527 -0
- ml4t/diagnostic/evaluation/metrics/interactions.py +772 -0
- ml4t/diagnostic/evaluation/metrics/monotonicity.py +226 -0
- ml4t/diagnostic/evaluation/metrics/risk_adjusted.py +324 -0
- ml4t/diagnostic/evaluation/multi_signal.py +550 -0
- ml4t/diagnostic/evaluation/portfolio_analysis/__init__.py +83 -0
- ml4t/diagnostic/evaluation/portfolio_analysis/analysis.py +734 -0
- ml4t/diagnostic/evaluation/portfolio_analysis/metrics.py +589 -0
- ml4t/diagnostic/evaluation/portfolio_analysis/results.py +334 -0
- ml4t/diagnostic/evaluation/report_generation.py +824 -0
- ml4t/diagnostic/evaluation/signal_selector.py +452 -0
- ml4t/diagnostic/evaluation/stat_registry.py +139 -0
- ml4t/diagnostic/evaluation/stationarity/__init__.py +97 -0
- ml4t/diagnostic/evaluation/stationarity/analysis.py +518 -0
- ml4t/diagnostic/evaluation/stationarity/augmented_dickey_fuller.py +296 -0
- ml4t/diagnostic/evaluation/stationarity/kpss_test.py +308 -0
- ml4t/diagnostic/evaluation/stationarity/phillips_perron.py +365 -0
- ml4t/diagnostic/evaluation/stats/AGENT.md +43 -0
- ml4t/diagnostic/evaluation/stats/__init__.py +191 -0
- ml4t/diagnostic/evaluation/stats/backtest_overfitting.py +219 -0
- ml4t/diagnostic/evaluation/stats/bootstrap.py +228 -0
- ml4t/diagnostic/evaluation/stats/deflated_sharpe_ratio.py +591 -0
- ml4t/diagnostic/evaluation/stats/false_discovery_rate.py +295 -0
- ml4t/diagnostic/evaluation/stats/hac_standard_errors.py +108 -0
- ml4t/diagnostic/evaluation/stats/minimum_track_record.py +408 -0
- ml4t/diagnostic/evaluation/stats/moments.py +164 -0
- ml4t/diagnostic/evaluation/stats/rademacher_adjustment.py +436 -0
- ml4t/diagnostic/evaluation/stats/reality_check.py +155 -0
- ml4t/diagnostic/evaluation/stats/sharpe_inference.py +219 -0
- ml4t/diagnostic/evaluation/themes.py +330 -0
- ml4t/diagnostic/evaluation/threshold_analysis.py +957 -0
- ml4t/diagnostic/evaluation/trade_analysis.py +1136 -0
- ml4t/diagnostic/evaluation/trade_dashboard/__init__.py +32 -0
- ml4t/diagnostic/evaluation/trade_dashboard/app.py +315 -0
- ml4t/diagnostic/evaluation/trade_dashboard/export/__init__.py +18 -0
- ml4t/diagnostic/evaluation/trade_dashboard/export/csv.py +82 -0
- ml4t/diagnostic/evaluation/trade_dashboard/export/html.py +276 -0
- ml4t/diagnostic/evaluation/trade_dashboard/io.py +166 -0
- ml4t/diagnostic/evaluation/trade_dashboard/normalize.py +304 -0
- ml4t/diagnostic/evaluation/trade_dashboard/stats.py +386 -0
- ml4t/diagnostic/evaluation/trade_dashboard/style.py +79 -0
- ml4t/diagnostic/evaluation/trade_dashboard/tabs/__init__.py +21 -0
- ml4t/diagnostic/evaluation/trade_dashboard/tabs/patterns.py +354 -0
- ml4t/diagnostic/evaluation/trade_dashboard/tabs/shap_analysis.py +280 -0
- ml4t/diagnostic/evaluation/trade_dashboard/tabs/stat_validation.py +186 -0
- ml4t/diagnostic/evaluation/trade_dashboard/tabs/worst_trades.py +236 -0
- ml4t/diagnostic/evaluation/trade_dashboard/types.py +129 -0
- ml4t/diagnostic/evaluation/trade_shap/__init__.py +102 -0
- ml4t/diagnostic/evaluation/trade_shap/alignment.py +188 -0
- ml4t/diagnostic/evaluation/trade_shap/characterize.py +413 -0
- ml4t/diagnostic/evaluation/trade_shap/cluster.py +302 -0
- ml4t/diagnostic/evaluation/trade_shap/explain.py +208 -0
- ml4t/diagnostic/evaluation/trade_shap/hypotheses/__init__.py +23 -0
- ml4t/diagnostic/evaluation/trade_shap/hypotheses/generator.py +290 -0
- ml4t/diagnostic/evaluation/trade_shap/hypotheses/matcher.py +251 -0
- ml4t/diagnostic/evaluation/trade_shap/hypotheses/templates.yaml +467 -0
- ml4t/diagnostic/evaluation/trade_shap/models.py +386 -0
- ml4t/diagnostic/evaluation/trade_shap/normalize.py +116 -0
- ml4t/diagnostic/evaluation/trade_shap/pipeline.py +263 -0
- ml4t/diagnostic/evaluation/trade_shap_dashboard.py +283 -0
- ml4t/diagnostic/evaluation/trade_shap_diagnostics.py +588 -0
- ml4t/diagnostic/evaluation/validated_cv.py +535 -0
- ml4t/diagnostic/evaluation/visualization.py +1050 -0
- ml4t/diagnostic/evaluation/volatility/__init__.py +45 -0
- ml4t/diagnostic/evaluation/volatility/analysis.py +351 -0
- ml4t/diagnostic/evaluation/volatility/arch.py +258 -0
- ml4t/diagnostic/evaluation/volatility/garch.py +460 -0
- ml4t/diagnostic/integration/__init__.py +48 -0
- ml4t/diagnostic/integration/backtest_contract.py +671 -0
- ml4t/diagnostic/integration/data_contract.py +316 -0
- ml4t/diagnostic/integration/engineer_contract.py +226 -0
- ml4t/diagnostic/logging/__init__.py +77 -0
- ml4t/diagnostic/logging/logger.py +245 -0
- ml4t/diagnostic/logging/performance.py +234 -0
- ml4t/diagnostic/logging/progress.py +234 -0
- ml4t/diagnostic/logging/wandb.py +412 -0
- ml4t/diagnostic/metrics/__init__.py +9 -0
- ml4t/diagnostic/metrics/percentiles.py +128 -0
- ml4t/diagnostic/py.typed +1 -0
- ml4t/diagnostic/reporting/__init__.py +43 -0
- ml4t/diagnostic/reporting/base.py +130 -0
- ml4t/diagnostic/reporting/html_renderer.py +275 -0
- ml4t/diagnostic/reporting/json_renderer.py +51 -0
- ml4t/diagnostic/reporting/markdown_renderer.py +117 -0
- ml4t/diagnostic/results/AGENT.md +24 -0
- ml4t/diagnostic/results/__init__.py +105 -0
- ml4t/diagnostic/results/barrier_results/__init__.py +36 -0
- ml4t/diagnostic/results/barrier_results/hit_rate.py +304 -0
- ml4t/diagnostic/results/barrier_results/precision_recall.py +266 -0
- ml4t/diagnostic/results/barrier_results/profit_factor.py +297 -0
- ml4t/diagnostic/results/barrier_results/tearsheet.py +397 -0
- ml4t/diagnostic/results/barrier_results/time_to_target.py +305 -0
- ml4t/diagnostic/results/barrier_results/validation.py +38 -0
- ml4t/diagnostic/results/base.py +177 -0
- ml4t/diagnostic/results/event_results.py +349 -0
- ml4t/diagnostic/results/feature_results.py +787 -0
- ml4t/diagnostic/results/multi_signal_results.py +431 -0
- ml4t/diagnostic/results/portfolio_results.py +281 -0
- ml4t/diagnostic/results/sharpe_results.py +448 -0
- ml4t/diagnostic/results/signal_results/__init__.py +74 -0
- ml4t/diagnostic/results/signal_results/ic.py +581 -0
- ml4t/diagnostic/results/signal_results/irtc.py +110 -0
- ml4t/diagnostic/results/signal_results/quantile.py +392 -0
- ml4t/diagnostic/results/signal_results/tearsheet.py +456 -0
- ml4t/diagnostic/results/signal_results/turnover.py +213 -0
- ml4t/diagnostic/results/signal_results/validation.py +147 -0
- ml4t/diagnostic/signal/AGENT.md +17 -0
- ml4t/diagnostic/signal/__init__.py +69 -0
- ml4t/diagnostic/signal/_report.py +152 -0
- ml4t/diagnostic/signal/_utils.py +261 -0
- ml4t/diagnostic/signal/core.py +275 -0
- ml4t/diagnostic/signal/quantile.py +148 -0
- ml4t/diagnostic/signal/result.py +214 -0
- ml4t/diagnostic/signal/signal_ic.py +129 -0
- ml4t/diagnostic/signal/turnover.py +182 -0
- ml4t/diagnostic/splitters/AGENT.md +19 -0
- ml4t/diagnostic/splitters/__init__.py +36 -0
- ml4t/diagnostic/splitters/base.py +501 -0
- ml4t/diagnostic/splitters/calendar.py +421 -0
- ml4t/diagnostic/splitters/calendar_config.py +91 -0
- ml4t/diagnostic/splitters/combinatorial.py +1064 -0
- ml4t/diagnostic/splitters/config.py +322 -0
- ml4t/diagnostic/splitters/cpcv/__init__.py +57 -0
- ml4t/diagnostic/splitters/cpcv/combinations.py +119 -0
- ml4t/diagnostic/splitters/cpcv/partitioning.py +263 -0
- ml4t/diagnostic/splitters/cpcv/purge_engine.py +379 -0
- ml4t/diagnostic/splitters/cpcv/windows.py +190 -0
- ml4t/diagnostic/splitters/group_isolation.py +329 -0
- ml4t/diagnostic/splitters/persistence.py +316 -0
- ml4t/diagnostic/splitters/utils.py +207 -0
- ml4t/diagnostic/splitters/walk_forward.py +757 -0
- ml4t/diagnostic/utils/__init__.py +42 -0
- ml4t/diagnostic/utils/config.py +542 -0
- ml4t/diagnostic/utils/dependencies.py +318 -0
- ml4t/diagnostic/utils/sessions.py +127 -0
- ml4t/diagnostic/validation/__init__.py +54 -0
- ml4t/diagnostic/validation/dataframe.py +274 -0
- ml4t/diagnostic/validation/returns.py +280 -0
- ml4t/diagnostic/validation/timeseries.py +299 -0
- ml4t/diagnostic/visualization/AGENT.md +19 -0
- ml4t/diagnostic/visualization/__init__.py +223 -0
- ml4t/diagnostic/visualization/backtest/__init__.py +98 -0
- ml4t/diagnostic/visualization/backtest/cost_attribution.py +762 -0
- ml4t/diagnostic/visualization/backtest/executive_summary.py +895 -0
- ml4t/diagnostic/visualization/backtest/interactive_controls.py +673 -0
- ml4t/diagnostic/visualization/backtest/statistical_validity.py +874 -0
- ml4t/diagnostic/visualization/backtest/tearsheet.py +565 -0
- ml4t/diagnostic/visualization/backtest/template_system.py +373 -0
- ml4t/diagnostic/visualization/backtest/trade_plots.py +1172 -0
- ml4t/diagnostic/visualization/barrier_plots.py +782 -0
- ml4t/diagnostic/visualization/core.py +1060 -0
- ml4t/diagnostic/visualization/dashboards/__init__.py +36 -0
- ml4t/diagnostic/visualization/dashboards/base.py +582 -0
- ml4t/diagnostic/visualization/dashboards/importance.py +801 -0
- ml4t/diagnostic/visualization/dashboards/interaction.py +263 -0
- ml4t/diagnostic/visualization/dashboards.py +43 -0
- ml4t/diagnostic/visualization/data_extraction/__init__.py +48 -0
- ml4t/diagnostic/visualization/data_extraction/importance.py +649 -0
- ml4t/diagnostic/visualization/data_extraction/interaction.py +504 -0
- ml4t/diagnostic/visualization/data_extraction/types.py +113 -0
- ml4t/diagnostic/visualization/data_extraction/validation.py +66 -0
- ml4t/diagnostic/visualization/feature_plots.py +888 -0
- ml4t/diagnostic/visualization/interaction_plots.py +618 -0
- ml4t/diagnostic/visualization/portfolio/__init__.py +41 -0
- ml4t/diagnostic/visualization/portfolio/dashboard.py +514 -0
- ml4t/diagnostic/visualization/portfolio/drawdown_plots.py +341 -0
- ml4t/diagnostic/visualization/portfolio/returns_plots.py +487 -0
- ml4t/diagnostic/visualization/portfolio/risk_plots.py +301 -0
- ml4t/diagnostic/visualization/report_generation.py +1343 -0
- ml4t/diagnostic/visualization/signal/__init__.py +103 -0
- ml4t/diagnostic/visualization/signal/dashboard.py +911 -0
- ml4t/diagnostic/visualization/signal/event_plots.py +514 -0
- ml4t/diagnostic/visualization/signal/ic_plots.py +635 -0
- ml4t/diagnostic/visualization/signal/multi_signal_dashboard.py +974 -0
- ml4t/diagnostic/visualization/signal/multi_signal_plots.py +603 -0
- ml4t/diagnostic/visualization/signal/quantile_plots.py +625 -0
- ml4t/diagnostic/visualization/signal/turnover_plots.py +400 -0
- ml4t/diagnostic/visualization/trade_shap/__init__.py +90 -0
- ml4t_diagnostic-0.1.0a1.dist-info/METADATA +1044 -0
- ml4t_diagnostic-0.1.0a1.dist-info/RECORD +242 -0
- ml4t_diagnostic-0.1.0a1.dist-info/WHEEL +4 -0
- ml4t_diagnostic-0.1.0a1.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
"""Evaluation framework implementing the Three-Tier Validation Framework.
|
|
2
|
+
|
|
3
|
+
This module provides the Evaluator class, metrics, statistical tests, and
|
|
4
|
+
visualization tools for comprehensive model validation.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ml4t.diagnostic.caching.smart_cache import SmartCache
|
|
8
|
+
from ml4t.diagnostic.results.barrier_results import (
|
|
9
|
+
BarrierTearSheet,
|
|
10
|
+
HitRateResult,
|
|
11
|
+
PrecisionRecallResult,
|
|
12
|
+
ProfitFactorResult,
|
|
13
|
+
TimeToTargetResult,
|
|
14
|
+
)
|
|
15
|
+
from ml4t.diagnostic.results.multi_signal_results import (
|
|
16
|
+
ComparisonResult,
|
|
17
|
+
MultiSignalSummary,
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
from . import ( # noqa: F401 (module re-export)
|
|
21
|
+
diagnostic_plots,
|
|
22
|
+
drift,
|
|
23
|
+
metrics,
|
|
24
|
+
report_generation,
|
|
25
|
+
stats,
|
|
26
|
+
visualization,
|
|
27
|
+
)
|
|
28
|
+
from .autocorrelation import (
|
|
29
|
+
ACFResult,
|
|
30
|
+
AutocorrelationAnalysisResult,
|
|
31
|
+
PACFResult,
|
|
32
|
+
analyze_autocorrelation,
|
|
33
|
+
compute_acf,
|
|
34
|
+
compute_pacf,
|
|
35
|
+
)
|
|
36
|
+
from .barrier_analysis import BarrierAnalysis
|
|
37
|
+
from .binary_metrics import (
|
|
38
|
+
BinaryClassificationReport,
|
|
39
|
+
ConfusionMatrix,
|
|
40
|
+
balanced_accuracy,
|
|
41
|
+
binary_classification_report,
|
|
42
|
+
binomial_test_precision,
|
|
43
|
+
compare_precisions_z_test,
|
|
44
|
+
compute_all_metrics,
|
|
45
|
+
compute_confusion_matrix,
|
|
46
|
+
coverage,
|
|
47
|
+
f1_score,
|
|
48
|
+
format_classification_report,
|
|
49
|
+
lift,
|
|
50
|
+
precision,
|
|
51
|
+
proportions_z_test,
|
|
52
|
+
recall,
|
|
53
|
+
specificity,
|
|
54
|
+
wilson_score_interval,
|
|
55
|
+
)
|
|
56
|
+
from .dashboard import create_evaluation_dashboard
|
|
57
|
+
from .diagnostic_plots import (
|
|
58
|
+
plot_acf_pacf,
|
|
59
|
+
plot_distribution,
|
|
60
|
+
plot_qq,
|
|
61
|
+
plot_volatility_clustering,
|
|
62
|
+
)
|
|
63
|
+
from .distribution import (
|
|
64
|
+
DistributionAnalysisResult,
|
|
65
|
+
HillEstimatorResult,
|
|
66
|
+
JarqueBeraResult,
|
|
67
|
+
MomentsResult,
|
|
68
|
+
QQPlotData,
|
|
69
|
+
ShapiroWilkResult,
|
|
70
|
+
TailAnalysisResult,
|
|
71
|
+
analyze_distribution,
|
|
72
|
+
analyze_tails,
|
|
73
|
+
compute_moments,
|
|
74
|
+
generate_qq_data,
|
|
75
|
+
hill_estimator,
|
|
76
|
+
jarque_bera_test,
|
|
77
|
+
shapiro_wilk_test,
|
|
78
|
+
)
|
|
79
|
+
from .drift import (
|
|
80
|
+
PSIResult,
|
|
81
|
+
compute_psi,
|
|
82
|
+
)
|
|
83
|
+
from .event_analysis import EventStudyAnalysis
|
|
84
|
+
from .excursion import (
|
|
85
|
+
ExcursionAnalysisResult,
|
|
86
|
+
ExcursionStats,
|
|
87
|
+
analyze_excursions,
|
|
88
|
+
compute_excursions,
|
|
89
|
+
)
|
|
90
|
+
from .feature_diagnostics import (
|
|
91
|
+
FeatureDiagnostics,
|
|
92
|
+
FeatureDiagnosticsConfig,
|
|
93
|
+
FeatureDiagnosticsResult,
|
|
94
|
+
)
|
|
95
|
+
from .feature_outcome import (
|
|
96
|
+
FeatureICResults,
|
|
97
|
+
FeatureImportanceResults,
|
|
98
|
+
FeatureOutcome,
|
|
99
|
+
FeatureOutcomeResult,
|
|
100
|
+
)
|
|
101
|
+
from .framework import EvaluationResult, Evaluator, get_metric_directionality
|
|
102
|
+
from .metric_registry import MetricRegistry
|
|
103
|
+
from .metrics import (
|
|
104
|
+
analyze_feature_outcome,
|
|
105
|
+
analyze_interactions,
|
|
106
|
+
analyze_ml_importance,
|
|
107
|
+
compute_conditional_ic,
|
|
108
|
+
compute_forward_returns,
|
|
109
|
+
compute_h_statistic,
|
|
110
|
+
compute_ic_by_horizon,
|
|
111
|
+
compute_ic_decay,
|
|
112
|
+
compute_ic_hac_stats,
|
|
113
|
+
compute_ic_ir,
|
|
114
|
+
compute_ic_series,
|
|
115
|
+
compute_mda_importance,
|
|
116
|
+
compute_mdi_importance,
|
|
117
|
+
compute_monotonicity,
|
|
118
|
+
compute_permutation_importance,
|
|
119
|
+
compute_shap_importance,
|
|
120
|
+
compute_shap_interactions,
|
|
121
|
+
information_coefficient,
|
|
122
|
+
)
|
|
123
|
+
from .multi_signal import MultiSignalAnalysis
|
|
124
|
+
from .portfolio_analysis import (
|
|
125
|
+
DistributionResult,
|
|
126
|
+
DrawdownPeriod,
|
|
127
|
+
DrawdownResult,
|
|
128
|
+
# Portfolio Analysis (pyfolio replacement)
|
|
129
|
+
PortfolioAnalysis,
|
|
130
|
+
PortfolioMetrics,
|
|
131
|
+
RollingMetricsResult,
|
|
132
|
+
alpha_beta,
|
|
133
|
+
annual_return,
|
|
134
|
+
annual_volatility,
|
|
135
|
+
calmar_ratio,
|
|
136
|
+
compute_portfolio_turnover,
|
|
137
|
+
conditional_var,
|
|
138
|
+
information_ratio,
|
|
139
|
+
max_drawdown,
|
|
140
|
+
omega_ratio,
|
|
141
|
+
# Core metric functions
|
|
142
|
+
sharpe_ratio,
|
|
143
|
+
sortino_ratio,
|
|
144
|
+
stability_of_timeseries,
|
|
145
|
+
up_down_capture,
|
|
146
|
+
value_at_risk,
|
|
147
|
+
)
|
|
148
|
+
from .report_generation import (
|
|
149
|
+
generate_html_report,
|
|
150
|
+
generate_json_report,
|
|
151
|
+
generate_markdown_report,
|
|
152
|
+
generate_multi_feature_html_report,
|
|
153
|
+
save_report,
|
|
154
|
+
)
|
|
155
|
+
from .signal_selector import SignalSelector
|
|
156
|
+
from .stat_registry import StatTestRegistry
|
|
157
|
+
from .stationarity import (
|
|
158
|
+
ADFResult,
|
|
159
|
+
KPSSResult,
|
|
160
|
+
PPResult,
|
|
161
|
+
StationarityAnalysisResult,
|
|
162
|
+
adf_test,
|
|
163
|
+
analyze_stationarity,
|
|
164
|
+
kpss_test,
|
|
165
|
+
pp_test,
|
|
166
|
+
)
|
|
167
|
+
from .stats import (
|
|
168
|
+
benjamini_hochberg_fdr,
|
|
169
|
+
compute_pbo,
|
|
170
|
+
holm_bonferroni,
|
|
171
|
+
ras_ic_adjustment,
|
|
172
|
+
)
|
|
173
|
+
from .threshold_analysis import (
|
|
174
|
+
MonotonicityResult,
|
|
175
|
+
OptimalThresholdResult,
|
|
176
|
+
SensitivityResult,
|
|
177
|
+
ThresholdAnalysisSummary,
|
|
178
|
+
analyze_all_metrics_monotonicity,
|
|
179
|
+
analyze_threshold_sensitivity,
|
|
180
|
+
check_monotonicity,
|
|
181
|
+
create_threshold_analysis_summary,
|
|
182
|
+
evaluate_percentile_thresholds,
|
|
183
|
+
evaluate_threshold_sweep,
|
|
184
|
+
find_optimal_threshold,
|
|
185
|
+
find_threshold_for_target_coverage,
|
|
186
|
+
format_threshold_analysis,
|
|
187
|
+
)
|
|
188
|
+
from .trade_analysis import (
|
|
189
|
+
TradeAnalysis,
|
|
190
|
+
TradeAnalysisResult,
|
|
191
|
+
TradeMetrics,
|
|
192
|
+
TradeStatistics,
|
|
193
|
+
)
|
|
194
|
+
from .trade_shap_diagnostics import (
|
|
195
|
+
ClusteringResult,
|
|
196
|
+
ErrorPattern,
|
|
197
|
+
TradeExplainFailure,
|
|
198
|
+
TradeShapAnalyzer,
|
|
199
|
+
TradeShapExplanation,
|
|
200
|
+
TradeShapResult,
|
|
201
|
+
)
|
|
202
|
+
from .validated_cv import (
|
|
203
|
+
ValidatedCrossValidation,
|
|
204
|
+
ValidatedCrossValidationConfig,
|
|
205
|
+
ValidationFoldResult,
|
|
206
|
+
ValidationResult,
|
|
207
|
+
validated_cross_val_score,
|
|
208
|
+
)
|
|
209
|
+
from .volatility import (
|
|
210
|
+
ARCHLMResult,
|
|
211
|
+
GARCHResult,
|
|
212
|
+
VolatilityAnalysisResult,
|
|
213
|
+
analyze_volatility,
|
|
214
|
+
arch_lm_test,
|
|
215
|
+
fit_garch,
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
# Lazy import for dashboard functions to avoid slow Streamlit import at module load
|
|
219
|
+
# This saves ~1.3 seconds on every import of ml4t.diagnostic
|
|
220
|
+
_dashboard_module = None
|
|
221
|
+
_HAS_STREAMLIT: bool | None = None # Will be set on first access
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
def __getattr__(name: str):
|
|
225
|
+
"""Lazy load dashboard functions to avoid importing Streamlit at module load."""
|
|
226
|
+
global _dashboard_module, _HAS_STREAMLIT
|
|
227
|
+
|
|
228
|
+
if name == "run_diagnostics_dashboard":
|
|
229
|
+
if _dashboard_module is None:
|
|
230
|
+
try:
|
|
231
|
+
from . import trade_shap_dashboard as _mod
|
|
232
|
+
|
|
233
|
+
_dashboard_module = _mod
|
|
234
|
+
_HAS_STREAMLIT = True
|
|
235
|
+
except ImportError:
|
|
236
|
+
_HAS_STREAMLIT = False
|
|
237
|
+
return None
|
|
238
|
+
|
|
239
|
+
return _dashboard_module.run_diagnostics_dashboard
|
|
240
|
+
|
|
241
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
__all__: list[str] = [
|
|
245
|
+
"EvaluationResult",
|
|
246
|
+
"Evaluator",
|
|
247
|
+
"get_metric_directionality",
|
|
248
|
+
"MetricRegistry",
|
|
249
|
+
"StatTestRegistry",
|
|
250
|
+
"create_evaluation_dashboard",
|
|
251
|
+
"metrics",
|
|
252
|
+
"stats",
|
|
253
|
+
"visualization",
|
|
254
|
+
"diagnostic_plots",
|
|
255
|
+
# IC Time Series (Alphalens-style)
|
|
256
|
+
"information_coefficient",
|
|
257
|
+
"compute_forward_returns",
|
|
258
|
+
"compute_ic_series",
|
|
259
|
+
"compute_ic_by_horizon",
|
|
260
|
+
"compute_ic_ir",
|
|
261
|
+
"compute_ic_hac_stats",
|
|
262
|
+
"compute_ic_decay",
|
|
263
|
+
"compute_conditional_ic",
|
|
264
|
+
"compute_monotonicity",
|
|
265
|
+
"analyze_feature_outcome",
|
|
266
|
+
"compute_h_statistic",
|
|
267
|
+
"compute_shap_interactions",
|
|
268
|
+
"analyze_interactions",
|
|
269
|
+
"compute_permutation_importance",
|
|
270
|
+
"compute_mdi_importance",
|
|
271
|
+
"compute_mda_importance",
|
|
272
|
+
"compute_shap_importance",
|
|
273
|
+
"analyze_ml_importance",
|
|
274
|
+
# Diagnostic Plotting Functions
|
|
275
|
+
"plot_acf_pacf",
|
|
276
|
+
"plot_qq",
|
|
277
|
+
"plot_volatility_clustering",
|
|
278
|
+
"plot_distribution",
|
|
279
|
+
# Feature Diagnostics (Main API)
|
|
280
|
+
"FeatureDiagnostics",
|
|
281
|
+
"FeatureDiagnosticsConfig",
|
|
282
|
+
"FeatureDiagnosticsResult",
|
|
283
|
+
# Stationarity tests
|
|
284
|
+
"adf_test",
|
|
285
|
+
"ADFResult",
|
|
286
|
+
"kpss_test",
|
|
287
|
+
"KPSSResult",
|
|
288
|
+
"pp_test",
|
|
289
|
+
"PPResult",
|
|
290
|
+
"analyze_stationarity",
|
|
291
|
+
"StationarityAnalysisResult",
|
|
292
|
+
# Autocorrelation
|
|
293
|
+
"compute_acf",
|
|
294
|
+
"ACFResult",
|
|
295
|
+
"compute_pacf",
|
|
296
|
+
"PACFResult",
|
|
297
|
+
"analyze_autocorrelation",
|
|
298
|
+
"AutocorrelationAnalysisResult",
|
|
299
|
+
# Volatility
|
|
300
|
+
"arch_lm_test",
|
|
301
|
+
"ARCHLMResult",
|
|
302
|
+
"fit_garch",
|
|
303
|
+
"GARCHResult",
|
|
304
|
+
"analyze_volatility",
|
|
305
|
+
"VolatilityAnalysisResult",
|
|
306
|
+
# Distribution
|
|
307
|
+
"compute_moments",
|
|
308
|
+
"MomentsResult",
|
|
309
|
+
"jarque_bera_test",
|
|
310
|
+
"JarqueBeraResult",
|
|
311
|
+
"shapiro_wilk_test",
|
|
312
|
+
"ShapiroWilkResult",
|
|
313
|
+
"hill_estimator",
|
|
314
|
+
"HillEstimatorResult",
|
|
315
|
+
"generate_qq_data",
|
|
316
|
+
"QQPlotData",
|
|
317
|
+
"analyze_tails",
|
|
318
|
+
"TailAnalysisResult",
|
|
319
|
+
"analyze_distribution",
|
|
320
|
+
"DistributionAnalysisResult",
|
|
321
|
+
# Report generation
|
|
322
|
+
"generate_html_report",
|
|
323
|
+
"generate_json_report",
|
|
324
|
+
"generate_markdown_report",
|
|
325
|
+
"generate_multi_feature_html_report",
|
|
326
|
+
"save_report",
|
|
327
|
+
# Drift detection
|
|
328
|
+
"compute_psi",
|
|
329
|
+
"PSIResult",
|
|
330
|
+
# Price Excursion Analysis (TP/SL parameter selection)
|
|
331
|
+
"analyze_excursions",
|
|
332
|
+
"compute_excursions",
|
|
333
|
+
"ExcursionAnalysisResult",
|
|
334
|
+
"ExcursionStats",
|
|
335
|
+
# Feature-Outcome Analysis (Module C Orchestration)
|
|
336
|
+
"FeatureOutcome",
|
|
337
|
+
"FeatureOutcomeResult",
|
|
338
|
+
"FeatureICResults",
|
|
339
|
+
"FeatureImportanceResults",
|
|
340
|
+
# Trade Analysis (ml4t-diagnostics v1.0)
|
|
341
|
+
"TradeAnalysis",
|
|
342
|
+
"TradeAnalysisResult",
|
|
343
|
+
"TradeMetrics",
|
|
344
|
+
"TradeStatistics",
|
|
345
|
+
# Trade-SHAP Diagnostics (ml4t-diagnostics v1.0 - KILLER FEATURE)
|
|
346
|
+
"ClusteringResult",
|
|
347
|
+
"ErrorPattern",
|
|
348
|
+
"TradeExplainFailure",
|
|
349
|
+
"TradeShapAnalyzer",
|
|
350
|
+
"TradeShapExplanation",
|
|
351
|
+
"TradeShapResult",
|
|
352
|
+
# Dashboard (optional - requires streamlit)
|
|
353
|
+
"run_diagnostics_dashboard",
|
|
354
|
+
# Event Study Analysis (Phase 2 - MacKinlay 1997)
|
|
355
|
+
"EventStudyAnalysis",
|
|
356
|
+
# Multiple Testing Corrections (Phase 3 - Multi-Signal)
|
|
357
|
+
"benjamini_hochberg_fdr",
|
|
358
|
+
"holm_bonferroni",
|
|
359
|
+
# Backtest Overfitting Detection
|
|
360
|
+
"compute_pbo",
|
|
361
|
+
"ras_ic_adjustment",
|
|
362
|
+
# Signal Selection Algorithms (Phase 3 - Multi-Signal)
|
|
363
|
+
"SignalSelector",
|
|
364
|
+
# Multi-Signal Analysis (Phase 3)
|
|
365
|
+
"MultiSignalAnalysis",
|
|
366
|
+
"MultiSignalSummary",
|
|
367
|
+
"ComparisonResult",
|
|
368
|
+
# Caching (Phase 3)
|
|
369
|
+
"SmartCache",
|
|
370
|
+
# Barrier Analysis (Phase 4)
|
|
371
|
+
"BarrierAnalysis",
|
|
372
|
+
"HitRateResult",
|
|
373
|
+
"ProfitFactorResult",
|
|
374
|
+
"PrecisionRecallResult",
|
|
375
|
+
"TimeToTargetResult",
|
|
376
|
+
"BarrierTearSheet",
|
|
377
|
+
# Portfolio Analysis (pyfolio replacement)
|
|
378
|
+
"PortfolioAnalysis",
|
|
379
|
+
"PortfolioMetrics",
|
|
380
|
+
"RollingMetricsResult",
|
|
381
|
+
"DrawdownResult",
|
|
382
|
+
"DrawdownPeriod",
|
|
383
|
+
"DistributionResult",
|
|
384
|
+
# Portfolio metric functions
|
|
385
|
+
"sharpe_ratio",
|
|
386
|
+
"sortino_ratio",
|
|
387
|
+
"calmar_ratio",
|
|
388
|
+
"omega_ratio",
|
|
389
|
+
"max_drawdown",
|
|
390
|
+
"annual_return",
|
|
391
|
+
"annual_volatility",
|
|
392
|
+
"value_at_risk",
|
|
393
|
+
"conditional_var",
|
|
394
|
+
"stability_of_timeseries",
|
|
395
|
+
"alpha_beta",
|
|
396
|
+
"information_ratio",
|
|
397
|
+
"up_down_capture",
|
|
398
|
+
"compute_portfolio_turnover",
|
|
399
|
+
# Binary Classification Metrics (Phase 2 - Book Alignment)
|
|
400
|
+
"BinaryClassificationReport",
|
|
401
|
+
"ConfusionMatrix",
|
|
402
|
+
"balanced_accuracy",
|
|
403
|
+
"binary_classification_report",
|
|
404
|
+
"binomial_test_precision",
|
|
405
|
+
"compare_precisions_z_test",
|
|
406
|
+
"compute_all_metrics",
|
|
407
|
+
"compute_confusion_matrix",
|
|
408
|
+
"coverage",
|
|
409
|
+
"f1_score",
|
|
410
|
+
"format_classification_report",
|
|
411
|
+
"lift",
|
|
412
|
+
"precision",
|
|
413
|
+
"proportions_z_test",
|
|
414
|
+
"recall",
|
|
415
|
+
"specificity",
|
|
416
|
+
"wilson_score_interval",
|
|
417
|
+
# Threshold Analysis (Phase 2 - Book Alignment)
|
|
418
|
+
"MonotonicityResult",
|
|
419
|
+
"OptimalThresholdResult",
|
|
420
|
+
"SensitivityResult",
|
|
421
|
+
"ThresholdAnalysisSummary",
|
|
422
|
+
"analyze_all_metrics_monotonicity",
|
|
423
|
+
"analyze_threshold_sensitivity",
|
|
424
|
+
"check_monotonicity",
|
|
425
|
+
"create_threshold_analysis_summary",
|
|
426
|
+
"evaluate_percentile_thresholds",
|
|
427
|
+
"evaluate_threshold_sweep",
|
|
428
|
+
"find_optimal_threshold",
|
|
429
|
+
"find_threshold_for_target_coverage",
|
|
430
|
+
"format_threshold_analysis",
|
|
431
|
+
# Validated Cross-Validation (CPCV + DSR)
|
|
432
|
+
"ValidatedCrossValidation",
|
|
433
|
+
"ValidatedCrossValidationConfig",
|
|
434
|
+
"validated_cross_val_score",
|
|
435
|
+
"ValidationFoldResult",
|
|
436
|
+
"ValidationResult",
|
|
437
|
+
]
|