MiguelCh commited on
Commit
93b3457
·
verified ·
1 Parent(s): 8ebafff

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -15,12 +15,14 @@ def predict_1(SOC: float):
15
  prediction = 1.58 + np.exp(-0.07*SOC)
16
  return prediction.round(2)
17
 
18
- def predict_2(Cy: float, SOC: float):
19
- prediction = 2.03 - 0.008 * Cy - 0.008 * SOC
20
  return prediction.round(2)
21
 
22
- def predict_3(Cy: float, SOC: float):
23
- prediction = 1.53 - 0.076 * SOC + 0.004 * Cy
 
 
24
  return prediction.round(2)
25
 
26
  def predict_4(pH: float, EC: float, CCE: float, SOC: float, Sa: float, Si: float,
@@ -33,7 +35,7 @@ def predict_4(pH: float, EC: float, CCE: float, SOC: float, Sa: float, Si: float
33
  xAlH = eAlH/ECEC
34
  BS1 = (eCa + eMg + eK + eNa)/CEC
35
  BS2 = (eCa + eMg + eK + eNa)/ECEC
36
- input_features = np.array([[pH, EC, CCE, SOC, Sa, Si, Cy, CEC, ECEC, xCa, xMg, xK, xNa, xAlH, BS1, BS2]])
37
  input_features_scale = s_c.transform(input_features)
38
  prediction = rf.predict(input_features_scale)[0].round(2)
39
  return prediction
@@ -72,7 +74,7 @@ with gr.Blocks() as demo:
72
 
73
  submit_1.click(predict_1, inputs=[SOC], outputs=[output])
74
  submit_2.click(predict_2, inputs=[SOC, Cy], outputs=[output])
75
- submit_3.click(predict_3, inputs=[SOC, Cy], outputs=[output])
76
  submit_4.click(predict_4, inputs=[pH , EC, CCE, SOC, Sa, Si, Cy, CEC, eCa, eMg, eK, eNa, eAlH], outputs=[output])
77
 
78
  demo.launch(share=False, debug=False)
 
15
  prediction = 1.58 + np.exp(-0.07*SOC)
16
  return prediction.round(2)
17
 
18
+ def predict_2(SOC: float, Cy: float):
19
+ prediction = 2.03 - 0.008*Cy - 0.008*SOC
20
  return prediction.round(2)
21
 
22
+ def predict_3(SOC: float, Cy: float, eCa: float, eMg: float eK: float, eAlH: float):
23
+ ECEC = eCa + eMg + eK + eNa + eAlH
24
+ xK = eK/ECEC
25
+ prediction = 1.53 - 0.076*SOC + 0.004*Cy - 2.04*xK
26
  return prediction.round(2)
27
 
28
  def predict_4(pH: float, EC: float, CCE: float, SOC: float, Sa: float, Si: float,
 
35
  xAlH = eAlH/ECEC
36
  BS1 = (eCa + eMg + eK + eNa)/CEC
37
  BS2 = (eCa + eMg + eK + eNa)/ECEC
38
+ input_features = np.array([[pH, EC, CCE, SOC, Sa, Si, Cy, CEC, ECEC, xCa, xMg, xK, xNa, xAlH, BS1, BS2]])
39
  input_features_scale = s_c.transform(input_features)
40
  prediction = rf.predict(input_features_scale)[0].round(2)
41
  return prediction
 
74
 
75
  submit_1.click(predict_1, inputs=[SOC], outputs=[output])
76
  submit_2.click(predict_2, inputs=[SOC, Cy], outputs=[output])
77
+ submit_3.click(predict_3, inputs=[SOC, Cy, eCa, eMg, eK, eAlH], outputs=[output])
78
  submit_4.click(predict_4, inputs=[pH , EC, CCE, SOC, Sa, Si, Cy, CEC, eCa, eMg, eK, eNa, eAlH], outputs=[output])
79
 
80
  demo.launch(share=False, debug=False)