"TensorFlow.js LSTM model for smart irrigation predictions, optimized for edge computing in 2025 Tunisia trials. Part of the 'Hybrid WiFi/LoRa Networks' research (IOP Publishing). Open-source code and data."
# LSTM Smart Irrigation Model (TensorFlow.js)
## Overview
This repository contains the `predictionWorker.js` script, a TensorFlow.js-based LSTM model for smart irrigation predictions. Developed for the 2025 Tunisia field trials, it supports the "Hybrid WiFi/LoRa Networks for AI-Driven Smart Irrigation" research (IOP Publishing). The model optimizes edge computing for 24-hour soil moisture forecasts, anomaly detection, and soil illness inference using gas sensor data.
## Files
- `predictionWorker.js`: Web Worker script for model initialization, training, and prediction.
- `index.html` (optional): Basic test harness to run the worker.
- Data: Linked from Hybrid WiFi/LoRa AI Irrigation (20,223 records, Jan-Jun 2025).
## Setup
1. Ensure a modern browser (e.g., Chrome) with internet access for TensorFlow.js CDN.
2. No local installation needed; script loads `
cdn.jsdelivr.net`.
## Usage
1. Clone the repo: `git clone
github.com`.
2. Open `index.html` in a browser or integrate the worker in your project.
3. Load CSV data (e.g., `bizerte_data.csv`) via a parser like PapaParse.
4. Send messages to the worker:
- Init: `worker.postMessage({ type: 'init' });`
- Train: `worker.postMessage({ type: 'train', historyData: [...] });`
- Predict: `worker.postMessage({ type: 'predict', historyData: [...] });`
Example response: `{ type: 'prediction', predictions: [val1, val2, ...], isAnomaly: true, illnessSuggestion: 'Possible surhumidification' }`.
## Notes
- LSTM: 64 units, dropout=0.3, Adam lr=0.0001, 50-time-step sequences.
- Requires >=51 data points for training/prediction.
- Part of open-source research; see paper at [IOP link TBD].
- Issues? Raise at Issues tab.
## License
MIT License (permissive use).