snajmark commited on
Commit
5412e88
·
1 Parent(s): a86f0ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -8
app.py CHANGED
@@ -192,6 +192,7 @@ def predict_inverse(hardness_target, ys_target, request: gr.Request):
192
  [el['name'] for el in domain],
193
  [[x] for x in x_best]))
194
  optimized_x = pd.DataFrame.from_dict(best_params)
 
195
  #for c in optimized_x.columns:
196
  # if c in continuous_variables:
197
  # optimized_x[c]=optimized_x[c]*(scaling_factors[c][1]-scaling_factors[c][0])+scaling_factors[c][0]
@@ -204,7 +205,7 @@ def predict_inverse(hardness_target, ys_target, request: gr.Request):
204
  'Single/Multiphase ', 'Single/Multiphase M', 'Single/Multiphase S']]
205
  result = optimized_x
206
  result = result[result>0.0].dropna(axis=1)
207
- return result
208
 
209
 
210
  example_inputs = [420, 10]
@@ -248,11 +249,16 @@ with gr.Blocks(css=css_styling, title=page_title) as demo:
248
  input_hardness = gr.Text(label="Enter your target hardness (in HV)")
249
  input_yield_strength = gr.Text(label="Enter your target yield strength (MPa)")
250
  with gr.Column():
251
- gr.Markdown("### Your optimal formulation and processing conditions")
252
- optimal_parameters = gr.DataFrame(label="Optimal parameters", wrap=True)
253
-
254
- gr.Markdown("### Model interpretation")
255
- ### Fill plot
 
 
 
 
 
256
 
257
  with gr.Row():
258
  gr.Examples([example_inputs], [input_hardness, input_yield_strength])
@@ -263,17 +269,19 @@ with gr.Blocks(css=css_styling, title=page_title) as demo:
263
  fn=predict_inverse,
264
  inputs=[input_hardness, input_yield_strength],
265
  outputs=[
266
- optimal_parameters
 
267
  ],
268
  show_progress=True,
269
  )
270
  clear_button.click(
271
- lambda x: [gr.update(value=None)] * 8,
272
  [],
273
  [
274
  optimal_parameters,
275
  input_hardness,
276
  input_yield_strength,
 
277
  ],
278
  )
279
 
 
192
  [el['name'] for el in domain],
193
  [[x] for x in x_best]))
194
  optimized_x = pd.DataFrame.from_dict(best_params)
195
+ plot = utils.interpret(optimized_x)
196
  #for c in optimized_x.columns:
197
  # if c in continuous_variables:
198
  # optimized_x[c]=optimized_x[c]*(scaling_factors[c][1]-scaling_factors[c][0])+scaling_factors[c][0]
 
205
  'Single/Multiphase ', 'Single/Multiphase M', 'Single/Multiphase S']]
206
  result = optimized_x
207
  result = result[result>0.0].dropna(axis=1)
208
+ return result, plot
209
 
210
 
211
  example_inputs = [420, 10]
 
249
  input_hardness = gr.Text(label="Enter your target hardness (in HV)")
250
  input_yield_strength = gr.Text(label="Enter your target yield strength (MPa)")
251
  with gr.Column():
252
+ with gr.Row():
253
+ gr.Markdown("### Your optimal formulation and processing conditions")
254
+ optimal_parameters = gr.DataFrame(label="Optimal parameters", wrap=True)
255
+ with gr.Row():
256
+ with gr.Column():
257
+ with gr.Row():
258
+ gr.Markdown("### Interpretation of hardness prediction")
259
+ gr.Markdown("### Interpretation of yield strength prediction")
260
+ with gr.Row():
261
+ output_interpretation = gr.Plot(label="Interpretation")
262
 
263
  with gr.Row():
264
  gr.Examples([example_inputs], [input_hardness, input_yield_strength])
 
269
  fn=predict_inverse,
270
  inputs=[input_hardness, input_yield_strength],
271
  outputs=[
272
+ optimal_parameters,
273
+ output_interpretation,
274
  ],
275
  show_progress=True,
276
  )
277
  clear_button.click(
278
+ lambda x: [gr.update(value=None)] * 4,
279
  [],
280
  [
281
  optimal_parameters,
282
  input_hardness,
283
  input_yield_strength,
284
+ output_interpretation,
285
  ],
286
  )
287