A self-contained Jupyter notebook implementing a Mamdani-type fuzzy logic controller to compute watering duration based on soil moisture and ambient temperature. Built with scikit-fuzzy and matplotlib, it includes visualizations, a rule base, partition testing, and rule conflict checks.
Fuzzy_Assignment_225522M.ipynb— Main notebook with the full implementation and documentation.
- Linguistic variables and membership functions:
- Inputs: Soil moisture (0–100) — dry/moist/humid; Temperature (0–40 °C) — low/medium/high
- Output: Watering duration (0–30 min) — short/medium/long
- 9-rule fuzzy rule base
- Inference demo for sample inputs
- Visualizations of membership functions and output decision
- Validation utilities:
- Partition testing to ensure coverage of fuzzy sets
- Rule conflict testing for contradictory antecedents
- Python 3.8+
- numpy
- scikit-fuzzy
- matplotlib
Install packages on Windows (cmd):
pip install -U scikit-fuzzy numpy matplotlibTip: The notebook’s first cell contains a commented pip install line that you can run inside the notebook if preferred.
- Open the notebook in VS Code (with the Jupyter extension) or Jupyter Lab/Notebook.
- Select a Python environment with the required packages installed.
- Run cells from top to bottom. Plots will display inline, and the computed watering duration will be printed.
- Defines universes of discourse for inputs and output and assigns triangular membership functions.
- Encodes interpretable rules (e.g., dry soil + high temperature → long watering).
- Uses scikit-fuzzy’s control system to perform fuzzification, inference, and defuzzification.
- Provides plots and simple checks to validate the fuzzy set coverage and rule consistency.
- Tune membership function parameters to match your sensor calibration and irrigation needs.
- Extend the rule base or add new inputs (e.g., humidity, sunlight) as needed.