Instructions to use DarkNeuronAI/darkneuron-hydrasense-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use DarkNeuronAI/darkneuron-hydrasense-v1 with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("DarkNeuronAI/darkneuron-hydrasense-v1", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
| import pandas as pd | |
| import joblib | |
| # Load the saved pipeline | |
| try: | |
| model = joblib.load('water_potability_model.pkl') | |
| print("Model loaded successfully!") | |
| except FileNotFoundError: | |
| print("Error: The file 'water_potability_model.pkl' was not found.") | |
| exit() | |
| except Exception as e: | |
| print("An unexpected error occurred while loading the pipeline:", e) | |
| exit() | |
| # Create a new water sample | |
| # IMPORTANT: Use the same feature order and names as in training | |
| sample_data = { | |
| 'ph': [7.2], | |
| 'Hardness': [180], | |
| 'Solids': [15000], | |
| 'Chloramines': [8.3], | |
| 'Sulfate': [350], | |
| 'Conductivity': [450], | |
| 'Organic_carbon': [10], | |
| 'Trihalomethanes': [70], | |
| 'Turbidity': [3] | |
| } | |
| # Convert to DataFrame with proper column names | |
| sample_df = pd.DataFrame(sample_data) | |
| # Make prediction | |
| try: | |
| prediction = model.predict(sample_df) | |
| result = "Potable" if prediction[0] == 1 else "Not Potable" | |
| print("Sample Prediction:", result) | |
| except ValueError as e: | |
| print("Error: Sample input has incorrect shape or type.", e) | |
| except Exception as e: | |
| print("An unexpected error occurred during prediction:", e) |