Spaces:
Runtime error
Runtime error
Commit
·
1731184
1
Parent(s):
bd502d0
Create new file
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
from sklearn.linear_model import LinearRegression
|
| 5 |
+
import pickle
|
| 6 |
+
filename = 'finalized_model.sav'
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# load the model from disk
|
| 10 |
+
lineareg = pickle.load(open(filename, 'rb'))
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
#function to predict the input hours
|
| 14 |
+
def predict_score(hours):
|
| 15 |
+
hours = np.array(hours)
|
| 16 |
+
pred_score = lineareg.predict(hours.reshape(-1,1))
|
| 17 |
+
return np.round(pred_score[0], 2)
|
| 18 |
+
|
| 19 |
+
input = gr.inputs.Number(label='Number of Hours studied')
|
| 20 |
+
output = gr.outputs.Textbox(label='Predicted Score')
|
| 21 |
+
gr.Interface( fn=predict_score,
|
| 22 |
+
inputs=input,
|
| 23 |
+
outputs=output).launch();
|
| 24 |
+
|