Parthebhan commited on
Commit
aafa04e
·
verified ·
1 Parent(s): 1a75052

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -1
app.py CHANGED
@@ -1 +1,36 @@
1
- pip freeze > requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ iimport pickle
2
+ import gradio as gr
3
+
4
+ # Define the function to read the pickled model
5
+ def read_pickle(path, saved_model_name):
6
+ with open(path + saved_model_name + '.pickle', 'rb') as to_read:
7
+ model = pickle.load(to_read)
8
+ return model
9
+
10
+ # Load the pickled model
11
+ path = './' # Assuming the model file is in the current directory
12
+ model = read_pickle(path, "Automatidata_gui")
13
+
14
+ # Define the function for making predictions
15
+ def automatidata(VendorID, passenger_count, Distance, Duration, rush_hour):
16
+ inputs = [[VendorID, passenger_count, Distance, Duration, rush_hour]]
17
+ prediction = model.predict(inputs)
18
+ prediction_value = prediction[0][0]
19
+ return f"Fare amount(approx.) = {round(prediction_value, 2)} $"
20
+
21
+ # Create the Gradio interface
22
+ automatidata_ga = gr.Interface(fn=automatidata,
23
+ inputs=[
24
+ gr.Number(1, 2, label="VendorID - [1, 2]"),
25
+ gr.Number(0, 6, label="Passenger Count"),
26
+ gr.Number(label="Distance"),
27
+ gr.Number(label="Duration"),
28
+ gr.Number(0, 1, label="Rush Hour")
29
+ ],
30
+ outputs="text", title="Taxi Fares Estimator",
31
+ description="Predicting Taxi Fare Amount Using Machine Learning."
32
+ )
33
+
34
+ # Launch the interface
35
+ if __name__ == "__main__":
36
+ automatidata_ga.launch(share=True)