Metadata-Version: 2.4
Name: data_advisor
Version: 0.4.0
Summary: Autonomous Dataset Auditor, Diagnostic Engine & IoT Exam Code Bank for timed data analysis and IoT practical examinations.
Author: Principal Data Science Architect
License-Expression: MIT
Keywords: data-analysis,eda,data-science,hypothesis-testing,code-generation,machine-learning,automated-eda,pandas,scipy,scikit-learn
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: pandas>=2.0.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: scipy>=1.10.0
Requires-Dist: scikit-learn>=1.2.0
Requires-Dist: matplotlib>=3.7.0
Requires-Dist: seaborn>=0.12.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"

# DataAdvisor (`data-advisor` v0.4.0)

> **Autonomous Dataset Auditor, Diagnostic Engine & IoT Exam Code Bank**  
> Engineered for students, practitioners, and engineers during timed practical examinations and data analysis tasks.  
> **100% Offline**: Requires **zero internet connection** to inspect datasets, search code, or retrieve solutions.

---

## ⚡ Quickstart

### 1. Search Any Keyword Across the Code Bank
Search instantly across all IoT questions, Arduino sketches, Python protocols, and Machine Learning models:
```bash
# Terminal CLI:
data-advisor --search "dht22"
data-advisor --search "coap"
data-advisor --search "mqtt"
data-advisor --search "random forest"
data-advisor --list                    # List all 36 available modules
```

Or inside a Python script / Jupyter Notebook:
```python
from data_advisor import search

# List all available questions and experiments:
search()

# Search for any topic or keyword:
search("dht22")
search("coap")
search(["esp32", "mqtt"])
```

---

### 2. View / Retrieve Complete Question & Code Files (`get_file`)
Retrieve the full question statement, README setup instructions, and all source codes:
```bash
# Terminal CLI:
data-advisor --get Q1
data-advisor --get Q3
data-advisor --get CQ1
data-advisor --get SQ1
data-advisor --get 15 --line-numbers
```

Or inside Python:
```python
from data_advisor import get_file, read_file

# Print the complete question, instructions, and clean code:
get_file("CQ1")
get_file("Q3", line_numbers=True)

# Or return the content as a string:
content = read_file("08")
```

---

### 3. Audit Any Exam Dataset & Generate Python Code (`data_advisor`)
When given an unknown dataset (CSV, TSV, Excel, Parquet):
```bash
# Terminal CLI: Print diagnostic report + executable Python solution:
data-advisor exam_dataset.csv --code

# Specify target column and save generated Python script to a file:
data-advisor exam_dataset.csv --target churn --output solution.py
```

Or inside Python:
```python
from data_advisor import data_advisor

# 1-Line: Outputs diagnostic report AND prints full executable Python code:
data_advisor("exam_dataset.csv")

# With target variable and script export:
data_advisor("exam_dataset.csv", target="churn", output_script="solution.py")
```

---

## 📄 Master Files in Root Directory

- [**`combined.txt`**](combined.txt): A single master file combining **all 36 code modules** with zero comments inside code blocks (ready for direct copy-pasting), searchable jump tags (`[EXPERIMENT XX]`, `[QUESTION QX]`, `[COMBINED QUESTION CQX]`, `[SIMPLE QUESTION SQX]`), and an interactive Table of Contents.
- [**`notes.txt`**](notes.txt): Complete IoT practical examination cheat sheet covering one-time `pip install` commands, terminal execution order, protocol port mappings (CoAP 5683, MQTT 1883, Streamlit 8501), dataset-to-model feature matrices, Supabase REST syntax, and common exam error fixes.

---

## 📦 IoT Code Bank Architecture (36 Comprehensive Modules)

The `code_bank/` directory contains **36 comprehensive modules** divided into four logical tiers:

### Complete Index of All 36 Modules:

