Update app.py
Browse files
app.py
CHANGED
@@ -1,42 +1,4 @@
|
|
1 |
-
|
2 |
|
3 |
-
# Install
|
4 |
-
|
5 |
-
requirements = f.readlines()
|
6 |
-
pip.main(["install"] + requirements)
|
7 |
-
|
8 |
-
import gradio as gr
|
9 |
-
import pickle
|
10 |
-
|
11 |
-
def read_pickle(path, saved_model_name: str):
|
12 |
-
"""Loads a pickled model from the specified path."""
|
13 |
-
with open(path + saved_model_name + '.pickle', 'rb') as to_read:
|
14 |
-
model = pickle.load(to_read)
|
15 |
-
return model
|
16 |
-
|
17 |
-
def automatidata(VendorID, passenger_count, Distance, Duration, rush_hour):
|
18 |
-
"""Predicts the taxi fare using the loaded model."""
|
19 |
-
inputs = [[VendorID, passenger_count, Distance, Duration, rush_hour]]
|
20 |
-
prediction = model.predict(inputs)
|
21 |
-
prediction_value = prediction[0][0]
|
22 |
-
return f"Fare amount(approx.) = ${round(prediction_value, 2)}"
|
23 |
-
|
24 |
-
if __name__ == "__main__":
|
25 |
-
path = 'F:/Case study/Interview preparation/01.Project/1. Automatidata/Final/'
|
26 |
-
model = read_pickle(path, 'Automatidata_gui')
|
27 |
-
|
28 |
-
automatidata_ga = gr.Interface(
|
29 |
-
fn=automatidata,
|
30 |
-
inputs=[
|
31 |
-
gr.Number(1, 2, label="VendorID - [1, 2]"),
|
32 |
-
gr.Number(0, 6, label="Passenger Count"),
|
33 |
-
gr.Number(label="Distance"),
|
34 |
-
gr.Number(label="Duration"),
|
35 |
-
gr.Number(0, 1, label="Rush Hour")
|
36 |
-
],
|
37 |
-
outputs="text",
|
38 |
-
title="Taxi Fares Estimater",
|
39 |
-
description="Predicting Taxi Fare Amount Using Machine Learning.",
|
40 |
-
)
|
41 |
-
|
42 |
-
automatidata_ga.launch(auth=('user', 'auto'), share=True)
|
|
|
1 |
+
pip show pickle torch numpy
|
2 |
|
3 |
+
# Install if not found
|
4 |
+
pip install pickle torch numpy
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|