MatCod commited on
Commit
d3745f7
·
verified ·
1 Parent(s): 673ff47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -10
app.py CHANGED
@@ -70,7 +70,7 @@ class EnergyMLPredictor:
70
  color_mapping = {0: 'incolor', 1: 'verde', 2: 'cinza', 3: 'bronze'}
71
  cor_str = color_mapping.get(data['cor'], 'incolor')
72
 
73
- # Create input features
74
  input_data = {
75
  'boosting': data['pot_boost'],
76
  'espessura': data['espessura'],
@@ -79,13 +79,12 @@ class EnergyMLPredictor:
79
  'cor': cor_str,
80
  'prod_e': data['Prod_E'],
81
  'prod_l': data['Prod_L'],
 
82
  'week_day': date_obj.weekday(),
83
  'month': date_obj.month,
84
  'quarter': (date_obj.month - 1) // 3 + 1,
85
  'is_weekend': int(date_obj.weekday() >= 5),
86
- 'week_of_year': date_obj.isocalendar()[1],
87
- 'day_of_month': date_obj.day,
88
- 'day_of_year': date_obj.timetuple().tm_yday
89
  }
90
 
91
  # Convert to DataFrame
@@ -171,8 +170,20 @@ class EnergyMLPredictor:
171
  for item in data:
172
  # Parse input
173
  date_obj = datetime.strptime(item['data'], '%Y-%m-%d')
174
- boosting_val = float(item['boosting'].replace(',', '.'))
175
- extracao_val = float(item['extracao_forno'].replace(',', '.'))
 
 
 
 
 
 
 
 
 
 
 
 
176
 
177
  # Create features
178
  input_data = {
@@ -181,8 +192,8 @@ class EnergyMLPredictor:
181
  'extracao_forno': extracao_val,
182
  'porcentagem_caco': item['porcentagem_caco'],
183
  'cor': item['cor'].lower(),
184
- 'prod_e': item.get('prod_e', 1),
185
- 'prod_l': item.get('prod_l', 1),
186
  'autoclave': item.get('autoclave', 1),
187
  'week_day': date_obj.weekday(),
188
  'month': date_obj.month,
@@ -225,8 +236,20 @@ class EnergyMLPredictor:
225
  for item in data:
226
  # Parse input
227
  date_obj = datetime.strptime(item['data'], '%Y-%m-%d')
228
- boosting_val = float(item['boosting'].replace(',', '.'))
229
- extracao_val = float(item['extracao_forno'].replace(',', '.'))
 
 
 
 
 
 
 
 
 
 
 
 
230
 
231
  # Create features (match training: numerical + categorical + boolean, NO day_of_month/day_of_year)
232
  input_data = {
 
70
  color_mapping = {0: 'incolor', 1: 'verde', 2: 'cinza', 3: 'bronze'}
71
  cor_str = color_mapping.get(data['cor'], 'incolor')
72
 
73
+ # Create input features (with autoclave)
74
  input_data = {
75
  'boosting': data['pot_boost'],
76
  'espessura': data['espessura'],
 
79
  'cor': cor_str,
80
  'prod_e': data['Prod_E'],
81
  'prod_l': data['Prod_L'],
82
+ 'autoclave': data.get('autoclave', 1),
83
  'week_day': date_obj.weekday(),
84
  'month': date_obj.month,
85
  'quarter': (date_obj.month - 1) // 3 + 1,
86
  'is_weekend': int(date_obj.weekday() >= 5),
87
+ 'week_of_year': date_obj.isocalendar()[1]
 
 
88
  }
89
 
90
  # Convert to DataFrame
 
170
  for item in data:
171
  # Parse input
172
  date_obj = datetime.strptime(item['data'], '%Y-%m-%d')
173
+
174
+ # Handle different field name formats (boosting vs ext_boosting)
175
+ if 'boosting' in item:
176
+ boosting_val = float(str(item['boosting']).replace(',', '.'))
177
+ elif 'ext_boosting' in item:
178
+ boosting_val = float(str(item['ext_boosting']).replace(',', '.'))
179
+ else:
180
+ boosting_val = 0.0
181
+
182
+ # Handle extracao_forno field
183
+ if 'extracao_forno' in item:
184
+ extracao_val = float(str(item['extracao_forno']).replace(',', '.'))
185
+ else:
186
+ extracao_val = 800.0
187
 
188
  # Create features
189
  input_data = {
 
192
  'extracao_forno': extracao_val,
193
  'porcentagem_caco': item['porcentagem_caco'],
194
  'cor': item['cor'].lower(),
195
+ 'prod_e': item.get('prod_e', item.get('Prod_E', 1)),
196
+ 'prod_l': item.get('prod_l', item.get('Prod_L', 1)),
197
  'autoclave': item.get('autoclave', 1),
198
  'week_day': date_obj.weekday(),
199
  'month': date_obj.month,
 
236
  for item in data:
237
  # Parse input
238
  date_obj = datetime.strptime(item['data'], '%Y-%m-%d')
239
+
240
+ # Handle different field name formats (boosting vs ext_boosting)
241
+ if 'boosting' in item:
242
+ boosting_val = float(str(item['boosting']).replace(',', '.'))
243
+ elif 'ext_boosting' in item:
244
+ boosting_val = float(str(item['ext_boosting']).replace(',', '.'))
245
+ else:
246
+ boosting_val = 0.0
247
+
248
+ # Handle extracao_forno field
249
+ if 'extracao_forno' in item:
250
+ extracao_val = float(str(item['extracao_forno']).replace(',', '.'))
251
+ else:
252
+ extracao_val = 800.0
253
 
254
  # Create features (match training: numerical + categorical + boolean, NO day_of_month/day_of_year)
255
  input_data = {