#### Part 1: Standard Lab Experiments (01 to 17)
| # | Question File | Category / Topic | Included Code Files |
|---|:---|:---|:---|
| **1** | `01_dht22_serial.txt` | ESP32 DHT22 Temperature & Humidity (Serial) | `1. sketch.ino`, `2. diagram.json`, `3. libraries.txt` |
| **2** | `02_ldr_serial.txt` | ESP32 LDR Light Intensity Monitoring | `1. sketch.ino`, `2. diagram.json` |
| **3** | `03_pir_serial.txt` | ESP32 PIR Motion Detection | `1. sketch.ino`, `2. diagram.json` |
| **4** | `04_mqtt_esp32_python.txt` | ESP32 MQTT Publisher & Python Subscriber | `1. sketch.ino`, `2. subscriber.py`, `3. diagram.json`, `4. libraries.txt` |
| **5** | `05_http_rest_supabase.txt` | HTTP REST API Cloud Storage & Web Dashboard | `1. send_http_data.py`, `2. app_http.py` |
| **6** | `06_mqtt_cloud_dashboard.txt` | MQTT Cloud Bridge & Streamlit Dashboard | `1. publisher.py`, `2. mqtt_bridge.py`, `3. app.py` |
| **7** | `07_thingsboard_simulation.txt` | ThingsBoard MQTT Telemetry Simulation | `1. simulate_thingsboard.py`, `2. environmental_dashboard.json` |
| **8** | `08_coap_server_client_dashboard.txt` | CoAP Server & Client Dashboard | `1. server.py`, `2. client.py` |
| **9** | `09_mqtt_hivemq_mosquitto_dual.txt` | Dual MQTT (HiveMQ Public & Mosquitto Local) | `1. dual_broker.py` |
| **10** | `10_coap_openmeteo_cloud.txt` | CoAP Environmental Monitoring & Cloud DB | `1. server.py`, `2. app.py` |
| **11** | `11_iss_tracker.txt` | Real-Time ISS Location Tracker & Plotter | `1. iss_tracker.py` |
| **12** | `12_earthquake_dashboard.txt` | USGS Earthquake Analysis Dashboard | `1. app.py` |
| **13** | `13_weather_analysis.txt` | Open-Meteo Weather Trend Visualizations | `1. weather_analysis.py` |
| **14** | `14_air_quality_kochi.txt` | Kochi Air Quality Dashboard (PM2.5, PM10, AQI) | `1. app.py` |
| **15** | `15_decision_tree_occupancy.txt` | Decision Tree Room Occupancy Classifier | `1. occupancy_cli.py`, `2. occupancy_app.py` |
| **16** | `16_linear_regression_beijing.txt` | Linear Regression Temperature Prediction | `1. temperature_cli.py`, `2. temperature_app.py` |
| **17** | `17_random_forest_air_quality.txt` | Random Forest 6-Class Air Quality Classifier | `1. air_quality_cli.py`, `2. air_quality_app.py` |

#### Part 2: Official Practical Exam Questions (Q1 to Q4)
| # | Question File | Category / Topic | Included Code Files |
|---|:---|:---|:---|
| **18** | `Q1_dht22_temperature_humidity.txt` | **Section A**: Q1 DHT22 Monitoring [30M] | `1. sketch.ino`, `2. diagram.json`, `3. libraries.txt` |
| **19** | `Q2_ldr_light_intensity.txt` | **Section A**: Q2 LDR Intensity [30M] | `1. sketch.ino`, `2. diagram.json` |
| **20** | `Q3_coap_air_quality_random_forest.txt` | **Section B**: Q3 CoAP Air Quality & RF [30M] | `1. server.py`, `2. client.py`, `3. app.py` |
| **21** | `Q4_coap_weather_decision_tree.txt` | **Section B**: Q4 CoAP Weather & DT [30M] | `1. server.py`, `2. client.py`, `3. app.py` |

