Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pickle
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
# Load the pickled model
|
| 5 |
+
with open('./Automatidata_gui.pickle', 'rb') as file:
|
| 6 |
+
model = pickle.load(file)
|
| 7 |
+
|
| 8 |
+
# Define the function for making predictions
|
| 9 |
+
def automatidata(VendorID, passenger_count, Distance, Duration, rush_hour):
|
| 10 |
+
inputs = [[VendorID, passenger_count, Distance, Duration, rush_hour]]
|
| 11 |
+
prediction = model.predict(inputs)
|
| 12 |
+
prediction_value = prediction[0][0]
|
| 13 |
+
return f"Fare amount(approx.) = {round(prediction_value, 2)} $"
|
| 14 |
+
|
| 15 |
+
# Create the Gradio interface
|
| 16 |
+
automatidata_ga = gr.Interface(fn=automatidata,
|
| 17 |
+
inputs=[
|
| 18 |
+
gr.Number(1, 2, label="VendorID - [1 or 2]"),
|
| 19 |
+
gr.Number(0, 6, label="Passenger Count - [1 to 6]"),
|
| 20 |
+
gr.Number(label="Distance in miles"),
|
| 21 |
+
gr.Number(label="Duration in mins"),
|
| 22 |
+
gr.Number(0, 1, label="Rush Hour - [0 or 1]")
|
| 23 |
+
],
|
| 24 |
+
outputs="text", title="New York City Taxi and Limousine Commission (TLC) - Taxi Fares Estimator",
|
| 25 |
+
examples = [
|
| 26 |
+
[2,1,2.33,15.09,0],
|
| 27 |
+
[1,2,4.22,24.29,0],
|
| 28 |
+
[1,1,0.71,6.66,0],
|
| 29 |
+
[2,1,0.97,8.37,0],
|
| 30 |
+
[2,3,1.48,8.92,0],
|
| 31 |
+
],
|
| 32 |
+
description="Predicting Taxi Fare Amount Using Machine Learning.",
|
| 33 |
+
theme='dark'
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
automatidata_ga.launch(share=True)
|