MiguelCh commited on
Commit
2907ba4
verified
1 Parent(s): 25d439e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -12,14 +12,17 @@ with open('my-standard-scaler.pkl', 'rb') as file:
12
 
13
  # Definir la funci贸n de predicci贸n
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(SOC: float, Cy: float):
 
19
  prediction = np.array(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, eNa: float, eAlH: float):
 
23
  ECEC = eCa + eMg + eK + eNa + eAlH
24
  xK = eK/ECEC
25
  prediction = np.array(1.53 - 0.076*SOC + 0.004*Cy - 2.04*xK)
@@ -27,6 +30,7 @@ def predict_3(SOC: float, Cy: float, eCa: float, eMg: float, eK: float, eNa: flo
27
 
28
  def predict_4(pH: float, EC: float, CCE: float, SOC: float, Sa: float, Si: float,
29
  Cy: float, CEC: float, eCa: float, eMg: float, eK: float, eNa: float, eAlH: float):
 
30
  ECEC = eCa + eMg + eK + eNa + eAlH
31
  xCa = eCa/ECEC
32
  xMg = eMg/ECEC
@@ -45,22 +49,27 @@ with gr.Blocks() as demo:
45
  gr.Markdown("# Estimar la densidad aparente del suelo")
46
  with gr.Row():
47
  with gr.Column():
 
 
48
  pH = gr.Number(label="pH (1:1)", value=7.09, interactive=True)
49
- EC = gr.Number(label="CE 1:1 (dS/m)", value=0.31, interactive=True)
50
- CCE = gr.Number(label="CaCO<sub>3</sub> (%)", value=0.20, interactive=True)
51
- eMg = gr.Number(label="Mg<sup>2+</sup> (meq/100g)", value=3.47, interactive=True)
52
- eAlH = gr.Number(label="Al<sup>3+</sup> + H<sup>+</sup> (meq/100g)", value=0.0, interactive=True)
53
  with gr.Column():
54
- SOC = gr.Number(label="SOC (%)", value=2.9408, interactive=True)
55
- Sa = gr.Number(label="Arena (%)", value=45.0, interactive=True)
 
 
 
 
 
 
56
  Si = gr.Number(label="Limo (%)", value=24.0, interactive=True)
57
- eK = gr.Number(label="K<sup>+</sup> (meq/100g)", value=0.47, interactive=True)
58
  with gr.Column():
59
- Cy = gr.Number(label="Arcilla (%)", value=31.0, interactive=True)
 
60
  CEC = gr.Number(label="CIC (meq/100g)", value=23.52, interactive=True)
61
- eCa = gr.Number(label="Ca<sup>2+</sup> (meq/100g)", value=19.44, interactive=True)
62
- eNa = gr.Number(label="Na<sup>+</sup> (meq/100g)", value=0.15, interactive=True)
63
-
64
  with gr.Row():
65
  with gr.Column():
66
  submit_1 = gr.Button(value='Abdelbaki')
 
12
 
13
  # Definir la funci贸n de predicci贸n
14
  def predict_1(SOC: float):
15
+ SOC = SOC/1.724 # SOC <- MO/1.724
16
  prediction = 1.58 + np.exp(-0.07*SOC)
17
  return prediction.round(2)
18
 
19
  def predict_2(SOC: float, Cy: float):
20
+ SOC = SOC/1.724 # SOC <- MO/1.724
21
  prediction = np.array(2.03 - 0.008*Cy - 0.008*SOC)
22
  return prediction.round(2)
23
 
24
  def predict_3(SOC: float, Cy: float, eCa: float, eMg: float, eK: float, eNa: float, eAlH: float):
25
+ SOC = SOC/1.724 # SOC <- MO/1.724
26
  ECEC = eCa + eMg + eK + eNa + eAlH
27
  xK = eK/ECEC
28
  prediction = np.array(1.53 - 0.076*SOC + 0.004*Cy - 2.04*xK)
 
30
 
31
  def predict_4(pH: float, EC: float, CCE: float, SOC: float, Sa: float, Si: float,
32
  Cy: float, CEC: float, eCa: float, eMg: float, eK: float, eNa: float, eAlH: float):
33
+ SOC = SOC/1.724 # SOC <- MO/1.724
34
  ECEC = eCa + eMg + eK + eNa + eAlH
35
  xCa = eCa/ECEC
36
  xMg = eMg/ECEC
 
49
  gr.Markdown("# Estimar la densidad aparente del suelo")
50
  with gr.Row():
51
  with gr.Column():
52
+ SOC = gr.Number(label="MO (%)", value=2.9408, interactive=True)
53
+ eK = gr.Number(label="K (meq/100g)", value=0.47, interactive=True)
54
  pH = gr.Number(label="pH (1:1)", value=7.09, interactive=True)
55
+ EC = gr.Number(label="C.E. (dS/m)", value=0.31, interactive=True)
56
+
 
 
57
  with gr.Column():
58
+ Cy = gr.Number(label="Arcilla (%)", value=31.0, interactive=True)
59
+ eNa = gr.Number(label="Na (meq/100g)", value=0.15, interactive=True)
60
+ CCE = gr.Number(label="CaCO3 (%)", value=0.20, interactive=True)
61
+
62
+
63
+ with gr.Column():
64
+ eCa = gr.Number(label="Ca (meq/100g)", value=19.44, interactive=True)
65
+ eAlH = gr.Number(label="Al + H (meq/100g)", value=0.0, interactive=True)
66
  Si = gr.Number(label="Limo (%)", value=24.0, interactive=True)
67
+
68
  with gr.Column():
69
+ eMg = gr.Number(label="Mg (meq/100g)", value=3.47, interactive=True)
70
+ Sa = gr.Number(label="Arena (%)", value=45.0, interactive=True)
71
  CEC = gr.Number(label="CIC (meq/100g)", value=23.52, interactive=True)
72
+
 
 
73
  with gr.Row():
74
  with gr.Column():
75
  submit_1 = gr.Button(value='Abdelbaki')