Created
September 6, 2020 06:01
-
-
Save a-agmon/22a7f1d58e9259b527023d8ac4bd4046 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
# assign each vector the cluster withwhich it is most associated | |
df_avg['cluster'] = np.argmax(lda.transform(df_avg), axis=1) | |
#chart the different clusters | |
fig, axs = plt.subplots(3, 1, sharex=True, sharey=True) | |
df_avg.iloc[:,:-1].loc[df_avg.cluster == 0].mean().plot.bar(ax=axs[0]) | |
axs[0].set_title('Category - 0 (Evening/Night)') | |
df_avg.iloc[:,:-1].loc[df_avg.cluster == 1].mean().plot.bar(ax=axs[1]) | |
axs[1].set_title('Category - 1 (Normal Day)') | |
df_avg.iloc[:,:-1].loc[df_avg.cluster == 2].mean().plot.bar(ax=axs[2]) | |
axs[2].set_title('Category - 2 (Late Night/Early Morning)') | |
for ax in axs.flat: | |
ax.set(xlabel='hours', ylabel='views') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment