Spaces:
Sleeping
Sleeping
| import pandas as pd | |
| import gradio as gr | |
| from sklearn.ensemble import GradientBoostingRegressor | |
| import pickle | |
| # Load the saved model | |
| gb_model = pickle.load(open('gb_model.pkl', 'rb')) | |
| # Define the prediction function | |
| def predict_leachate_volume(EC_rock, Ph_rock, Corg_rock, Ca_rock, K_rock, Mg_rock, Na_rock, SAR_rock, SiO2_rock): | |
| input_data = [[EC_rock, Ph_rock, Corg_rock, Ca_rock, K_rock, Mg_rock, Na_rock, SAR_rock, SiO2_rock]] | |
| prediction = gb_model.predict(input_data) | |
| return prediction[0] | |
| # Create Gradio inputs | |
| inputs = [ | |
| gr.Number(label="EC_rock", value=0), | |
| gr.Number(label="Ph_rock", value=10), | |
| gr.Number(label="Corg_rock (%)", value=10), | |
| gr.Number(label="Ca_rock", value=60), | |
| gr.Number(label="K_rock", value=40), | |
| gr.Number(label="Mg_rock", value=6999), | |
| gr.Number(label="Na_rock", value=2999), | |
| gr.Number(label="SAR_rock", value=1999), | |
| gr.Number(label="SiO2_rock", value=56) | |
| ] | |
| # Create Gradio output | |
| outputs = gr.Textbox(label="Predicted Leachate Volume") | |
| # Set up the Gradio interface | |
| interface = gr.Interface(fn=predict_leachate_volume, inputs=inputs, outputs=outputs, live=True, | |
| title="Leachate Volume Prediction", description="Enter the rock characteristics to predict the leachate volume.") | |
| # Launch the interface | |
| interface.launch(share=True) | |