Spaces:
Runtime error
Runtime error
RahelJadhav
commited on
Upload 4 files
Browse files- app.py +47 -0
- best_model.pkl +3 -0
- best_pipeline (1).pkl +3 -0
- requirements.txt +3 -0
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import joblib
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load the saved model
|
6 |
+
model = joblib.load('best_model.pkl')
|
7 |
+
|
8 |
+
# Load the saved pipeline (which includes the scaler and the model)
|
9 |
+
pipeline = joblib.load('best_pipeline.pkl')
|
10 |
+
|
11 |
+
# Define the prediction function
|
12 |
+
def predict(input1, input2, input3, input4, input5,input6):
|
13 |
+
# Create a numpy array from the inputs
|
14 |
+
inputs = np.array([input1, input2, input3, input4, input5,input6]).reshape(1, -1)
|
15 |
+
|
16 |
+
# Transform the inputs using the scaler
|
17 |
+
inputs_scaled = pipeline.transform(inputs)
|
18 |
+
|
19 |
+
# Make the prediction
|
20 |
+
prediction = model.predict(inputs_scaled)
|
21 |
+
|
22 |
+
# Return the prediction and a description
|
23 |
+
return prediction[0], f"The predicted value is {prediction[0]:.2f}"
|
24 |
+
|
25 |
+
# Define the Gradio interface
|
26 |
+
iface = gr.Interface(
|
27 |
+
fn=predict, # Function to call
|
28 |
+
inputs=[
|
29 |
+
gr.Number(label="Age"),
|
30 |
+
gr.Number(label="Hours per day"),
|
31 |
+
gr.Number(label="Depression"),
|
32 |
+
gr.Number(label="Insomnia"),
|
33 |
+
gr.Number(label="OCD"),
|
34 |
+
gr.Number(label="BPM")
|
35 |
+
],
|
36 |
+
outputs=[
|
37 |
+
gr.Number(label="Predicted Value"),
|
38 |
+
gr.Textbox(label="Prediction Description")
|
39 |
+
],
|
40 |
+
title="Music & Mental Health Predictor",
|
41 |
+
description="""This Model has been trained on this <a href="https://www.kaggle.com/datasets/catherinerasgaitis/mxmh-survey-results">Dataset</a>.""",
|
42 |
+
theme=gr.themes.Soft(),
|
43 |
+
examples=[[18,3,0,1,0,156]]
|
44 |
+
)
|
45 |
+
|
46 |
+
# Launch the interface
|
47 |
+
iface.launch(debug=True)
|
best_model.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:694a06e780838bd2584d332a685bf9cd0cc882189898bfad4233797162b176e9
|
3 |
+
size 8826646
|
best_pipeline (1).pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:ac24b8da27cf83967f38bbc64f2004ac5cb96e25692443daf2d92e335b3ae284
|
3 |
+
size 1221
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
joblib
|
2 |
+
scikit-learn==1.3.2
|
3 |
+
xgboost
|