Spaces:
Sleeping
Sleeping
uploaded the related files
Browse filesFiles changed (3)
- app.pyAdded+46
- requirements.txtAdded+53
- water_potability_model.pklAdded+3
12345678910111213141516171819202122232425262728293031323334353637383940414243444546import gradio as grimport pickleimport pandas as pdimport numpy as np
with open('water_potability_model.pkl', 'rb') as f: model = pickle.load(f);
def predict_water_potability(ph, hardness, solids, chloramines, sulfate, conductivity, organic_carbon, trihalomethanes, turbidity): input_df = pd.DataFrame([[ph, hardness, solids, chloramines, sulfate, conductivity, organic_carbon, trihalomethanes, turbidity]], columns=['ph', 'Hardness', 'Solids', 'Chloramines', 'Sulfate', 'Conductivity', 'Organic_carbon', 'Trihalomethanes', 'Turbidity']) prediction = model.predict(input_df)[0]
if prediction == 1: return "The water is potable." else: return "The water is not potable."
input = [ gr.Slider(0.0,14.0,step=0.1,label="pH",value=7.0), gr.Slider(0.0,350.00,step=0.1,label="Hardness",value=200.0), gr.Slider(0.0,70000.0,step=1.0,label="Solids",value=20000.0), gr.Slider(0.0, 15.0, step=0.1, label="Chloramines", value=7.0), gr.Slider(0.0, 500.0, step=0.1, label="Sulfate", value=330.0), gr.Slider(0.0, 800.0, step=0.1, label="Conductivity", value=420.0), gr.Slider(0.0, 30.0, step=0.1, label="Organic Carbon", value=14.0), gr.Slider(0.0, 130.0, step=0.1, label="Trihalomethanes", value=66.0), gr.Slider(0.0, 10.0, step=0.1, label="Turbidity", value=4.0)]
output = [gr.Textbox(label="Predictions")]
demo = gr.Interface( fn=predict_water_potability, inputs=input, outputs=output, title="Water Potability Prediction", description="it will predict whether the water is potable or not")
if __name__ == "__main__": demo.launch(share=True)1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253annotated-doc==0.0.4annotated-types==0.7.0anyio==4.13.0audioop-lts==0.2.2brotli==1.2.0certifi==2026.4.22click==8.3.3fastapi==0.136.1filelock==3.29.0fsspec==2026.3.0gradio==6.13.0gradio_client==2.5.0groovy==0.1.2h11==0.16.0hf-gradio==0.4.1hf-xet==1.4.3httpcore==1.0.9httpx==0.28.1huggingface_hub==1.11.0idna==3.13Jinja2==3.1.6joblib==1.5.3markdown-it-py==4.0.0MarkupSafe==3.0.3mdurl==0.1.2numpy==2.4.4orjson==3.11.8packaging==26.1pandas==3.0.2pillow==12.2.0pydantic==2.13.3pydantic_core==2.46.3pydub==0.25.1Pygments==2.20.0python-dateutil==2.9.0.post0python-multipart==0.0.26pytz==2026.1.post1PyYAML==6.0.3rich==15.0.0safehttpx==0.1.7scikit-learn==1.6.1scipy==1.17.1semantic-version==2.10.0shellingham==1.5.4six==1.17.0starlette==1.0.0threadpoolctl==3.6.0tomlkit==0.14.0tqdm==4.67.3typer==0.24.2typing-inspection==0.4.2typing_extensions==4.15.0uvicorn==0.46.0123version https://git-lfs.github.com/spec/v1oid sha256:26ae6a25549217c2a461a48f2434a58d324bb00b3c2539ca9221caa1a2307926size 182506app.pyAdded+46
requirements.txtAdded+53
water_potability_model.pklAdded+3