Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,13 +26,13 @@ MODEL_FALLBACKS = [MODELS_DIR / "model.joblib", MODELS_DIR / "model.pkl"]
|
|
| 26 |
COLORS = {"pred": "#1f77b4", "actual": "#f2b702", "ref": "#5a5a5a"}
|
| 27 |
|
| 28 |
# ---- Plot sizing controls ----
|
| 29 |
-
CROSS_W =
|
| 30 |
-
CROSS_H =
|
| 31 |
-
TRACK_W =
|
| 32 |
-
TRACK_H =
|
| 33 |
-
FONT_SZ =
|
| 34 |
-
PLOT_COLS = [
|
| 35 |
-
CROSS_NUDGE = 0.0
|
| 36 |
|
| 37 |
# =========================
|
| 38 |
# Page / CSS
|
|
@@ -172,14 +172,16 @@ def cross_plot_static(actual, pred):
|
|
| 172 |
fixed_min, fixed_max = 6000, 10000
|
| 173 |
ticks = np.arange(fixed_min, fixed_max + 1, 1000)
|
| 174 |
|
|
|
|
|
|
|
| 175 |
fig, ax = plt.subplots(
|
| 176 |
-
figsize=(
|
| 177 |
-
dpi=
|
| 178 |
constrained_layout=False
|
| 179 |
)
|
| 180 |
|
| 181 |
# points
|
| 182 |
-
ax.scatter(a, p, s=
|
| 183 |
|
| 184 |
# 1:1 diagonal
|
| 185 |
ax.plot([fixed_min, fixed_max], [fixed_min, fixed_max],
|
|
@@ -191,7 +193,7 @@ def cross_plot_static(actual, pred):
|
|
| 191 |
ax.set_xticks(ticks)
|
| 192 |
ax.set_yticks(ticks)
|
| 193 |
|
| 194 |
-
# equal aspect → true 45°
|
| 195 |
ax.set_aspect("equal", adjustable="box")
|
| 196 |
|
| 197 |
# thousands formatting
|
|
@@ -199,20 +201,22 @@ def cross_plot_static(actual, pred):
|
|
| 199 |
ax.xaxis.set_major_formatter(fmt)
|
| 200 |
ax.yaxis.set_major_formatter(fmt)
|
| 201 |
|
| 202 |
-
# labels (
|
| 203 |
-
ax.set_xlabel("Actual UCS (psi)", fontweight="bold", fontsize=
|
| 204 |
-
ax.set_ylabel("Predicted UCS (psi)", fontweight="bold", fontsize=
|
|
|
|
| 205 |
|
| 206 |
# grid & frame
|
| 207 |
-
ax.grid(True, linestyle=":", alpha=0.
|
| 208 |
for spine in ax.spines.values():
|
| 209 |
-
spine.set_linewidth(1.
|
| 210 |
spine.set_color("#444")
|
| 211 |
|
| 212 |
-
#
|
| 213 |
-
fig.subplots_adjust(left=0.
|
| 214 |
return fig
|
| 215 |
|
|
|
|
| 216 |
# =========================
|
| 217 |
# Track plot (Plotly)
|
| 218 |
# =========================
|
|
|
|
| 26 |
COLORS = {"pred": "#1f77b4", "actual": "#f2b702", "ref": "#5a5a5a"}
|
| 27 |
|
| 28 |
# ---- Plot sizing controls ----
|
| 29 |
+
CROSS_W = 420 # px (explicit, not None)
|
| 30 |
+
CROSS_H = 420 # px
|
| 31 |
+
TRACK_W = 320 # px (slightly narrower to avoid crowding)
|
| 32 |
+
TRACK_H = 740 # px
|
| 33 |
+
FONT_SZ = 13
|
| 34 |
+
PLOT_COLS = [36, 6, 28] # wider spacer so plots never bump into each other
|
| 35 |
+
CROSS_NUDGE = 0.0 # keep 0 unless you really want an inner pad
|
| 36 |
|
| 37 |
# =========================
|
| 38 |
# Page / CSS
|
|
|
|
| 172 |
fixed_min, fixed_max = 6000, 10000
|
| 173 |
ticks = np.arange(fixed_min, fixed_max + 1, 1000)
|
| 174 |
|
| 175 |
+
# fixed px size = (figsize * dpi)
|
| 176 |
+
dpi = 110
|
| 177 |
fig, ax = plt.subplots(
|
| 178 |
+
figsize=(CROSS_W / dpi, CROSS_H / dpi),
|
| 179 |
+
dpi=dpi,
|
| 180 |
constrained_layout=False
|
| 181 |
)
|
| 182 |
|
| 183 |
# points
|
| 184 |
+
ax.scatter(a, p, s=16, c=COLORS["pred"], alpha=0.9, linewidths=0)
|
| 185 |
|
| 186 |
# 1:1 diagonal
|
| 187 |
ax.plot([fixed_min, fixed_max], [fixed_min, fixed_max],
|
|
|
|
| 193 |
ax.set_xticks(ticks)
|
| 194 |
ax.set_yticks(ticks)
|
| 195 |
|
| 196 |
+
# equal aspect → true 45°
|
| 197 |
ax.set_aspect("equal", adjustable="box")
|
| 198 |
|
| 199 |
# thousands formatting
|
|
|
|
| 201 |
ax.xaxis.set_major_formatter(fmt)
|
| 202 |
ax.yaxis.set_major_formatter(fmt)
|
| 203 |
|
| 204 |
+
# labels + ticks (smaller so they don't dominate)
|
| 205 |
+
ax.set_xlabel("Actual UCS (psi)", fontweight="bold", fontsize=12)
|
| 206 |
+
ax.set_ylabel("Predicted UCS (psi)", fontweight="bold", fontsize=12)
|
| 207 |
+
ax.tick_params(labelsize=10)
|
| 208 |
|
| 209 |
# grid & frame
|
| 210 |
+
ax.grid(True, linestyle=":", alpha=0.3)
|
| 211 |
for spine in ax.spines.values():
|
| 212 |
+
spine.set_linewidth(1.1)
|
| 213 |
spine.set_color("#444")
|
| 214 |
|
| 215 |
+
# moderate margins; keeps labels readable but not huge
|
| 216 |
+
fig.subplots_adjust(left=0.16, bottom=0.16, right=0.98, top=0.98)
|
| 217 |
return fig
|
| 218 |
|
| 219 |
+
|
| 220 |
# =========================
|
| 221 |
# Track plot (Plotly)
|
| 222 |
# =========================
|