Spaces:
Running
Running
Update src/streamlit_app.py
Browse files- src/streamlit_app.py +13 -2
src/streamlit_app.py
CHANGED
|
@@ -461,13 +461,24 @@ if submitted:
|
|
| 461 |
surv_fn, landmarks = predict_patient_survival(cph, patient_design, years=[3, 5, 10])
|
| 462 |
|
| 463 |
st.subheader("Individual adjusted survival curve")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 464 |
fig, ax = plt.subplots(figsize=(8, 5))
|
| 465 |
-
|
|
|
|
| 466 |
ax.set_title("Predicted adjusted survival curve")
|
| 467 |
-
ax.set_xlabel("
|
| 468 |
ax.set_ylabel("Survival probability")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 469 |
st.pyplot(fig, bbox_inches="tight")
|
| 470 |
plt.clf()
|
|
|
|
| 471 |
|
| 472 |
st.write("Landmark survival probabilities:")
|
| 473 |
for y in [3, 5, 10]:
|
|
|
|
| 461 |
surv_fn, landmarks = predict_patient_survival(cph, patient_design, years=[3, 5, 10])
|
| 462 |
|
| 463 |
st.subheader("Individual adjusted survival curve")
|
| 464 |
+
# Convert days → years for plotting
|
| 465 |
+
surv_years = surv_fn.copy()
|
| 466 |
+
surv_years.index = surv_years.index / 365.25
|
| 467 |
+
|
| 468 |
fig, ax = plt.subplots(figsize=(8, 5))
|
| 469 |
+
surv_years.plot(ax=ax, legend=False)
|
| 470 |
+
|
| 471 |
ax.set_title("Predicted adjusted survival curve")
|
| 472 |
+
ax.set_xlabel("Years")
|
| 473 |
ax.set_ylabel("Survival probability")
|
| 474 |
+
|
| 475 |
+
# Optional: make ticks clean integers
|
| 476 |
+
ax.set_xlim(left=0)
|
| 477 |
+
ax.xaxis.set_major_locator(plt.MaxNLocator(integer=True))
|
| 478 |
+
|
| 479 |
st.pyplot(fig, bbox_inches="tight")
|
| 480 |
plt.clf()
|
| 481 |
+
|
| 482 |
|
| 483 |
st.write("Landmark survival probabilities:")
|
| 484 |
for y in [3, 5, 10]:
|