Skip to content

Commit

Permalink
Save changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Ramirez committed Aug 26, 2024
1 parent afabe9e commit a1324f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
18 changes: 16 additions & 2 deletions pf2/figures/figureA10.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pf2.predict import predict_mortality, run_plsr



def makeFigure():
"""Get a list of the axis objects and create a figure."""
ax, f = getSetup((8, 8), (2, 2))
Expand All @@ -40,6 +41,7 @@ def makeFigure():
patient_factor,
meta
)



names = ["COVID-19", "Non-COVID 19"]
Expand All @@ -53,6 +55,9 @@ def makeFigure():
s=150,
c="tab:red"
)

print(plsr.x_loadings_[:, 0])
print(plsr.x_loadings_[:, 1])
x_ax.scatter(
plsr.x_loadings_[:, 0],
plsr.x_loadings_[:, 1],
Expand All @@ -75,12 +80,21 @@ def makeFigure():

x_ax.plot([-100, 100], [0, 0], linestyle="--", color="k", zorder=-3)
x_ax.plot([0, 0], [-100, 100], linestyle="--", color="k", zorder=-3)
x_ax.set_xlim(x_lims)
x_ax.set_ylim(y_lims)
# x_ax.set_xlim(x_lims)
# x_ax.set_ylim(y_lims)

if ax_index == 0:
x_ax.set_ylim([-.6, .6])
x_ax.set_xlim([-.6, .6])
else:
x_ax.set_ylim([-1, 1])
x_ax.set_xlim([-1, 1])

x_ax.set_xlabel("PLSR 1")
x_ax.set_ylabel("PLSR 2")
x_ax.set_title(f"{name}: X-loadings")




return f
3 changes: 2 additions & 1 deletion pf2/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def run_plsr(
plsr = PLSRegression(
n_components=n_components,
scale=False,
max_iter=int(1E5)
max_iter=int(1E15)
)
rfe_cv = RFECV(plsr, step=1, cv=SKF, min_features_to_select=n_components)
rfe_cv.fit(data, labels)
Expand All @@ -55,6 +55,7 @@ def run_plsr(
plsr.coef_.squeeze(),
index=data.columns
)
print(plsr.coef_)

if proba:
return probabilities, plsr
Expand Down

0 comments on commit a1324f3

Please sign in to comment.