Skip to content

Instantly share code, notes, and snippets.

@abhijeet-talaulikar
Created August 31, 2023 14:01
Show Gist options
  • Save abhijeet-talaulikar/f409135b08babf796dc7fbdacfbd3d1c to your computer and use it in GitHub Desktop.
Save abhijeet-talaulikar/f409135b08babf796dc7fbdacfbd3d1c to your computer and use it in GitHub Desktop.
!git clone https://github.com/tctianchi/pyvenn.git
%matplotlib inline
from pyvenn import venn
# Get aspect labels
aspects = pd.DataFrame({
"aspect": proba_df.idxmax(axis=1),
"max_proba": proba_df.lookup(proba_df.index, proba_df.idxmax(axis=1))
}).groupby("aspect").sum().reset_index().sort_values("max_proba", ascending=False).head(5).aspect.to_list()
# Create sets for venn diagram
topic_ids = []
for col in aspects:
topic_ids.append(
proba_df.loc[proba_df[col] > 0, col].index.to_list(),
)
# Plot
labels = venn.get_labels(topic_ids, fill=['number'])
fig, ax = venn.venn5(labels, names=aspects)
ax.legend(aspects, prop = { "size": 20 }, loc ="upper left", bbox_to_anchor=(1, 0.5))
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment