Upload 5 files
Browse files- .gitattributes +1 -0
- README.md +87 -0
- example_usage.py +40 -0
- gitattributes +35 -0
- requirements.txt +3 -0
- water_potability_model.pkl +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
water_potability_model.pkl filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
metrics:
|
| 6 |
+
- accuracy
|
| 7 |
+
- precision
|
| 8 |
+
- recall
|
| 9 |
+
- f1
|
| 10 |
+
- confusion_matrix
|
| 11 |
+
pipeline_tag: tabular-classification
|
| 12 |
+
library_name: sklearn
|
| 13 |
+
tags:
|
| 14 |
+
- Water Potability
|
| 15 |
+
- Random Forest
|
| 16 |
+
- Standard Scaler
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
# 💧 HydraSense - Water Potability Classifier Model (v1.0)
|
| 20 |
+
|
| 21 |
+
A lightweight **Random Forest + StandardScaler** based water potability prediction model developed by **DarkNeuronAI**.
|
| 22 |
+
It classifies water as **Potable (1)** or **Not Potable (0)** based on chemical and physical features — ideal for simple tabular classification tasks.
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## 🚀 Features
|
| 27 |
+
- Fast and efficient — runs easily on standard laptops
|
| 28 |
+
- Trained with real-world water quality datasets
|
| 29 |
+
- Predicts potability from features like **pH, Hardness, Solids, Chloramines, Sulfate, Conductivity, Organic Carbon, Trihalomethanes, Turbidity**
|
| 30 |
+
- Uses a **pipeline** to automatically scale and preprocess input data
|
| 31 |
+
- Easy to use and integrate
|
| 32 |
+
|
| 33 |
+
---
|
| 34 |
+
|
| 35 |
+
## 🚀 Model Overview
|
| 36 |
+
- **Algorithm:** Random Forest Classifier
|
| 37 |
+
- **Preprocessing:** StandardScaler (automatic feature scaling)
|
| 38 |
+
- **Goal:** Predict whether water is safe to drink (Potable) or unsafe (Not Potable)
|
| 39 |
+
- **Performance:** Accurate classification on real-world datasets
|
| 40 |
+
|
| 41 |
+
---
|
| 42 |
+
|
| 43 |
+
## 🧩 Files Included
|
| 44 |
+
- `water_potability_model.pkl` → Trained Random Forest pipeline (scaler + model)
|
| 45 |
+
- `example_usage.py` → Example code to use the model
|
| 46 |
+
- `requirements.txt` → Dependencies list
|
| 47 |
+
|
| 48 |
+
---
|
| 49 |
+
|
| 50 |
+
## 🏷️ Prediction Labels (Binary)
|
| 51 |
+
- **0:** Not Potable (Unsafe to drink)
|
| 52 |
+
- **1:** Potable (Safe to drink)
|
| 53 |
+
|
| 54 |
+
---
|
| 55 |
+
|
| 56 |
+
## 💡 How to Use (Example Code)
|
| 57 |
+
```python
|
| 58 |
+
from huggingface_hub import hf_hub_download
|
| 59 |
+
import joblib
|
| 60 |
+
import pandas as pd
|
| 61 |
+
|
| 62 |
+
# Download and load the trained pipeline
|
| 63 |
+
pipeline_path = hf_hub_download("DarkNeuron-AI/darkneuron-hydrasense-v1", "water_potability_model.pkl")
|
| 64 |
+
model = joblib.load(pipeline_path)
|
| 65 |
+
|
| 66 |
+
# Example water sample
|
| 67 |
+
sample_data = {
|
| 68 |
+
'ph': [7.2],
|
| 69 |
+
'Hardness': [180],
|
| 70 |
+
'Solids': [15000],
|
| 71 |
+
'Chloramines': [8.3],
|
| 72 |
+
'Sulfate': [350],
|
| 73 |
+
'Conductivity': [450],
|
| 74 |
+
'Organic_carbon': [10],
|
| 75 |
+
'Trihalomethanes': [70],
|
| 76 |
+
'Turbidity': [3]
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
sample_df = pd.DataFrame(sample_data)
|
| 80 |
+
|
| 81 |
+
# Predict potability
|
| 82 |
+
prediction = model.predict(sample_df)
|
| 83 |
+
|
| 84 |
+
print("Prediction:", "💧 Potable" if prediction[0] == 1 else "⚠️ Not Potable")
|
| 85 |
+
```
|
| 86 |
+
|
| 87 |
+
# Developed With ❤️ By DarkNeuronAI
|
example_usage.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import joblib
|
| 3 |
+
|
| 4 |
+
# Load the saved pipeline
|
| 5 |
+
try:
|
| 6 |
+
model = joblib.load('water_potability_model.pkl')
|
| 7 |
+
print("Model loaded successfully!")
|
| 8 |
+
except FileNotFoundError:
|
| 9 |
+
print("Error: The file 'water_potability_model.pkl' was not found.")
|
| 10 |
+
exit()
|
| 11 |
+
except Exception as e:
|
| 12 |
+
print("An unexpected error occurred while loading the pipeline:", e)
|
| 13 |
+
exit()
|
| 14 |
+
|
| 15 |
+
# Create a new water sample
|
| 16 |
+
# IMPORTANT: Use the same feature order and names as in training
|
| 17 |
+
sample_data = {
|
| 18 |
+
'ph': [7.2],
|
| 19 |
+
'Hardness': [180],
|
| 20 |
+
'Solids': [15000],
|
| 21 |
+
'Chloramines': [8.3],
|
| 22 |
+
'Sulfate': [350],
|
| 23 |
+
'Conductivity': [450],
|
| 24 |
+
'Organic_carbon': [10],
|
| 25 |
+
'Trihalomethanes': [70],
|
| 26 |
+
'Turbidity': [3]
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
# Convert to DataFrame with proper column names
|
| 30 |
+
sample_df = pd.DataFrame(sample_data)
|
| 31 |
+
|
| 32 |
+
# Make prediction
|
| 33 |
+
try:
|
| 34 |
+
prediction = model.predict(sample_df)
|
| 35 |
+
result = "Potable" if prediction[0] == 1 else "Not Potable"
|
| 36 |
+
print("Sample Prediction:", result)
|
| 37 |
+
except ValueError as e:
|
| 38 |
+
print("Error: Sample input has incorrect shape or type.", e)
|
| 39 |
+
except Exception as e:
|
| 40 |
+
print("An unexpected error occurred during prediction:", e)
|
gitattributes
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pandas
|
| 2 |
+
scikit-learn
|
| 3 |
+
joblib
|
water_potability_model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e66ec01a9cc1916a5e08243d4136a92c103ac40ad2f5118c2dd0a23f7df2e895
|
| 3 |
+
size 7343234
|