ayush-vatsal commited on
Commit
7596ce7
1 Parent(s): b229f38

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +82 -51
app.py CHANGED
@@ -17,57 +17,88 @@ model = joblib.load(model_dir + "/car_prices_model.pkl")
17
 
18
 
19
 
20
- def car(km_driven, mileage, engine, max_power, seats, age, seller_type_dealer, seller_type_individual, seller_type_trustmark_dealer,
21
- fuel_type_cng, fuel_type_diesel, fuel_type_electric, fuel_type_petrol, transmission_type_automatic, transmission_type_manual):
22
- input_list = []
23
- input_list.append(km_driven)
24
- input_list.append(mileage)
25
- input_list.append(engine)
26
- input_list.append(max_power)
27
- input_list.append(seats)
28
- input_list.append(age)
29
- input_list.append(seller_type_dealer)
30
- input_list.append(seller_type_individual)
31
- input_list.append(seller_type_trustmark_dealer)
32
- input_list.append(fuel_type_cng)
33
- input_list.append(fuel_type_diesel)
34
- input_list.append(fuel_type_electric)
35
- input_list.append(fuel_type_petrol)
36
- input_list.append(transmission_type_automatic)
37
- input_list.append(transmission_type_manual)
38
- # 'res' is a list of predictions returned as the label.
39
- df = pd.DataFrame(input_list)
40
- # df = pd.get_dummies(data=df, columns=['seller_type', 'fuel_type', 'transmission_type'])
41
- # df = df.rename(columns = {'seller_type_Trustmark Dealer': 'seller_type_Trustmark_Dealer'})
42
- res = model.predict(df.T)[0]
43
- return res
44
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  demo = gr.Interface(
46
- fn=car,
47
- title="Car Price Predictive Analytics",
48
- description="Experiment with car details to predict the price of your car.",
49
- allow_flagging="never",
50
- inputs=[
51
- gr.inputs.Number(default=10000.0, label="Kilometers driven"),
52
- gr.inputs.Number(default=12.0, label="Mileage (in KM/L)"),
53
- gr.inputs.Number(default=1199.0, label="Engine Size (in cc)"),
54
- gr.inputs.Number(default=70.0, label="Max Power (in BHP)"),
55
- gr.inputs.Number(default=5, label="Number of Seats"),
56
- gr.inputs.Number(default=4.0, label="Age of the car"),
57
- gr.inputs.Number(default=0, label="seller_type_dealer"),
58
- gr.inputs.Number(default=0, label="seller_type_individual"),
59
- gr.inputs.Number(default=0, label="seller_type_trustmark_dealer"),
60
- gr.inputs.Number(default=0, label="fuel_type_cng"),
61
- gr.inputs.Number(default=0, label="fuel_type_diesel"),
62
- gr.inputs.Number(default=0, label="fuel_type_electric"),
63
- gr.inputs.Number(default=0, label="fuel_type_petrol"),
64
- gr.inputs.Number(default=0, label="transmission_type_automatic"),
65
- gr.inputs.Number(default=0, label="transmission_type_manual"),
66
-
67
- # gr.inputs.Dropdown(choices=["Dealer", "Individual", "Trademark Dealer"]),
68
- # gr.inputs.Dropdown(choices=["Petrol", "Diesel", "Other"]),
69
- # gr.inputs.Dropdown(choices=["Automatic", "Manual"]),
70
- ],
71
- outputs=gr.Number())
72
 
73
  demo.launch()
 
17
 
18
 
19
 
20
+ def car(km_driven, mileage, engine, max_power, seats, age, seller_type, fuel_type, transmission_type):
21
+ input_list = []
22
+ input_list.append(km_driven)
23
+ input_list.append(mileage)
24
+ input_list.append(engine)
25
+ input_list.append(max_power)
26
+ input_list.append(seats)
27
+ input_list.append(age)
28
+ input_list.append(seller_type)
29
+ input_list.append(fuel_type)
30
+ input_list.append(transmission_type)
31
+
32
+ if (input_list[6] == "Dealer"):
33
+ input_list.pop(6)
34
+ input_list.insert(6, 1)
35
+ input_list.insert(7, 0)
36
+ input_list.insert(8, 0)
37
+ if (input_list[6] == "Individual"):
38
+ input_list.pop(6)
39
+ input_list.insert(6, 0)
40
+ input_list.insert(7, 1)
41
+ input_list.insert(8, 0)
42
+ if (input_list[6] == "Trustmark Dealer"):
43
+ input_list.pop(6)
44
+ input_list.insert(6, 0)
45
+ input_list.insert(7, 0)
46
+ input_list.insert(8, 1)
47
+
48
+ if (input_list[9] == "CNG"):
49
+ input_list.pop(9)
50
+ input_list.insert(9, 1)
51
+ input_list.insert(10, 0)
52
+ input_list.insert(11, 0)
53
+ input_list.insert(12, 0)
54
+ if (input_list[9] == "Diesel"):
55
+ input_list.pop(9)
56
+ input_list.insert(9, 0)
57
+ input_list.insert(10, 1)
58
+ input_list.insert(11, 0)
59
+ input_list.insert(12, 0)
60
+ if (input_list[9] == "Electric"):
61
+ input_list.pop(9)
62
+ input_list.insert(9, 0)
63
+ input_list.insert(10, 0)
64
+ input_list.insert(11, 1)
65
+ input_list.insert(12, 0)
66
+ if (input_list[9] == "Petrol"):
67
+ input_list.pop(9)
68
+ input_list.insert(9, 0)
69
+ input_list.insert(10, 0)
70
+ input_list.insert(11, 0)
71
+ input_list.insert(12, 1)
72
+
73
+ if (input_list[13] == "Automatic"):
74
+ input_list.pop(13)
75
+ input_list.insert(13, 1)
76
+ input_list.insert(14, 0)
77
+ if (input_list[13] == "Manual"):
78
+ input_list.pop(13)
79
+ input_list.insert(13, 0)
80
+ input_list.insert(14, 1)
81
+ df = pd.DataFrame(input_list)
82
+ res = model.predict(df.T)[0]
83
+ return res
84
+
85
  demo = gr.Interface(
86
+ fn=car,
87
+ title="Car Price Predictive Analytics",
88
+ description="Experiment with car details to predict the price of your car.",
89
+ allow_flagging="never",
90
+ inputs=[
91
+ gr.inputs.Number(default=10000.0, label="Kilometers driven"),
92
+ gr.inputs.Number(default=12.0, label="Mileage (in KM/L)"),
93
+ gr.inputs.Number(default=1199.0, label="Engine Size (in cc)"),
94
+ gr.inputs.Number(default=70.0, label="Max Power (in BHP)"),
95
+ gr.inputs.Number(default=5, label="Number of Seats"),
96
+ gr.inputs.Number(default=4.0, label="Age of the car"),
97
+
98
+ gr.inputs.Dropdown(choices=["Dealer", "Individual", "Trustmark Dealer"]),
99
+ gr.inputs.Dropdown(choices=["Petrol", "Diesel", "Electric", "CNG"]),
100
+ gr.inputs.Dropdown(choices=["Automatic", "Manual"]),
101
+ ],
102
+ outputs=gr.Number())
 
 
 
 
 
 
 
 
 
103
 
104
  demo.launch()