Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def scree_plot(S, n_components=10):
- """
- Plot proportion of variance contained in each individual component
- """
- components = np.arange(n_components) + 1
- S = S ** 2
- total_var = np.sum(S[:n_components])
- proportions = S / total_var
- plt.bar(components, proportions[:n_components])
- plt.title("Variance Proportions across Principal Components")
- plt.xlabel("Principal Component")
- plt.ylabel("Proportion")
- plt.show()
- # raise NotImplementedError
- def plot_component_vector(V):
- # raise NotImplementedError
- col = np.abs(V[0,:])
- # print("col:", col)
- xvals = np.arange(V.shape[1])
- plt.bar(xvals, col)
- plt.title("Breakdown of First Principal Component into Features")
- plt.xlabel("Feature")
- plt.ylabel("Value")
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement