[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-108181":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":15,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":16,"rankGlobal":10,"rankLanguage":10,"license":17,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":36,"updatedAt":37,"readmeContent":38,"aiSummary":39,"trendingCount":15,"starSnapshotCount":15,"syncStatus":40,"lastSyncTime":41,"discoverSource":42},108181,"predictorlab","MarkIvor\u002Fpredictorlab","MarkIvor","Self-hosted tabular ML that doesn't lie. Leakage Guard, conformal intervals, profit-optimized thresholds, counterfactuals & instant REST\u002FMCP API.","",null,"Python",3,1,67,0,40.9,"MIT License",false,"main",true,[22,23,24,25,26,27,28,29,30,31,32,33,34,35],"automl","catboost","conformal-prediction","counterfactual-explanations","data-leakage","duckdb","explainable-ai","fastapi","lightgbm","machine-learning","mcp-server","mlops","self-hosted","tabular-data","2026-11-04 14:32:46","2026-11-19 16:26:39","# PredictorLab\n\n**English** | [Русский](README.ru.md)\n\n![Python](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPython-3.12+-blue?logo=python&logoColor=white)\n![React](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FReact-19-61dafb?logo=react&logoColor=white)\n![CatBoost](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCatBoost-LightGBM-orange)\n![DuckDB](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FDuckDB-In--process-orange?logo=duckdb)\n![MCP](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FMCP-1.28+-purple)\n![License](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLicense-MIT-green)\n![Languages](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FLanguages-EN%20%7C%20RU-green)\n\n[![CI](https:\u002F\u002Fgithub.com\u002FMarkIvor\u002Fpredictorlab\u002Factions\u002Fworkflows\u002Fci.yml\u002Fbadge.svg?branch=main)](..\u002F..\u002Factions\u002Fworkflows\u002Fci.yml)\n[![Nightly](https:\u002F\u002Fgithub.com\u002FMarkIvor\u002Fpredictorlab\u002Factions\u002Fworkflows\u002Fnightly.yml\u002Fbadge.svg?branch=main)](..\u002F..\u002Factions\u002Fworkflows\u002Fnightly.yml)\n\n> Upload your data. Say what you want to predict. Get an honest model with a confidence interval,\n> a profit-optimized threshold, and a REST API — in 5 minutes.\n\n**PredictorLab** is self-hosted tabular ML for **analysts who need ML but don't have a DS team**.\nYou know your data, you know your business costs — PredictorLab handles the ML: catches leakage,\nsplits correctly, calibrates probabilities, and converts them into decisions in rubles.\n\n**Spoiler:** the model that shows 99% accuracy on your first upload is almost certainly broken.\nThis tool will tell you exactly why — and fix it for you.\n\n![Model Hangar](docs\u002Fscreenshots\u002F02_hangar.png)\n\n---\n\n## Who this is for\n\n| You are | You have | PredictorLab gives you |\n|---------|----------|----------------------|\n| **Analyst \u002F product manager** | A CSV with historical outcomes, business intuition about costs | A working ML model without learning scikit-learn. The tool asks the right questions (What's a false negative worth? Which features can you actually change?) and turns answers into a decision system |\n| **Consultant \u002F data engineer** | Clients with data, no time to hand-hold | A self-hosted tool you can deploy for a client in 5 minutes, share a prediction form, and hand over an API. No SaaS dependency, no data leaving the client's server |\n| **Solo DS practitioner** | ML knowledge, but no time to build the full pipeline | The boring parts are done: out-of-time splits, conformal intervals, calibration, monitoring, versioning. You focus on features and business logic |\n\n**What you need:** a dataset with a labeled outcome column, and rough numbers for what a correct\nprediction earns vs what a wrong one costs. That's it.\n\n**What you don't need:** Python, scikit-learn, or a DS degree. But if you have them — the REST API\nand MCP server give you full programmatic control.\n\n---\n\n## The Problem\n\nI've watched this scenario play out dozens of times:\n\n1. A business team uploads a customer churn dataset to a mass-market \"no-code ML\" tool\n2. They get **ROC-AUC 0.98** — everybody celebrates\n3. The model goes to production, predicts nothing useful, and dies quietly\n\nThe 0.98 was never real. The dataset had a `cancel_date` column — filled in only after a customer\nhad already churned. The model learned to read the future, not to predict it. Mass-market no-code\ntools don't block on this — at best they show a yellow warning that nobody clicks.\nEnterprise tools like DataRobot *do* detect leakage, but they cost $$$ and require an implementation team.\n\n**The second problem** is even more insidious: even with a \"good\" model, business people get\nprobabilities — not decisions. \"This customer has a 73% churn probability.\" Great. What do I *do*\nwith that? Call them? Offer a discount? The tool never says, because the tool doesn't know\nwhat a phone call costs or what a saved customer is worth.\n\n**PredictorLab solves both — in the gap between \"too simple to trust\" and \"too expensive to buy\":**\n\n| Problem | Mass-market no-code tools | Enterprise (DataRobot) | **PredictorLab** |\n|---------|--------------------------|------------------------|------------------|\n| Target leakage | Yellow warning icon (nobody clicks) | Detects it, requires setup | **BLOCK verdict** with explanation in plain language + one-click \"Exclude and retrain\" |\n| Random split on time-series data | Random split → contamination | Configurable, manual setup | **Automatic out-of-time split** when a date column exists |\n| Bare probability, no uncertainty | \"73% churn\" (and then what?) | Confidence intervals (model-specific) | **Conformal interval** with coverage guarantee + OOD flag |\n| Threshold at 0.5 or by F1 | \"Here's your AUC\" | Configurable, manual tuning | **Cost matrix → profit-maximizing threshold**: \"At 0.27, treating top-500 customers nets +84,000₽\u002Fmonth\" |\n| No actionable next step | SHAP values in a chart | Good, but $$$ | **Counterfactuals**: \"Reduce discount by 5% → probability drops 0.81→0.31, ROI: 21,400₽\" |\n| Dead model after training | One-and-done | Built-in monitoring | **PSI drift + live metrics + webhooks + one-click retrain** |\n| Price | $99\u002Fmo SaaS, data leaves your server | $50k+\u002Fyear, needs a team | **MIT, self-hosted, Docker** |\n\n---\n\n## How it looks\n\n**Leakage Guard in action** — the killer feature. Upload the leaky demo dataset, and the system\ndoesn't just warn — it refuses to show results and tells you what to do:\n\n![Leakage Guard BLOCK](docs\u002Fscreenshots\u002F03_overview.png)\n\n*The \"What does this mean?\" block explains AUC, lift, and conformal coverage in business terms — not jargon.*\n\n**Training panel** — real-time SSE progress, 7 stages with descriptions, live leaderboard, elapsed\u002Fremaining time:\n\n![Training Panel](docs\u002Fscreenshots\u002F04_whatif.png)\n\n**Profit optimization** — the threshold is set where your money is maximized, not where F1 looks pretty:\n\n![Profit Curve](docs\u002Fscreenshots\u002F05_profit.png)\n\n**Sharing predictions** — three ways, each one click. Web form for non-technical users, API key for developers, batch for processing your entire customer base:\n\n![Share Predictions](docs\u002Fscreenshots\u002F07_api_share.png)\n\n**Single prediction** — probability, conformal interval, reasons in plain language, OOD flag:\n\n![Prediction](docs\u002Fscreenshots\u002F06_predict.png)\n\n**Model Card** — auto-generated with leakage report, assumptions, limitations. Exportable to Markdown and PDF:\n\n![Model Card](docs\u002Fscreenshots\u002F08_model_card.png)\n\n---\n\n## How it works\n\n```\n  ┌────────────────── Web Interface ──────────────────┐\n  │  React UI ←SSE→ FastAPI + asyncio jobs + ProcessPool │\n  │         │                                          │\n  │         │   ┌─────── REST API :8000 ────────┐      │\n  │         │   │  \u002Fapi\u002Fv1\u002Fmodels\u002F{id}\u002Fpredict  │      │\n  │         │   │  \u002Fapi\u002Fv1\u002Fmodels\u002F{id}\u002Fwhatif   │      │\n  │         │   │  \u002Fapi\u002Fv1\u002Fjobs\u002F{id}            │      │\n  │         │   └───────────────────────────────┘      │\n  │         │                                          │\n  │         │   ┌─────── MCP Server :8100 ──────┐      │\n  │         │   │  predict, explain, what_if,   │      │\n  │         │   │  counterfactual, model_card   │      │\n  │         │   └───────────────────────────────┘      │\n  │         │                                          │\n  │         ▼                                          │\n  │  ┌─── Core Pipeline ──────────────────────────┐    │\n  │  │                                            │    │\n  │  │  CSV\u002FXLSX\u002FParquet ← PII scanner            │    │\n  │  │       ↓                                    │    │\n  │  │  Feature Builder (point-in-time SQL)       │    │\n  │  │       ↓                                    │    │\n  │  │  Leakage Guard (9 deterministic checks)    │    │\n  │  │       ↓                                    │    │\n  │  │  Splits (OOT \u002F group \u002F stratified)         │    │\n  │  │       ↓                                    │    │\n  │  │  Training (CatBoost + LightGBM + Optuna)    │    │\n  │  │       ↓                                    │    │\n  │  │  Calibration + Conformal + OOD + SHAP       │    │\n  │  │       ↓                                    │    │\n  │  │  Profit → Threshold → Counterfactuals       │    │\n  │  │       ↓                                    │    │\n  │  │  Monitoring (PSI drift + live metrics)      │    │\n  │  │                                            │    │\n  │  └────────────────────────────────────────────┘    │\n  │                                                    │\n  │  DuckDB (data) · SQLite (metadata) · joblib       │\n  │  PostgreSQL \u002F MySQL \u002F ClickHouse \u002F SQLite (RO)     │\n  └────────────────────────────────────────────────────┘\n```\n\n1. **Upload** CSV, XLSX or Parquet — encoding and delimiter detected automatically (including cp1251).\n   PII columns (email, phone, INN, SNILS, passport, card) are detected and **excluded from training by default**.\n2. **Pick a target** — from a dropdown or describe it in words (LLM suggests the column and SQL).\n3. **Leakage Guard** runs 9 deterministic checks. If BLOCK — you see exactly which columns leak and why.\n   One click: \"Exclude and retrain\". Advanced users can override (recorded in Model Card).\n4. **Train** — Quick (CatBoost + linear, ~2 min) or Full (Optuna searches CatBoost + LightGBM within a time budget).\n   Watch live progress: stages, candidate leaderboard, elapsed time.\n5. **Result** — AUC\u002FMAE vs baseline, conformal coverage, calibration curve, SHAP drivers.\n   Set the cost matrix → profit curve → optimal threshold. Try What-If sliders.\n6. **Share** — create a web form link, an API key, or batch-predict an entire file.\n7. **Monitor** — PSI drift alerts, live metrics on real outcomes, webhooks, one-click retrain.\n\n---\n\n## Leakage Guard: the demo that sells the product\n\nThe `demo-data\u002Fb2b_leaky.csv` dataset contains a deliberate trap:\n`cancel_date` is filled only for customers who already churned. Here's what happens:\n\n```\nLeakage Guard — Verdict: BLOCK\n\n[x] cancel_date almost perfectly predicts the target (AUC 0.998).\n    Value appears to be known only after the event has occurred.\n[x] final_status: column name resembles a post-event feature.\n[x] cancel_date contains dates after the event time (100% of rows) — feature from the future.\n\nResults will not be shown.\n[ Exclude (cancel_date, final_status) and retrain ]\n```\n\nAfter \"Exclude and retrain\", AUC drops to **0.85**. That's the real model.\nIt's still good — but it's honest. The 0.998 was never yours.\n\n---\n\n## Quick Start\n\n```bash\ngit clone https:\u002F\u002Fgithub.com\u002FMarkIvor\u002Fpredictorlab.git\ncd predictorlab\ncp .env.example .env    # change ADMIN_EMAIL \u002F ADMIN_PASSWORD \u002F secrets\ndocker compose up -d\n```\n\n| | |\n|---|---|\n| UI | http:\u002F\u002Flocalhost:3000 |\n| API | http:\u002F\u002Flocalhost:8000 |\n| OpenAPI docs | http:\u002F\u002Flocalhost:8000\u002Fdocs |\n\nDefault admin is created from `.env` on first boot. Password change is required on first login.\n\n**Dev without Docker:**\n```bash\npython -m venv .venv && .venv\u002Fbin\u002Fpip install -r backend\u002Frequirements.txt\ncd backend && uvicorn app.main:app --port 8000\n# second terminal:\ncd frontend && npm install && npm run dev\n```\n\n**Works fully offline and without LLM.** When `LLM_BASE_URL` is empty, all LLM features are hidden.\nTraining, predictions, intervals, thresholds — everything is deterministic code.\nLLM is only for: natural-language target suggestion, semantic column checking, and Model Card text.\nRaw data rows never leave the system (enforced by code + tested by a spy test).\n\n---\n\n## Predict in 60 seconds\n\n```bash\n# Create a key in the UI (API tab) — shown once, stored as SHA-256 hash\nexport KEY=pl_live_...\n\n# Get the model's input schema\ncurl http:\u002F\u002Flocalhost:8000\u002Fapi\u002Fv1\u002Fmodels\u002F1\u002Fschema -H \"Authorization: Bearer $KEY\"\n\n# Predict with reasons\ncurl -X POST http:\u002F\u002Flocalhost:8000\u002Fapi\u002Fv1\u002Fmodels\u002F1\u002Fpredict \\\n  -H \"Authorization: Bearer $KEY\" -H \"Content-Type: application\u002Fjson\" \\\n  -d '{\"data\": [{\"days_since_last_order\": 75, \"satisfaction\": 2.1}], \"include\": [\"reasons\"]}'\n```\n\nResponse:\n```json\n{\n  \"predictions\": [{\n    \"prediction_id\": \"prd_01J...\",\n    \"label\": \"churn\",\n    \"probability\": 0.81,\n    \"decision\": true,\n    \"threshold\": 0.27,\n    \"conformal\": {\"coverage\": 0.9, \"prediction_set\": [\"churn\"]},\n    \"out_of_distribution\": false,\n    \"top_reasons\": [\n      {\"feature\": \"days_since_last_order\", \"value\": 75,\n       \"text\": \"No orders in 75 days: +18pp to risk\"}\n    ]\n  }],\n  \"latency_ms\": 62\n}\n```\n\nSnippets for **curl, Python, JavaScript, and 1C** are auto-generated per model schema — they work without edits.\n\n---\n\n## Share predictions\n\n| Method | What it is | For whom |\n|--------|-----------|----------|\n| **Web form** | One click → shareable URL. Anyone can predict without login. Optional password. | Colleagues, clients |\n| **API key** | `pl_live_...` key with per-model access, hash-stored, shown once | Developers |\n| **Batch** | Upload CSV → background job → download predictions with intervals | Processing the full customer base |\n| **MCP** | `predict`, `explain`, `what_if`, `counterfactual`, `get_model_card`, `get_drift_status` — right in Claude Desktop or Cursor | AI power users |\n\n---\n\n## What-If and Counterfactuals\n\n**What-If sliders** let you change any feature and watch the prediction and interval recalculate in real time\n(150ms debounce). A permanent disclaimer: *\"This is the model's response to a feature change, not a proven causal effect.\"*\n\n**Counterfactuals** go further: they find the **minimum-cost change** to actionable features\nthat flips the prediction across the threshold. You define: allowed range, direction (only up \u002F only down),\nand cost per unit of change. The system searches (greedy + random restarts, with a timeout)\nand returns:\n\n```\nAction: reduce discount_pct from 12% to 5%\nCost: 3,000 ₽\nProbability before: 0.81 → after: 0.31\nExpected ROI: 21,400 ₽\n```\n\nIf the model says \"change the customer's age\" — it won't, because you marked it as immutable.\n\n---\n\n## Monitoring\n\nAfter the model is in production:\n\n- Every prediction is logged (PII masked, TTL configurable)\n- **PSI drift** computed per feature and per prediction distribution (7\u002F30-day windows)\n- **Live metrics**: real AUC\u002FMAE from feedback vs validation numbers\n- **Webhooks** fire on DRIFT or live-metric drop\n- **One-click retrain** on fresh data; version comparison and rollback\n\n---\n\n## Benchmarks\n\n| Operation | Budget | Measured |\n|---|---|---|\n| `predict`, 1 record | \u003C 300 ms | **62 ms** |\n| `predict` + SHAP reasons | \u003C 1 s | **79 ms** |\n| Batch 10k rows | \u003C 2 min | **14 s** |\n| Train quick, 50k × 50 | ~2 min | **155 s** |\n| Counterfactual, 1 object | \u003C 10 s | **6.4 s** |\n\nFull results: [BENCHMARKS.md](BENCHMARKS.md) · Run: `make bench`\n\n---\n\n## Tests & CI\n\n```bash\nmake check     # lint + typecheck + unit + property + integration + llm + security + frontend (~2 min)\nmake test-e2e  # Playwright end-to-end\nmake test-ml   # ML quality: golden datasets, determinism, invariants\nmake bench     # performance benchmarks → BENCHMARKS.md\n```\n\n| Layer | Tools |\n|-------|-------|\n| Lint + format | ruff (check + format) |\n| Typecheck | mypy (strict for `core\u002F`) |\n| Unit tests | pytest — 51 tests: guard, profit, conformal, splits, PII, sql_guard, counterfactuals, signing |\n| Property tests | hypothesis — 12 tests: profit monotonicity, conformal coverage, PII masking, CF bounds |\n| Integration | TestClient — upload → train → predict → batch → keys → 422 errors |\n| LLM contract | mock client, fixtures, spy test (\"raw rows don't leave\"), number validator, causal-word stop-list |\n| Security | key hash, 401\u002F403, sql_guard DML\u002FDDL\u002FCTE injection, PII exclusion + masking |\n| Frontend | vitest + eslint + tsc — 10 component tests |\n| ML quality | golden datasets (Telco AUC range), leak detection, determinism, robustness, invariance |\n| CI | GitHub Actions: ruff → mypy → tsc\u002Feslint → pytest → coverage ≥ 60% → e2e smoke |\n\n---\n\n## Honesty & Limitations\n\n- **Counterfactuals ≠ causality.** \"Reduce discount → probability drops\" is the model's response\n  to a feature change, not proof that the discount caused the churn.\n- **Conformal guarantee is marginal.** 90% coverage holds on average across predictions,\n  not for every individual object. For heavily imbalanced classes, set coverage may exceed α —\n  that's a mathematical property of the method (see [DECISIONS.md](DECISIONS.md) D-12).\n- **Small datasets give wide intervals.** 200 rows → the interval is nearly useless.\n  We show this honestly instead of hiding it behind a single number.\n- **Profit in rubles is only as good as your assumptions.** All formulas and coefficients\n  are expandable in the UI. The \"+1.84M ₽\" is true exactly to the extent your\n  cost\u002Fbenefit estimates are true.\n- **LLM never affects the numbers.** Training, probabilities, intervals, thresholds, profit —\n  all deterministic code. LLM writes texts only, and those pass a number validator\n  that rejects any number not present in the computed fields.\n- **Time-series forecasting (v0.3)** is pragmatic: lags + rolling stats + calendar features,\n  one series at a time. Strong exotic seasonality is not modeled (DECISIONS.md D-10).\n\n---\n\n## Tech Stack\n\n| Layer | |\n|-------|-|\n| Backend | Python 3.12, FastAPI, Pydantic v2, SSE, asyncio jobs + ProcessPool |\n| ML | scikit-learn, CatBoost, LightGBM, Optuna, SHAP, own split-conformal |\n| Data | DuckDB (data), SQLite (metadata), PostgreSQL \u002F MySQL \u002F ClickHouse \u002F SQLite connectors (read-only) |\n| Frontend | React 19, TypeScript, Vite, Recharts, CSS custom properties (no UI kits) |\n| MCP | FastMCP (stdio + HTTP, Bearer auth) |\n| Infra | Docker, docker-compose, GitHub Actions, pre-commit |\n| Testing | pytest + hypothesis + vitest + Playwright + ruff + mypy + bandit |\n\n---\n\n## License\n\nMIT — like all [Ivor's Lab](https:\u002F\u002Fgithub.com\u002FMarkIvor) repositories.\n\nTelco Customer Churn © IBM (Apache 2.0 mirror), California Housing from A. Géron's course —\nboth included in `demo-data\u002F` for offline demos.\n","PredictorLab 是一个面向业务分析师和数据工程师的自托管表格数据机器学习平台，专注于构建可信赖、可落地的预测模型。其核心功能包括自动检测并防止数据泄露、生成符合置信度要求的共形预测区间、基于业务成本优化分类阈值、提供可操作的反事实解释，并内置 REST API 和 MCP 服务接口。技术上融合 DuckDB 轻量查询、CatBoost\u002FLightGBM 模型引擎、FastAPI 服务框架及可解释 AI 组件。适用于无专职数据科学团队的中小型企业、咨询公司交付场景或需本地化部署、关注预测可信度与业务损益对齐的分析任务。",2,"2026-11-24 04:33:46","CREATED_QUERY"]