|
import gradio as gr |
|
import joblib |
|
import numpy as np |
|
|
|
|
|
model = joblib.load('best_model.pkl') |
|
|
|
|
|
pipeline = joblib.load('best_pipeline.pkl') |
|
|
|
|
|
def predict(input1, input2, input3, input4, input5,input6): |
|
|
|
inputs = np.array([input1, input2, input3, input4, input5,input6]).reshape(1, -1) |
|
|
|
|
|
inputs_scaled = pipeline.transform(inputs) |
|
|
|
|
|
prediction = model.predict(inputs_scaled) |
|
|
|
|
|
return prediction[0], f"The predicted value is {prediction[0]:.2f}" |
|
|
|
|
|
iface = gr.Interface( |
|
fn=predict, |
|
inputs=[ |
|
gr.Number(label="Age"), |
|
gr.Number(label="Hours per day"), |
|
gr.Number(label="Depression"), |
|
gr.Number(label="Insomnia"), |
|
gr.Number(label="OCD"), |
|
gr.Number(label="BPM") |
|
], |
|
outputs=[ |
|
gr.Number(label="Predicted Value"), |
|
gr.Textbox(label="Prediction Description") |
|
], |
|
title="Music & Mental Health Predictor", |
|
description="""This Model has been trained on this <a href="https://www.kaggle.com/datasets/catherinerasgaitis/mxmh-survey-results">Dataset</a>.""", |
|
theme=gr.themes.Soft(), |
|
examples=[[18,3,0,1,0,156]] |
|
) |
|
|
|
|
|
iface.launch(debug=True) |