Spaces:
Sleeping
Sleeping
Commit
·
b66c2b6
1
Parent(s):
b55fce9
Update app.py
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import pandas as pd
|
|
3 |
import statsmodels.api as sm
|
4 |
import numpy as np
|
5 |
import matplotlib.pyplot as plt
|
|
|
6 |
from itertools import product
|
7 |
|
8 |
# Function to apply transformations to both features and target
|
@@ -66,25 +67,29 @@ def load_excel(file):
|
|
66 |
|
67 |
# Plot 1: Transformed_target vs. Predicted values
|
68 |
predicted = model.predict(transformed_features)
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
73 |
|
74 |
# Plot 2: Residuals
|
75 |
residuals = model.resid
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
|
81 |
# Create a table for residuals
|
82 |
residuals_table = pd.DataFrame({'Residuals': residuals})
|
83 |
|
84 |
results.append({
|
85 |
'best_equation': model.summary().as_text(),
|
86 |
-
'plot_transformed_vs_predicted':
|
87 |
-
'plot_residuals_histogram':
|
88 |
'residuals_table': residuals_table
|
89 |
})
|
90 |
|
@@ -96,10 +101,10 @@ iface = gr.Interface(
|
|
96 |
fn=load_excel,
|
97 |
inputs="file",
|
98 |
outputs=[
|
99 |
-
gr.Textbox(label="
|
100 |
-
gr.
|
101 |
-
gr.
|
102 |
-
gr.DataFrame(label="
|
103 |
],
|
104 |
live=False,
|
105 |
theme=gr.themes.Monochrome(),
|
|
|
3 |
import statsmodels.api as sm
|
4 |
import numpy as np
|
5 |
import matplotlib.pyplot as plt
|
6 |
+
import seaborn as sns
|
7 |
from itertools import product
|
8 |
|
9 |
# Function to apply transformations to both features and target
|
|
|
67 |
|
68 |
# Plot 1: Transformed_target vs. Predicted values
|
69 |
predicted = model.predict(transformed_features)
|
70 |
+
plt.figure(figsize=(18, 6))
|
71 |
+
sns.scatterplot(x=transformed_target, y=predicted)
|
72 |
+
plt.xlabel("Observados")
|
73 |
+
plt.ylabel("Previstos")
|
74 |
+
plt.tight_layout()
|
75 |
+
plt.plot(X_plot, Y_plot, color='r')
|
76 |
+
plt.savefig("scatterplot.png")
|
77 |
+
plt.close()
|
78 |
|
79 |
# Plot 2: Residuals
|
80 |
residuals = model.resid
|
81 |
+
plt.figure(figsize=(18, 6))
|
82 |
+
sns.histplot(data = residuals, kde=True)
|
83 |
+
plt.savefig("histplot.png")
|
84 |
+
plt.close()
|
85 |
|
86 |
# Create a table for residuals
|
87 |
residuals_table = pd.DataFrame({'Residuals': residuals})
|
88 |
|
89 |
results.append({
|
90 |
'best_equation': model.summary().as_text(),
|
91 |
+
'plot_transformed_vs_predicted': "scatterplot.png", # Use the figure object
|
92 |
+
'plot_residuals_histogram': "histplot.png", # Use the figure object
|
93 |
'residuals_table': residuals_table
|
94 |
})
|
95 |
|
|
|
101 |
fn=load_excel,
|
102 |
inputs="file",
|
103 |
outputs=[
|
104 |
+
gr.Textbox(label="Resultados Estatísticos", type="text"),
|
105 |
+
gr.Image(label="Gráfico - Observados X Previstos"),
|
106 |
+
gr.Image(label="Histograma de Resíduos"),
|
107 |
+
gr.DataFrame(label="Tabela dos Resíduos", type="pandas"),
|
108 |
],
|
109 |
live=False,
|
110 |
theme=gr.themes.Monochrome(),
|