Giao diện
Bảng ML Pipeline
TÓM TẮT
12 bảng hỗ trợ toàn bộ ML lifecycle: training → prediction → backtest → self-improvement → audit.
forecast_results — Kết quả dự báo
sql
CREATE TABLE forecast_results (
id bigserial PRIMARY KEY,
series_key text NOT NULL,
client_id text NOT NULL,
product_id bigint,
forecast_date date NOT NULL,
predicted_quantity numeric NOT NULL,
confidence_lower numeric, -- P10
confidence_upper numeric, -- P90
event_tier int,
model_version text,
created_at timestamptz DEFAULT now()
);training_jobs — Tracking Training
sql
CREATE TABLE training_jobs (
id bigserial PRIMARY KEY,
job_id uuid UNIQUE NOT NULL,
client_id text NOT NULL,
status text NOT NULL DEFAULT 'pending',
started_at timestamptz,
completed_at timestamptz,
metrics jsonb, -- {wmape, bias, fnr, mae}
model_version text,
error_message text
);backtest_results — Walk-Forward Validation
sql
CREATE TABLE backtest_results (
id bigserial PRIMARY KEY,
result_id uuid UNIQUE NOT NULL,
cycle_id uuid, -- FK → improvement_cycles
client_id text NOT NULL,
forecast_level text NOT NULL DEFAULT 'order', -- 'order' | 'sku'
fold_index int,
train_start date,
train_end date,
test_start date,
test_end date,
metrics jsonb NOT NULL, -- {wmape, bias, fnr, mae, event_wmape...}
model_version text
);improvement_cycles — AutoML State Machine
sql
CREATE TABLE improvement_cycles (
id bigserial PRIMARY KEY,
cycle_id uuid UNIQUE NOT NULL,
client_id text NOT NULL,
state text NOT NULL DEFAULT 'PROFILING',
-- States: PROFILING → BACKTEST → ANALYZE → SUGGEST → APPLY → RETRAIN → VERIFY → COMPLETE
max_iterations int DEFAULT 5,
current_iteration int DEFAULT 0,
convergence_threshold numeric DEFAULT 0.005,
mape_before numeric,
mape_after numeric,
config_snapshot jsonb,
error_message text
);llm_suggestions — Gợi ý AI
sql
CREATE TABLE llm_suggestions (
id bigserial PRIMARY KEY,
suggestion_id uuid UNIQUE NOT NULL,
cycle_id uuid,
client_id text NOT NULL,
category text NOT NULL,
-- Categories: hyperparameter, feature, event, calendar, cross_audit, other
summary text NOT NULL,
reasoning text,
parameter_diff jsonb, -- Before/after config diff
before_metrics jsonb,
after_metrics jsonb,
status text NOT NULL DEFAULT 'pending'
-- Status: pending, applied, rejected, rollback
);Các bảng phụ trợ
| Bảng | Mục đích |
|---|---|
model_metadata | Registry model: version, metrics, feature_count, training_samples |
sku_metadata | Phân loại SKU: sku_type (dead/intermittent/lumpy/smooth/seasonal), demand_frequency |
discovered_events | Sự kiện auto-discovered bởi LLM từ residual analysis |
llm_providers | Cấu hình LLM API: provider_type, model_name, API key |
model_comparisons | A/B test giữa các model/LLM providers |
data_profiles | EDA snapshots: summary_stats, demand_patterns, temporal_patterns |
anomaly_log | Cross-audit anomalies giữa order-level và SKU-level forecasts |
Tài liệu liên quan
- Schema tổng quan
- AutoML — Cách improvement_cycles được sử dụng
- Bảo mật & RLS