yassine123Z commited on
Commit
b5d61af
·
verified ·
1 Parent(s): 919f268

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -15
app.py CHANGED
@@ -15,8 +15,6 @@ model = SetFitModel.from_pretrained(
15
  )
16
 
17
  # Dummy reference categories (replace with your real categories or load CSV)
18
- import pandas as pd
19
-
20
  ref_data = pd.DataFrame({
21
  "Cat1EN": [
22
  "Purchase of goods","Purchase of goods","Purchase of goods","Purchase of goods",
@@ -30,14 +28,28 @@ ref_data = pd.DataFrame({
30
  "Food & beverages","Food & beverages","Food & beverages","Food & beverages",
31
  "Food & beverages","Food & beverages","Food & beverages","Food & beverages",
32
  "Heating and air conditioning","Heating and air conditioning","Fuels","Fuels","Fuels","Fuels",
33
- "Fuels","Fuels","Mobility (freight)","Mobility (freight)","Mobility (freight)","Mobility (freight)",
34
- "Mobility (freight)","Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
 
 
 
 
35
  "Mobility (passengers)","Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
36
  "Mobility (passengers)","Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
37
- "Mobility (passengers)","Process and fugitive emissions","Process and fugitive emissions",
38
- "Process and fugitive emissions","Waste treatment","Waste treatment","Waste treatment",
39
- "Waste treatment","Waste treatment","Waste treatment","Waste treatment","Waste treatment",
 
 
 
 
 
40
  "Waste treatment","Waste treatment","Waste treatment","Waste treatment","Waste treatment",
 
 
 
 
 
41
  "Use of electricity","Use of electricity","Use of electricity"
42
  ],
43
  "Cat2EN": [
@@ -52,19 +64,28 @@ ref_data = pd.DataFrame({
52
  "Condiments","Desserts","Fruits and vegetables","Fats and oils","Prepared / cooked meals",
53
  "Animal products","Cereal products","Dairy products","Heat and steam","Air conditioning and refrigeration",
54
  "Fossil fuels","Mobile fossil fuels","Organic fuels","Gaseous fossil fuels","Liquid fossil fuels",
55
- "Solid fossil fuels","Air transport","Ship transport","Truck transport","Combined transport",
56
- "Train transport","Air transport","Coach / Urban bus","Ship transport","Combined transport",
 
 
 
 
57
  "E-Bike","Accommodation / Events","Soft mobility","Motorcycle / Scooter","Train transport",
58
- "Public transport","Car","Agriculture","Global warming potential","Industrial processes",
 
 
 
59
  "Commercial and industrial","Wastewater","Electrical equipment","Households and similar",
60
  "Metal","Organic materials","Paper and cardboard","Batteries and accumulators","Plastics",
61
- "Fugitive process emissions","Textiles","Glass","Electricity for electric vehicles","Renewables","Standard"
 
 
62
  ],
63
  "DescriptionCat2EN": [
64
  "Goods purchase - sports","Goods purchase - buildings","Goods purchase - office items","Goods purchase - water",
65
  "Goods purchase - appliances","Goods purchase - electricals","Goods purchase - machinery","Goods purchase - furniture",
66
  "Goods purchase - textiles","Goods purchase - vehicles","Material purchase - construction","Material purchase - organic",
67
- "Material purchase - paper","Material purchase - plastics","Material purchase - chemicals","Material purchase - refrigerants & others",
68
  "Service - equipment rental","Service - building rental","Service - furniture rental","Service - vehicles",
69
  "Service - info/culture","Service - catering","Service - healthcare","Service - crafts",
70
  "Service - admin/consulting","Service - cleaning","Service - IT","Service - logistics",
@@ -72,19 +93,28 @@ ref_data = pd.DataFrame({
72
  "Food condiments","Food desserts","Food fruits & vegetables","Food fats & oils","Prepared meals",
73
  "Animal-based food","Cereal-based food","Dairy products","Heating - heat & steam","Heating - cooling/refrigeration",
74
  "Fuel - fossil","Fuel - mobile fossil","Fuel - organic","Fuel - gaseous","Fuel - liquid","Fuel - solid",
 
75
  "Freight transport - air","Freight transport - ship","Freight transport - truck","Freight transport - combined",
76
- "Freight transport - train","Passenger transport - air","Passenger transport - bus","Passenger transport - ship",
 
 
77
  "Passenger transport - combined","Passenger transport - e-bike","Passenger transport - accommodation/events",
78
  "Passenger transport - soft mobility","Passenger transport - scooter/motorbike","Passenger transport - train",
79
- "Passenger transport - public","Passenger transport - car","Emissions - agriculture","Emissions - warming potential",
80
- "Emissions - industry","Waste - commercial/industrial","Waste - wastewater","Waste - electricals",
 
 
 
 
81
  "Waste - households","Waste - metals","Waste - organics","Waste - paper","Waste - batteries",
82
  "Waste - plastics","Waste - fugitive","Waste - textiles","Waste - glass",
 
83
  "Electricity - EVs","Electricity - renewables","Electricity - standard"
84
  ]
85
  })
86
 
87
 
 
88
  ref_data["combined"] = ref_data[["Cat1EN", "Cat2EN", "DescriptionCat2EN"]].agg(" ".join, axis=1)
89
  ref_embeddings = model.encode(ref_data["combined"].tolist())
90
 
 
15
  )
16
 
17
  # Dummy reference categories (replace with your real categories or load CSV)
 
 
18
  ref_data = pd.DataFrame({
19
  "Cat1EN": [
20
  "Purchase of goods","Purchase of goods","Purchase of goods","Purchase of goods",
 
28
  "Food & beverages","Food & beverages","Food & beverages","Food & beverages",
29
  "Food & beverages","Food & beverages","Food & beverages","Food & beverages",
30
  "Heating and air conditioning","Heating and air conditioning","Fuels","Fuels","Fuels","Fuels",
31
+ "Fuels","Fuels",
32
+
33
+ "Mobility (freight)","Mobility (freight)","Mobility (freight)","Mobility (freight)",
34
+ "Mobility (freight)",
35
+
36
+ "Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
37
  "Mobility (passengers)","Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
38
  "Mobility (passengers)","Mobility (passengers)","Mobility (passengers)","Mobility (passengers)",
39
+
40
+
41
+
42
+
43
+ "Process and fugitive emissions","Process and fugitive emissions",
44
+ "Process and fugitive emissions",
45
+
46
+ "Waste treatment","Waste treatment","Waste treatment",
47
  "Waste treatment","Waste treatment","Waste treatment","Waste treatment","Waste treatment",
48
+ "Waste treatment","Waste treatment","Waste treatment","Waste treatment",
49
+
50
+
51
+
52
+
53
  "Use of electricity","Use of electricity","Use of electricity"
54
  ],
55
  "Cat2EN": [
 
64
  "Condiments","Desserts","Fruits and vegetables","Fats and oils","Prepared / cooked meals",
65
  "Animal products","Cereal products","Dairy products","Heat and steam","Air conditioning and refrigeration",
66
  "Fossil fuels","Mobile fossil fuels","Organic fuels","Gaseous fossil fuels","Liquid fossil fuels",
67
+ "Solid fossil fuels",
68
+
69
+ "Air transport","Ship transport","Truck transport","Combined transport",
70
+ "Train transport",
71
+
72
+ "Air transport","Coach / Urban bus","Ship transport","Combined transport",
73
  "E-Bike","Accommodation / Events","Soft mobility","Motorcycle / Scooter","Train transport",
74
+ "Public transport","Car",
75
+
76
+ "Agriculture","Global warming potential","Industrial processes",
77
+
78
  "Commercial and industrial","Wastewater","Electrical equipment","Households and similar",
79
  "Metal","Organic materials","Paper and cardboard","Batteries and accumulators","Plastics",
80
+ "Fugitive process emissions","Textiles","Glass",
81
+
82
+ "Electricity for electric vehicles","Renewables","Standard"
83
  ],
84
  "DescriptionCat2EN": [
85
  "Goods purchase - sports","Goods purchase - buildings","Goods purchase - office items","Goods purchase - water",
86
  "Goods purchase - appliances","Goods purchase - electricals","Goods purchase - machinery","Goods purchase - furniture",
87
  "Goods purchase - textiles","Goods purchase - vehicles","Material purchase - construction","Material purchase - organic",
88
+ "Material purchase - paper","Material purchase - plastics","Material purchase - chemicals","Material purchase - refrigerants",
89
  "Service - equipment rental","Service - building rental","Service - furniture rental","Service - vehicles",
90
  "Service - info/culture","Service - catering","Service - healthcare","Service - crafts",
91
  "Service - admin/consulting","Service - cleaning","Service - IT","Service - logistics",
 
93
  "Food condiments","Food desserts","Food fruits & vegetables","Food fats & oils","Prepared meals",
94
  "Animal-based food","Cereal-based food","Dairy products","Heating - heat & steam","Heating - cooling/refrigeration",
95
  "Fuel - fossil","Fuel - mobile fossil","Fuel - organic","Fuel - gaseous","Fuel - liquid","Fuel - solid",
96
+
97
  "Freight transport - air","Freight transport - ship","Freight transport - truck","Freight transport - combined",
98
+ "Freight transport - train",
99
+
100
+ "Passenger transport - air","Passenger transport - bus","Passenger transport - ship",
101
  "Passenger transport - combined","Passenger transport - e-bike","Passenger transport - accommodation/events",
102
  "Passenger transport - soft mobility","Passenger transport - scooter/motorbike","Passenger transport - train",
103
+ "Passenger transport - public","Passenger transport - car",
104
+
105
+ "Emissions - agriculture","Emissions - warming potential",
106
+ "Emissions - industry",
107
+
108
+ "Waste - commercial/industrial","Waste - wastewater","Waste - electricals",
109
  "Waste - households","Waste - metals","Waste - organics","Waste - paper","Waste - batteries",
110
  "Waste - plastics","Waste - fugitive","Waste - textiles","Waste - glass",
111
+
112
  "Electricity - EVs","Electricity - renewables","Electricity - standard"
113
  ]
114
  })
115
 
116
 
117
+
118
  ref_data["combined"] = ref_data[["Cat1EN", "Cat2EN", "DescriptionCat2EN"]].agg(" ".join, axis=1)
119
  ref_embeddings = model.encode(ref_data["combined"].tolist())
120