#### Part 3: Combined 2-Topic Exam Questions (CQ1 to CQ8)
| # | Question File | Category / Combination | Included Code Files |
|---|:---|:---|:---|
| **22** | `CQ1_coap_linear_regression.txt` | **CoAP** + **Linear Regression** + Streamlit | `1. server.py`, `2. client.py`, `3. app.py` |
| **23** | `CQ2_coap_decision_tree_occupancy.txt` | **CoAP** + **Decision Tree (Occupancy)** + Streamlit | `1. server.py`, `2. client.py`, `3. app.py` |
| **24** | `CQ3_mqtt_decision_tree_occupancy.txt` | **MQTT** + **Decision Tree (Occupancy)** + Streamlit | `1. publisher.py`, `2. subscriber.py`, `3. app.py` |
| **25** | `CQ4_mqtt_random_forest_air_quality.txt` | **MQTT** + **Random Forest (AQI)** + Streamlit | `1. publisher.py`, `2. subscriber.py`, `3. app.py` |
| **26** | `CQ5_mqtt_linear_regression.txt` | **MQTT** + **Linear Regression (Temp)** + Streamlit | `1. publisher.py`, `2. subscriber.py`, `3. app.py` |
| **27** | `CQ6_esp32_serial_ml_occupancy.txt` | **ESP32 Serial (DHT22+LDR)** + **Decision Tree** + Streamlit | `1. esp32_sensors.ino`, `2. serial_classifier.py`, `3. app.py` |
| **28** | `CQ7_mqtt_supabase_cloud.txt` | **MQTT** + **Supabase Cloud DB** + Streamlit | `1. publisher.py`, `2. mqtt_bridge.py`, `3. app.py` |
| **29** | `CQ8_coap_supabase_cloud.txt` | **CoAP** + **Supabase Cloud DB** + Streamlit | `1. server.py`, `2. client_bridge.py`, `3. app.py` |

#### Part 4: Minimal Diagnostic & Verification Scripts (SQ1 to SQ7)
| # | Question File | Target Technology Tested | Included Code Files |
|---|:---|:---|:---|
| **30** | `SQ1_supabase_crud.txt` | Supabase Cloud REST POST & GET Connection | `1. test_supabase.py` |
| **31** | `SQ2_streamlit_minimal.txt` | Streamlit Dashboard Layout, Metrics & Alert Badges | `1. test_app.py` |
| **32** | `SQ3_coap_minimal.txt` | Asynchronous CoAP Server & Client Pair (`aiocoap`) | `1. server.py`, `2. client.py` |
| **33** | `SQ4_mqtt_minimal.txt` | MQTT Publisher & Subscriber Pair (`paho-mqtt`) | `1. publisher.py`, `2. subscriber.py` |
| **34** | `SQ5_ml_minimal.txt` | Decision Tree, Random Forest & Linear Regression | `1. test_models.py` |
| **35** | `SQ6_openmeteo_api.txt` | Direct Open-Meteo REST API Ingestion (`requests`) | `1. test_api.py` |
| **36** | `SQ7_esp32_serial.txt` | ESP32 Serial JSON Transmitter & Python Listener | `1. sketch.ino`, `2. read_serial.py` |

---

## 🔒 100% Offline Capability

- **Zero Network Required**: Does not connect to the internet to run searches, load code files, or inspect datasets.
- **Local Fallback Datasets**: Machine learning scripts support local offline CSV datasets (`city_day.csv`, `PRSA_Data_...csv`, `datatraining.txt`) and include automatic synthetic data generators if dataset files are missing.
- **Local Protocol Testing**: CoAP server/client examples bind to `127.0.0.1:5683` (localhost UDP) and local MQTT uses `localhost:1883`.

---

## 🚀 Building & Publishing to PyPI

### 1. Build the Distribution
```powershell
python -m build
```
*(Generates the universal wheel `.whl` and source distribution `.tar.gz` in `dist/` bundling all 36 code bank modules, `notes.txt`, and `combined.txt`).*

### 2. Upload to PyPI
```powershell
python -m twine upload dist/*
```
- **Username**: `__token__`
- **Password**: `<paste your PyPI API token starting with pypi-...>`

---

## 💻 Installation on Other Machines

On any lab system, exam machine, or virtual environment:
```bash
# Install directly from PyPI
pip install data-advisor

# Or install locally in editable mode
pip install -e .
```

### CLI Command Summary:
| Command | Action |
|:---|:---|
| `data-advisor --list` or `-l` | List all 36 questions & files in the code bank |
| `data-advisor --search "<keyword>"` or `-s` | Search questions matching any keyword or phrase |
| `data-advisor --get <CQ1/Q3/SQ1/08>` or `-g` | Print complete question statement, setup instructions & code |
| `data-advisor <dataset.csv> --code` | Audit dataset and output complete copy-pasteable Python code |
| `data-advisor <dataset.csv> -o run.py` | Save generated Python data science pipeline to `run.py` |
