Accelerate clinical research. Reduce costs. Minimize patient risk. Maximize trial success.
InSilico is an AI-powered platform that revolutionizes clinical trial design through Digital Twin technology and explainable machine learning. Powered by 250,000+ real patient records from the CDC BRFSS dataset, InSilico enables researchers to simulate patient outcomes, validate intervention efficacy, and optimize trial cohortsโall before enrolling a single human subject.
Built during HackPrinceton, this project combines cutting-edge generative AI, statistical rigor, and medical informatics to transform clinical research from a high-risk gamble into precision science.
Traditional clinical trials face a perfect storm of challenges:
| Challenge | Impact | Cost |
|---|---|---|
| Extreme Costs | Bringing a drug to market requires $2.6B+ investment | ๐ฐ Prohibitive for smaller biotech firms |
| Patient Risk | Early-phase trials expose vulnerable populations to unknown risks | |
| High Failure Rates | 90% of drugs fail in clinical trialsโoften due to suboptimal cohort selection | ๐ Wasted resources |
| Extended Timelines | 10+ years from discovery to FDA approval | โฑ๏ธ Patient populations waiting for treatments |
InSilico provides a Digital Sandbox for risk-free, cost-effective trial simulation:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Real Patient Data (250K+ BRFSS records) โ
โ โ โ
โ TVAE Synthetic Patient Generation โ
โ (Privacy-preserving, Statistically Validated) โ
โ โ โ
โ Centroid Recovery + Gamma Formula Simulation โ
โ (Drug + Biomarker Effects) โ
โ โ โ
โ SHAP Explainability Layer โ
โ (Why this patient responds to treatment) โ
โ โ โ
โ Trial Success Prediction & Cohort Optimization โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Key Capabilities:
- โ Simulate Intervention Impact: Model how a patient's risk profile changes when biomarkers (BMI, Blood Pressure, A1C) are modified by a drug
- โ Synthetic Control Arms: Generate thousands of high-fidelity synthetic patients to boost statistical power
- โ Explainable Risk Mapping: Use SHAP values to explain exactly why a patient's risk is dropping or rising
- โ PDF Analysis Engine: Extract drug mechanisms from trial PDFs using RAG + Google Gemini AI
- โ Interactive Dashboard: Real-time visualization of trial outcomes and risk trajectories
graph TB
subgraph Data["๐ Data Layer"]
CDC["CDC BRFSS Dataset<br/>250K+ Records"]
PDF["Medical PDFs<br/>Trial Documents"]
end
subgraph ML["๐ค ML Pipeline"]
TVAE["TVAE Encoder<br/>Synthetic Patient Gen"]
VAL["Statistical Validation<br/>KS Test, Wasserstein"]
RF["Random Forest<br/>Risk Classifier"]
end
subgraph Engine["โ๏ธ Simulation Engine"]
CENT["Centroid Recovery<br/>Health โ Disease Vector"]
GAMMA["Gamma Formula<br/>Drug Potency Scoring"]
SIM["Patient Trajectory<br/>Simulation"]
end
subgraph Explain["๐ Explainability"]
SHAP["SHAP Values<br/>Feature Attribution"]
VIZ["Risk Radar Charts<br/>Visual Analytics"]
end
subgraph API["๐ API Layer"]
FAST["FastAPI Backend<br/>3 Core Endpoints"]
end
subgraph Frontend["๐ป UI Layer"]
NEXT["Next.js Dashboard<br/>Interactive Sim"]
end
CDC -->|Train| TVAE
PDF -->|Parse & Extract| GAMMA
TVAE -->|Validate| VAL
VAL -->|Train| RF
RF -->|Generate Twins| SIM
CENT -->|Vector Transform| SIM
GAMMA -->|Impact Score| SIM
SIM -->|Patient Data| SHAP
SHAP -->|Explanations| VIZ
RF -->|Score| API
SIM -->|Simulate| API
API -->|Data| FAST
FAST -->|Results| NEXT
VIZ -->|Charts| NEXT
style Data fill:#e1f5ff
style ML fill:#f3e5f5
style Engine fill:#fff3e0
style Explain fill:#f1f8e9
style API fill:#fce4ec
style Frontend fill:#ede7f6
Synthetic Patients (TVAE): 250K BRFSS records โ 50K synthetic patients | Validation: KS test โ , Wasserstein distance โ , PCA manifold โ | Disease prevalence: 13.9% real vs 13.3% synthetic (<1% error)
Risk Model (Random Forest): 12 biomarkers โ Diabetes risk + SHAP importance | Accuracy: ~78% on holdout | Latency: <1ms per prediction
Algorithm:
- Calculate health centroid (
$\mu_H$ ) and disease centroid ($\mu_D$ ) - Compute recovery vector:
$\vec{r} = \mu_H - \mu_D$ - Apply drug effect:
$Patient_{new} = Patient_{old} + \gamma \cdot \vec{r}$ - Re-score with Random Forest
Gamma (Drug Potency): Range [0, 1], auto-extracted from MoA text
- Weight loss โ 0.12 | A1C reduction โ 0.18 | Lifestyle intervention โ 0.25
Every result includes SHAP feature attribution showing how each biomarker contributes to risk changes:
{"baseline_risk": 0.42, "simulated_risk": 0.28, "risk_reduction": 0.14,
"shap_deltas": {"BMI": -0.08, "HighBP": -0.04, "PhysActivity": -0.02}}| Endpoint | Purpose |
|---|---|
GET /health |
System status & model info |
POST /score-patient |
Baseline risk assessment + SHAP |
POST /simulate-trial |
Full intervention simulation |
POST /parse-trial-pdf |
Extract drug MoA from PDFs (RAG + Gemini) |
Quick Example: POST /simulate-trial โ Returns baseline/simulated risk with SHAP attributions
Built with Next.js 14 + TypeScript + Radix UI
-
/- Landing Page- Hero section with project vision
- Feature highlights
- Interactive Spline 3D animation
-
/simulator- Trial Simulator- Patient profile form (12 biomarkers)
- Drug MoA input interface
- Real-time risk visualization
- SHAP radar chart (6-axis: BMI, BP, Cholesterol, Activity, Gen Health, Phys Health)
-
/assistant- AI Assistant- Chat interface for MoA queries
- PDF upload & analysis
- Trial design recommendations
- Patient Profile Form: Validated input for 12 patient features
- Trial Charts: Risk trajectory visualization, cohort distribution
- Mini Bot: Contextual help and recommendations
- Theme Provider: Dark/light mode support
โ ๏ธ Note: Features in this section are planned for Phase 2 (Q2-Q4 2026). Current MVP focuses on core simulation engine.
Planned Capabilities:
- ๐ฎ Wearable Integration (Q2 2026): Real-time data from Apple Watch, Fitbit, Garmin
- ๐ฎ Calendar Sync (Q3 2026): Auto-schedule appointments via Google Calendar, Apple Calendar, Outlook
- ๐ฎ Apple HealthKit (Q4 2026): Bi-directional sync with Apple Health, medication adherence tracking
- ๐ฎ Agentic Intelligence (Q2+): Open Claw framework for autonomous patient engagement, dropout prediction, adaptive interventions
- ๐ฎ Smart Alerts (Q3+): SMS/push notifications for medication reminders, clinical alerts, risk escalations
| Layer | Technology | Purpose |
|---|---|---|
| Backend | FastAPI + Python 3.11 | REST API, core simulation engine |
| ML/Data Science | scikit-learn, pandas, NumPy | Random Forest, data processing |
| Synthetic Data | SDV (TVAE) | Generate synthetic patients |
| Explainability | SHAP | Feature attribution & interpretation |
| PDF Processing | PyPDF, Google Gemini AI | Extract trial data from PDFs |
| Agentic Framework | Open Claw | Multi-agent orchestration, tool use |
| Agent Memory | LangChain + ChromaDB | Context persistence, retrieval |
| Health Integrations | Apple HealthKit, Fitbit API, Google Fit | Real-time wearable data streaming |
| Calendar Integration | Google Calendar API, Microsoft Graph | Appointment scheduling & sync |
| Messaging | Twilio SMS + Firebase Cloud Messaging | Patient notifications & reminders |
| Frontend | Next.js 14, TypeScript, React | Interactive dashboard |
| UI Components | Radix UI, Tailwind CSS | Accessible component library |
| Visualization | Matplotlib, Seaborn, Chart.js | Data visualization |
| Database | ChromaDB, PostgreSQL (planned) | Vector & relational storage |
| Deployment | Uvicorn, Vercel, Docker | Backend/frontend deployment |
Potential Outcome Improvements (Q4 2026+):
- โ 65% dropout rate (23% โ 8%)
- โ 400% faster adverse event detection (<24h vs 2-3 weeks)
- โ 25% treatment adherence (71% โ 89%)
- โ 300% faster efficacy determination (3 weeks vs 12 weeks)
- โ 6600x more data points per patient (1000+ vs ~15)
- Python 3.11+
- Node.js 18+ (for frontend)
- pip & npm/pnpm
# Install Python dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Add your GEMINI_API_KEY to .env
# Run the backend server
python -m uvicorn backend.app:app --reload --port 8000Backend will be available at: http://localhost:8000
API documentation (Swagger UI): http://localhost:8000/docs
cd latestfrontend
# Install dependencies
pnpm install
# or: npm install
# Run development server
pnpm dev
# or: npm run devFrontend will be available at: http://localhost:3000
# Generate synthetic patients & validate
jupyter notebook Hack_Princeton_final.ipynb
# Or run simulations directly
python insilico_simulation.pytrialforge/
โโโ backend/ # FastAPI backend
โ โโโ app.py # Main API server
โ โโโ model_loader.py # Load ML artifacts
โ โโโ rag_pipeline.py # RAG for PDF analysis
โ โโโ pdf_parser.py # PDF extraction
โ โโโ gamma_formula.py # Gamma calculation
โ โโโ endpoint_extractor.py # API helpers
โ โโโ calibration/
โ โ โโโ coefficients.json # Model coefficients
โ โ โโโ reference_drugs.json # Drug MoA database
โ โโโ model_artifacts/
โ โโโ risk_model.joblib # Trained Random Forest
โโโ latestfrontend/ # Next.js frontend
โ โโโ app/ # Page routes
โ โ โโโ page.tsx # Landing page
โ โ โโโ assistant/page.tsx # AI assistant
โ โ โโโ simulator/page.tsx # Trial simulator
โ โโโ components/ # Reusable UI components
โ โโโ lib/api.ts # API client
โ โโโ context/simulator-context.tsx # State management
โโโ Hack_Princeton_final.ipynb # Core ML notebook
โโโ insilico_simulation.py # Simulation engine
โโโ insilico_moa.py # MoA parser
โโโ requirements.txt # Python dependencies
โโโ readme.Md # This file
Novel approach to simulate drug effects by treating the health-disease spectrum as a vector space. Unlike traditional statistical models, this enables intuitive visualization of intervention impact.
Automated extraction of drug potency from clinical documents via LLM + RAG, eliminating manual parameter entry.
TVAE-generated patients maintain statistical fidelity while ensuring zero re-identification risk (HIPAA-compliant).
Every simulation result includes SHAP decomposition, enabling researchers to understand why a patient responds to treatment.
From PDF upload โ MoA extraction โ gamma estimation โ simulation โ SHAP explanation, all automated and transparent.
Example: Testing a weight-loss intervention on diabetes cohort
- Baseline diabetes risk: 42%
- Post-intervention risk: 28% (33% reduction)
- Responder rate: 42% of cohort shows significant improvement
- Time to answer: <2 seconds (real-time)
- Pre-trial validation: Identify high-responder populations before enrollment
- Reduced trial duration: Optimize cohort composition for faster recruitment
- Minimized dropouts: Focus on patients likely to benefit from intervention
- Synthetic patient distributions match real BRFSS distributions with <1% KS-test p-value
- Random Forest achieves ~78% accuracy on diabetes prediction
- SHAP explanations align with known clinical risk factors
This project integrates multiple advanced ML techniques:
- Generative Modeling: TVAE for privacy-preserving synthetic data
- Ensemble Methods: Random Forest for robust risk prediction
- Game Theory: SHAP for explainable AI (based on Shapley values)
- Statistical Testing: KS test, Wasserstein distance for distribution validation
- Information Geometry: PCA manifold analysis for feature space visualization
References:
- Xu, L., et al. (2019). "Modeling tabular data using GANs" (ICLR)
- Lundberg, S. M., & Lee, S. I. (2017). "A unified approach to interpreting model predictions" (NeurIPS)
- CDC BRFSS Dataset: https://www.cdc.gov/brfss/
Open source. Built for the clinical research community.
Built during HackPrinceton 2026 by engineers passionate about democratizing clinical research through AI.
For questions about the system:
- Check
/docsendpoint for API documentation - Review
Hack_Princeton_final.ipynbfor ML pipeline details - Explore frontend components in
latestfrontend/components/
InSilico: Where precision medicine meets machine learning. Test outcomes before enrolling patients. Transform trials from risk into science. ๐