durrani commited on
Commit
b1c769d
1 Parent(s): 4437549
Files changed (1) hide show
  1. app.py +19 -1
app.py CHANGED
@@ -1,4 +1,22 @@
1
  import torch
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  # Input data
4
  x1 = torch.tensor([50, 60, 70, 80, 90])
@@ -59,4 +77,4 @@ while iter_count < max_iters:
59
  # Print the final values of Theta0, Theta1, and Theta2
60
  print("Final values: Theta0 = {}, Theta1 = {}, Theta2 = {}".format(Theta0.item(), Theta1.item(), Theta2.item()))
61
  print("Final Cost: Cost = {}".format(cost.item()))
62
- print("Final values: y_pred = {}, y_actual = {}".format(y_pred, y_actual))
 
1
  import torch
2
+ import numpy as np
3
+ import gradio as gr
4
+
5
+ # Function to predict the input hours
6
+ def predict_score(x1, x2):
7
+ Theta0 = torch.tensor(-0.5738734424645411)
8
+ Theta1 = torch.tensor(2.1659122905141825)
9
+ Theta2 = torch.tensor(0.0)
10
+ pred_score = Theta0 + Theta1 * x1 + Theta2 * x2
11
+ return pred_score.item()
12
+
13
+ input1 = gr.inputs.Number(label="Number of new students")
14
+ input2 = gr.inputs.Number(label="Number of temperature")
15
+
16
+ output = gr.outputs.Textbox(label='Predicted Score')
17
+
18
+ # Gradio interface for the prediction function
19
+ gr.Interface(fn=predict_score, inputs=[input1, input2], outputs=output).launch()
20
 
21
  # Input data
22
  x1 = torch.tensor([50, 60, 70, 80, 90])
 
77
  # Print the final values of Theta0, Theta1, and Theta2
78
  print("Final values: Theta0 = {}, Theta1 = {}, Theta2 = {}".format(Theta0.item(), Theta1.item(), Theta2.item()))
79
  print("Final Cost: Cost = {}".format(cost.item()))
80
+ print("Final values: y_pred = {}, y_actual = {}".format(y_pred, y_actual))