Spaces:
Sleeping
Sleeping
File size: 4,015 Bytes
08123aa |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
# 🐳 Running Optimization with Docker
Yes! You can absolutely use Docker to run the optimization code. This is actually **recommended** because:
✅ **Isolated environment** - No conflicts with your system Python
✅ **Reproducible** - Same results every time
✅ **Easy cleanup** - Just remove the container when done
✅ **Resource control** - Limit CPU/memory usage
## Quick Start (3 Commands)
```bash
# 1. Make script executable (one time)
chmod +x run_optimization_docker.sh
# 2. Run optimization
./run_optimization_docker.sh
# 3. That's it! Results are saved to content/models/
```
## What Gets Created
The Docker setup includes:
1. **`Dockerfile.optimization`** - Docker image definition
2. **`docker-compose.optimization.yml`** - Easy container management
3. **`run_optimization_docker.sh`** - One-command runner script
4. **`DOCKER_OPTIMIZATION.md`** - Detailed documentation
## Simple Usage Examples
### Run Full Optimization
```bash
./run_optimization_docker.sh
```
Takes ~1-2 hours, 100 trials per model
### Faster Run (50 trials)
```bash
./run_optimization_docker.sh --trials 50
```
Takes ~30-60 minutes
### Run Feature Analysis
```bash
./run_optimization_docker.sh --script feature_importance_analysis.py
```
Takes ~5-10 minutes
### Compare Results
```bash
./run_optimization_docker.sh --script compare_models.py
```
## Using Docker Compose
If you prefer docker-compose:
```bash
# Build and run
docker-compose -f docker-compose.optimization.yml up --build
# View logs
docker-compose -f docker-compose.optimization.yml logs -f
# Stop when done
docker-compose -f docker-compose.optimization.yml down
```
## Using Docker Directly
```bash
# Build image
docker build -f Dockerfile.optimization -t heart-optimization .
# Run optimization
docker run --rm \
-v "$(pwd)/content:/app/content" \
-v "$(pwd)/model_assets:/app/model_assets:ro" \
heart-optimization
```
## Results Location
All results are automatically saved to your host machine:
- `content/models/model_metrics_optimized.csv` - Performance metrics
- `content/models/*_optimized.joblib` - Optimized models
- `content/models/ensemble_info_optimized.json` - Ensemble configuration
- `content/reports/` - Feature importance visualizations
## Resource Requirements
**Minimum:**
- 4GB RAM
- 2 CPU cores
- 5GB disk space
**Recommended:**
- 8GB RAM
- 4 CPU cores
- 10GB disk space
## Time Estimates
| Configuration | Time |
|--------------|------|
| 30 trials | ~20-30 min |
| 50 trials | ~30-60 min |
| 100 trials | ~1-2 hours |
| 200 trials | ~2-4 hours |
## Troubleshooting
### Docker not running
```bash
# Check Docker status
docker info
# Start Docker Desktop (if on Mac/Windows)
# Or: sudo systemctl start docker (Linux)
```
### Out of memory
```bash
# Reduce trials
./run_optimization_docker.sh --trials 30
# Or reduce timeout
STUDY_TIMEOUT=1800 ./run_optimization_docker.sh
```
### Data file not found
```bash
# Verify data exists
ls -lh content/cardio_train_extended.csv
```
## Advanced Options
### Custom Resource Limits
Edit `docker-compose.optimization.yml`:
```yaml
deploy:
resources:
limits:
cpus: '8' # Use more CPUs
memory: 16G # More RAM
```
### Environment Variables
```bash
N_TRIALS=50 STUDY_TIMEOUT=1800 ./run_optimization_docker.sh
```
### Interactive Shell
```bash
docker-compose -f docker-compose.optimization.yml run --rm optimization bash
```
## Next Steps
1. ✅ Run `./run_optimization_docker.sh`
2. ✅ Wait for completion (1-2 hours)
3. ✅ Check results in `content/models/`
4. ✅ Compare with baseline using `compare_models.py`
5. ✅ Deploy optimized models
## Full Documentation
For detailed instructions, see:
- **[DOCKER_OPTIMIZATION.md](DOCKER_OPTIMIZATION.md)** - Complete Docker guide
- **[QUICK_START.md](QUICK_START.md)** - General quick start
- **[IMPROVEMENTS.md](IMPROVEMENTS.md)** - Improvement details
---
**Pro Tip:** Run optimization overnight or during lunch break. The container will save all results automatically!
|