File size: 1,421 Bytes
8537724
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import gradio as gr
import pickle 

def read_pickle(path, saved_model_name:str):
    with open(path + saved_model_name + '.pickle', 'rb') as to_read:
        model = pickle.load(to_read)
    return model

def automatidata(VendorID, passenger_count, Distance, Duration, rush_hour):
    inputs = [[VendorID, passenger_count, Distance, Duration, rush_hour]]
    prediction = model.predict(inputs) 
    prediction_value = prediction[0][0]
    return f" Fare amount(approx.) =  {round(prediction_value,2)}  $"

path = 'F:/Case study/Interview preparation/01.Project/1. Automatidata/Final/'
model = read_pickle(path,'Automatidata_gui')

automatidata_ga = gr.Interface(fn=automatidata, 
                               inputs = [
                                         gr.Number(1,2, label="VendorID - [1, 2]"),
                                         gr.Number(0,6, label="Passenger Count"),
                                         gr.Number(label="Distance"),
                                         gr.Number(label="Duration"),
                                         gr.Number(0,1, label="Rush Hour")
                                        ],
                              outputs = "text",title="Taxi Fares Estimater", 
                              description="Predicting Taxi Fare Amount Using Machine Learning.",
                               )

if __name__ == "__main__":
    automatidata_ga.launch(share=True)