shashankanand13 commited on
Commit
835d453
โ€ข
1 Parent(s): 4c9806d

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +51 -0
app.py ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import numpy as np
4
+ import sklearn
5
+ import pickle
6
+ model = pickle.load(open('random_forest_regression_model.pkl', 'rb'))
7
+
8
+ import gradio as gr
9
+ def car(Year,owners,sp,fuel,distance,tyype,trans):
10
+ if fuel =="PETROL":
11
+ p,d=1,0
12
+ if fuel =="DIESEL":
13
+ p,d=0,1
14
+ if fuel =="CNG":
15
+ p,d=0,0
16
+ year = 2022-Year
17
+ if tyype=="Individual":
18
+ st=1
19
+ else:
20
+ st=0
21
+ if trans=="Manual":
22
+ t=1
23
+ else:
24
+ t=0
25
+ error = "ใ€ ๐—˜๐—ฟ๐—ฟ๐—ผ๐—ฟ ๐Ÿฐ๐Ÿฌ๐Ÿฐ : ๐—ฉ๐—ฎ๐—น๐˜‚๐—ฒ ๐— ๐—ถ๐˜€๐˜€๐—ถ๐—ป๐—ด ใ€‘"
26
+ prediction=model.predict([[sp,distance,owners,year,d,p,st,t]])
27
+ output=round(prediction[0],2)
28
+ ou= str(output)
29
+ if Year==0 or distance==0 or sp==0:
30
+ return error
31
+ else:
32
+ return "The Price of Will be โ‚น" + ou + "L !"
33
+ # face = gr.Interface(fn=start, inputs=["text", "checkbox","N", gr.inputs.Slider(0, 100),gr.inputs.Radio(["add", "subtract", "multiply"])], outputs=["text", "number"])
34
+ # face.launch()
35
+
36
+ # ---------------------------------INPUTS :------------------------------
37
+
38
+ # in1=gr.inputs.Textbox(placeholder="En",label="MO")
39
+ in2=gr.inputs.Number(label='Which Model (Year)ใ€*ใ€‘',default=0)
40
+ in3= gr.inputs.Slider(0, 10,1,label="No. of Previous Owners eg.")
41
+ in4=gr.inputs.Number(label='Kilometeres Drivedใ€*ใ€‘',default=0)
42
+ in5= gr.inputs.Radio(["PETROL", "DIESEL", "CNG"])
43
+ in6=gr.inputs.Dropdown(["Individual", "Dealer"],label="You Are")
44
+ in7=gr.inputs.Dropdown(["Automatic", "Manual"],label="Transmission Type")
45
+ in8=gr.inputs.Number(label='Showroom Price โ‚น(in LAKHS)ใ€*ใ€‘',default=0)
46
+
47
+ interface = gr.Interface(fn=car,
48
+ inputs=[in2,in3,in8,in5,in4,in6,in7],
49
+ outputs=["text"],title="Car calculator"
50
+ )
51
+ interface.launch(inline=False)