Update app.py
Browse files
app.py
CHANGED
@@ -433,12 +433,15 @@ class RSM_BoxBehnken:
|
|
433 |
# 10. Cuadrados medios
|
434 |
ms_regression = ss_regression / df_regression
|
435 |
ms_residual = ss_residual / df_residual
|
436 |
-
ms_lack_of_fit =
|
437 |
-
|
|
|
|
|
438 |
|
439 |
# 11. Estadístico F y valor p para la falta de ajuste
|
440 |
-
f_lack_of_fit = ms_lack_of_fit / ms_pure_error if not np.isnan(ms_lack_of_fit) else np.nan
|
441 |
-
p_lack_of_fit = 1 - f.cdf(f_lack_of_fit, df_lack_of_fit, df_pure_error) if not np.isnan(f_lack_of_fit) else np.nan
|
|
|
442 |
|
443 |
# 12. Crear la tabla ANOVA detallada
|
444 |
detailed_anova_table = pd.DataFrame({
|
@@ -665,9 +668,9 @@ def fit_and_optimize_model():
|
|
665 |
zip_path = rsm.save_figures_to_zip()
|
666 |
|
667 |
return (
|
668 |
-
|
669 |
pareto_completo,
|
670 |
-
|
671 |
pareto_simplificado,
|
672 |
equation_output,
|
673 |
optimization_table,
|
@@ -796,7 +799,7 @@ def create_gradio_interface():
|
|
796 |
with gr.Column():
|
797 |
gr.Markdown("## Generar Gráficos de Superficie de Respuesta")
|
798 |
fixed_variable_input = gr.Dropdown(label="Variable Fija", choices=["Glucosa_g_L", "Proteina_Pescado_g_L", "Sulfato_Manganeso_g_L"], value="Glucosa_g_L") # Updated choices
|
799 |
-
fixed_level_input = gr.Slider(label="Nivel de Variable Fija (Natural Units)", minimum=
|
800 |
plot_button = gr.Button("Generar Gráficos")
|
801 |
with gr.Row():
|
802 |
left_button = gr.Button("<")
|
|
|
433 |
# 10. Cuadrados medios
|
434 |
ms_regression = ss_regression / df_regression
|
435 |
ms_residual = ss_residual / df_residual
|
436 |
+
ms_lack_of_fit = np.nan # Initialize ms_lack_of_fit to nan
|
437 |
+
if not np.isnan(df_lack_of_fit) and df_lack_of_fit != 0: # Check df_lack_of_fit is valid
|
438 |
+
ms_lack_of_fit = ss_lack_of_fit / df_lack_of_fit
|
439 |
+
ms_pure_error = ss_pure_error / df_pure_error if not np.isnan(df_pure_error) else np.nan
|
440 |
|
441 |
# 11. Estadístico F y valor p para la falta de ajuste
|
442 |
+
f_lack_of_fit = ms_lack_of_fit / ms_pure_error if not np.isnan(ms_lack_of_fit) and not np.isnan(ms_pure_error) and ms_pure_error != 0 else np.nan # Added nan checks and zero division check
|
443 |
+
p_lack_of_fit = 1 - f.cdf(f_lack_of_fit, df_lack_of_fit, df_pure_error) if not np.isnan(f_lack_of_fit) and not np.isnan(df_lack_of_fit) and not np.isnan(df_pure_error) else np.nan # Added nan checks
|
444 |
+
|
445 |
|
446 |
# 12. Crear la tabla ANOVA detallada
|
447 |
detailed_anova_table = pd.DataFrame({
|
|
|
668 |
zip_path = rsm.save_figures_to_zip()
|
669 |
|
670 |
return (
|
671 |
+
model_completo_output,
|
672 |
pareto_completo,
|
673 |
+
model_simplificado_output,
|
674 |
pareto_simplificado,
|
675 |
equation_output,
|
676 |
optimization_table,
|
|
|
799 |
with gr.Column():
|
800 |
gr.Markdown("## Generar Gráficos de Superficie de Respuesta")
|
801 |
fixed_variable_input = gr.Dropdown(label="Variable Fija", choices=["Glucosa_g_L", "Proteina_Pescado_g_L", "Sulfato_Manganeso_g_L"], value="Glucosa_g_L") # Updated choices
|
802 |
+
fixed_level_input = gr.Slider(label="Nivel de Variable Fija (Natural Units)", minimum=min(data['Glucosa_g_L']), maximum=max(data['Glucosa_g_L']), step=0.1, value=5.0) # Updated Slider - Using data min/max
|
803 |
plot_button = gr.Button("Generar Gráficos")
|
804 |
with gr.Row():
|
805 |
left_button = gr.Button("<")
|