Factor Investing, Dimensionality Reduction, Sklearn, Python.
np.argmax(cumsum >= 0.95) + 1 # d equals 154 we got d = 7. plt.figure(figsize=(6, 4)) plt.plot(cumsum, linewidth=3) plt.xlabel("Dimensions") plt.ylabel("Explained Variance") plt.plot([d, d], [0, 0.975], "k:") plt.plot([0, d], [0.975, 0.975], "k:") plt.plot(d, 0.975, "ko") plt.annotate("Elbow",