Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,19 @@ with open('my-standard-scaler.pkl', 'rb') as file:
|
|
11 |
s_c = pickle.load(file)
|
12 |
|
13 |
# Definir la función de predicción
|
14 |
-
def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
Cy: float, CEC: float, eCa: float, eMg: float, eK: float, eNa: float, eAlH: float):
|
16 |
ECEC = eCa + eMg + eK + eNa + eAlH
|
17 |
xCa = eCa/ECEC
|
@@ -47,9 +59,20 @@ with gr.Blocks() as demo:
|
|
47 |
eCa = gr.Number(label="eCa (--)", value=19.44, interactive=True)
|
48 |
eNa = gr.Number(label="eNa (--)", value=0.15, interactive=True)
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
output = gr.Textbox(label=": soil bulk density", interactive=False)
|
52 |
-
|
53 |
-
|
|
|
|
|
|
|
54 |
|
55 |
demo.launch(share=False, debug=False)
|
|
|
11 |
s_c = pickle.load(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(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,
|
27 |
Cy: float, CEC: float, eCa: float, eMg: float, eK: float, eNa: float, eAlH: float):
|
28 |
ECEC = eCa + eMg + eK + eNa + eAlH
|
29 |
xCa = eCa/ECEC
|
|
|
59 |
eCa = gr.Number(label="eCa (--)", value=19.44, interactive=True)
|
60 |
eNa = gr.Number(label="eNa (--)", value=0.15, interactive=True)
|
61 |
|
62 |
+
with gr.Row():
|
63 |
+
with gr.Column():
|
64 |
+
submit_1 = gr.Button(value='Abdelbaki')
|
65 |
+
with gr.Column():
|
66 |
+
submit_2 = gr.Button(value='Benites')
|
67 |
+
with gr.Column():
|
68 |
+
submit_3 = gr.Button(value='MLRegression')
|
69 |
+
with gr.Column():
|
70 |
+
submit_4 = gr.Button(value='Random Forest')
|
71 |
output = gr.Textbox(label=": soil bulk density", interactive=False)
|
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)
|