Created
August 31, 2023 14:01
-
-
Save abhijeet-talaulikar/f409135b08babf796dc7fbdacfbd3d1c to your computer and use it in GitHub Desktop.
This file contains 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
!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