Last active
December 19, 2018 16:12
-
-
Save RyotaBannai/b1819aa8982997e9140115d5e30bf993 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import seaborn as sns; sns.set() | |
ax = plt.gca() | |
ax.set_xlabel('Principal component 1') | |
ax.set_ylabel('Principal component 2') | |
plt.scatter(X_raw[:, 0], X_raw[:, 1], c='#663399', alpha=0.5) | |
plt.scatter(X_mean[0], X_mean[1], c='red', s=50) | |
plt.axis('equal') | |
for length, vector in zip(w_12, v_12): | |
vector[0] = -vector[0] # Little tweak the sign | |
dir_ = vector * 3 * np.sqrt(length) # Standard Deviation 3 | |
start = X_mean; end = start + dir_ | |
arrowprops = dict(arrowstyle='->', linewidth=2, | |
shrinkA=0, shrinkB=0, color='red', alpha=0.5) | |
ax.annotate('', xy=end, xytext=start, arrowprops=arrowprops) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment