Skip to content

Commit 84b46ac

Browse files
committed
Working prediction plot
1 parent a2492c3 commit 84b46ac

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

gui/app.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ def main():
222222
"batch_size",
223223
]
224224
],
225-
outputs=blocks["df"],
225+
outputs=[blocks["df"], blocks["predictions_plot"]],
226+
show_progress=True,
226227
)
227228

228229
# Any update to the equation choice will trigger a plot_example_data:

gui/plots.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ def plot_example_data(test_equation, num_points, noise_level, data_seed):
6161
return fig
6262

6363

64+
def plot_predictions(y, ypred):
65+
fig, ax = plt.subplots(figsize=(6, 6), dpi=100)
66+
67+
ax.scatter(y, ypred, alpha=0.7, edgecolors="w", s=50)
68+
69+
stylize_axis(ax)
70+
71+
ax.set_xlabel("true")
72+
ax.set_ylabel("prediction")
73+
fig.tight_layout(pad=2)
74+
75+
return fig
76+
77+
6478
def stylize_axis(ax):
6579
ax.grid(True, which="both", ls="--", linewidth=0.5, color="gray", alpha=0.5)
6680
ax.spines["top"].set_visible(False)

gui/processing.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import pandas as pd
99
from data import generate_data, read_csv
10+
from plots import plot_predictions
1011

1112
EMPTY_DF = lambda: pd.DataFrame(
1213
{
@@ -188,7 +189,10 @@ def processing(
188189
)
189190
)
190191
out = PERSISTENT_READER.out_queue.get()
192+
predictions = out["ypred"]
191193
equations = out["equations"]
192-
yield equations[["Complexity", "Loss", "Equation"]]
194+
yield equations[["Complexity", "Loss", "Equation"]], plot_predictions(
195+
y, predictions
196+
)
193197

194198
time.sleep(0.1)

0 commit comments

Comments
 (0)