Skip to content

Commit 2c77b00

Browse files
committed
Touching up pcovc vs pca example
1 parent 9d8ea28 commit 2c77b00

File tree

1 file changed

+20
-21
lines changed

1 file changed

+20
-21
lines changed

examples/pcovc/PCovC_Comparison.py

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545
pca.fit(X_scaled, y)
4646
T_pca = pca.transform(X_scaled)
4747

48-
fig, axis = plt.subplots()
49-
scatter = axis.scatter(T_pca[:, 0], T_pca[:, 1], c=y)
50-
axis.set(xlabel="PC$_1$", ylabel="PC$_2$")
51-
axis.legend(
48+
fig, ax = plt.subplots()
49+
scatter = ax.scatter(T_pca[:, 0], T_pca[:, 1], c=y)
50+
ax.set(xlabel="PC$_1$", ylabel="PC$_2$")
51+
ax.legend(
5252
scatter.legend_elements()[0][::-1],
5353
load_breast_cancer().target_names[::-1],
5454
loc="upper right",
@@ -66,9 +66,9 @@
6666

6767
T_lda = lda.transform(X_scaled)
6868

69-
fig, axis = plt.subplots()
70-
axis.scatter(-T_lda[:], np.zeros(len(T_lda[:])), c=y)
71-
axis.set(xlabel="LD$_1$", ylabel="LD$_2$")
69+
fig, ax = plt.subplots()
70+
ax.scatter(T_lda[:], np.zeros(len(T_lda[:])), c=y)
71+
ax.set(xlabel="LDA$_1$", ylabel="LDA$_2$")
7272

7373
# %%
7474
#
@@ -91,21 +91,20 @@
9191

9292
T_pcovc = pcovc.transform(X_scaled)
9393

94-
fig, axis = plt.subplots()
95-
axis.scatter(T_pcovc[:, 0], T_pcovc[:, 1], c=y)
96-
axis.set(xlabel="PCov$_1$", ylabel="PCov$_2$")
94+
fig, ax = plt.subplots()
95+
ax.scatter(T_pcovc[:, 0], T_pcovc[:, 1], c=y)
96+
ax.set(xlabel="PCov$_1$", ylabel="PCov$_2$")
9797

9898
# %%
9999
#
100100
# A side-by-side comparison of the
101-
# three techniques (PCA, LDA, and PCovC):
102-
103-
n_models = 3
104-
105-
fig, axes = plt.subplots(1, n_models, figsize=(6 * n_models, 5))
106-
axes[0].scatter(T_pca[:, 0], T_pca[:, 1], c=y)
107-
axes[0].set_title("PCA")
108-
axes[1].scatter(-T_lda[:], np.zeros(len(T_lda[:])), c=y)
109-
axes[1].set_title("LDA")
110-
axes[2].scatter(T_pcovc[:, 0], T_pcovc[:, 1], c=y)
111-
axes[2].set_title("PCovC")
101+
# three maps (PCA, LDA, and PCovC):
102+
103+
fig, axs = plt.subplots(1, 3, figsize=(18, 5))
104+
axs[0].scatter(T_pca[:, 0], T_pca[:, 1], c=y)
105+
axs[0].set_title("PCA")
106+
axs[1].scatter(T_lda, np.zeros(len(T_lda)), c=y)
107+
axs[1].set_title("LDA")
108+
axs[2].scatter(T_pcovc[:, 0], T_pcovc[:, 1], c=y)
109+
axs[2].set_title("PCovC")
110+
plt.show()

0 commit comments

Comments
 (0)