An intelligent aquaculture farm management system powered by machine learning.
- Water Quality Engine (WQE): Analyze, classify, and predict water quality
- Anomaly Detection: Detect sensor failures and unusual patterns
- Time-Series Prediction: Forecast pH, DO, temperature, and ammonia
- Actionable Recommendations: Get expert-system recommendations
- REST API: Deploy as a service
# Clone or navigate to the project
cd aquaculture_ai
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# or
.\venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtfrom src.engines.water_quality import WaterQualityEngine
# Initialize engine
engine = WaterQualityEngine()
# Generate synthetic data and train all models
results = engine.train_all(n_synthetic=5000)
# Analyze current water quality
analysis = engine.analyze({
"pH": 7.5,
"DO": 5.2,
"temperature": 28.5,
"ammonia": 0.3
})
print(f"WQI Score: {analysis['wqi_score']}")
print(f"Quality: {analysis['status']['quality_class']}")
print(f"Stress Level: {analysis['status']['stress_level']}")
print(f"Alerts: {len(analysis['alerts'])}")
print(f"Recommendations: {analysis['recommendations']}")from src.engines.water_quality import WaterQualityEngine
from src.api.endpoints import run_server
# Initialize and train engine
engine = WaterQualityEngine()
engine.train_all()
# Start API server
run_server(host="0.0.0.0", port=8000, engine=engine)Then access:
- API Docs: http://localhost:8000/docs
- Health Check: http://localhost:8000/health
aquaculture_ai/
├── src/
│ ├── config.py # Configuration & thresholds
│ ├── data/
│ │ ├── loader.py # Data loading
│ │ ├── cleaner.py # Data cleaning
│ │ ├── preprocessor.py # Feature engineering
│ │ └── schema.py # Data schema validation
│ ├── engines/
│ │ └── water_quality.py # Main Water Quality Engine
│ ├── models/
│ │ ├── classifier.py # XGBoost classifier
│ │ ├── lstm_predictor.py # LSTM time-series
│ │ └── anomaly_detector.py # Isolation Forest
│ ├── utils/
│ │ ├── metrics.py # Evaluation metrics
│ │ ├── visualization.py # Plotting
│ │ └── alerts.py # Alert system
│ └── api/
│ └── endpoints.py # FastAPI endpoints
├── notebooks/ # Training notebooks
├── data/ # Data storage
├── saved_models/ # Trained models
└── tests/ # Unit tests
The WQE provides three main models:
Classifies water quality into categories:
- Excellent (WQI > 85)
- Good (WQI 70-85)
- Moderate (WQI 55-70)
- Poor (WQI 40-55)
- Dangerous (WQI < 40)
Predicts next 6-24 hours of:
- pH
- Dissolved Oxygen (DO)
- Temperature
- Ammonia
Detects:
- Sensor failures
- Sudden spikes
- Unusual patterns
Key thresholds in config.py:
| Parameter | Safe Range | Optimal |
|---|---|---|
| pH | 6.0 - 9.0 | 7.5 |
| DO | 4.0+ mg/L | 6.0 mg/L |
| Temperature | 24-32°C | 26-30°C |
| Ammonia | < 0.5 mg/L | < 0.02 mg/L |
| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/analyze |
POST | Analyze water quality |
/predict |
POST | Predict future values |
/train |
POST | Train models |
/alerts |
GET | Get active alerts |
/thresholds |
GET | Get thresholds |
This project is designed to support additional engines:
- Growth Prediction Engine
- Survival Risk Engine
- Feeding Efficiency Engine
- Disease & Medicine Engine
- Yield Prediction Engine
- Root Cause & Recommendation Engine
MIT License