Open LucaCappelletti94 opened 2 years ago
Hi @LucaCappelletti94 this is quite pretty! Thanks for posting the embedding itself. Do you have code that was used to generate this that you want to PR in here?
Two big caveats:
I absolutely understand that this is a graph with several issues and that TransE may not be the best embedding model for this task, but it still remains a decent lower bound. If we were to see just a gaussian ball instead of a sensible TSNE decomposition I may have been a bit more worried.
Which model would you consider best for this task? I can benchmark it against TransE quite easily and see how much it improves.
I'm heading out to get groceries, I'll write the code here by this evening. Can I consider this graph URL stable, so to add it to ensmallen's automatic retrieval?
Hopefully with improved versions of the graph we will see also improved embedding, this is just a lower bound.
I wouldn't consider this stable. I'll set up zenodo dumping soon
One note: I just noticed I have inverted the labels of the distances. I will re-run the embedding and get the fixed image in a bit.
Hello @cthoyt, sorry for the long delay. I got swamped by PhD-related things. I finally got some time to provide the code and the correct images (as soon as they finish rendering).
So, first, install the latest version of 🍇 by using pip install grape
. Then, you can load up this repository's graph by using:
from grape import Graph
graph = Graph.from_csv(
edge_path="graph.tsv",
sources_column_number=0,
edge_list_edge_types_column_number=1,
destinations_column_number=2,
directed=False,
name="OBO Foundry"
)
Since this graph is relatively small and does not raise any memory concerns, you can enable the time-memory speedups to get a faster execution. It primarily means that instead of using the default Elias-fano data structure, I switch to either a COO or a CSR, depending on what is needed for a task. By default, when running an enable
, it changes to a CSR.
graph.enable()
To get the graph report, display the graph in a jupyter cell or just run print(graph)
. Consider that the report is in HTML, so it is best used in a jupyter notebook.
For the visualization part, you can run:
from grape import GraphVisualizer
GraphVisualizer(graph).fit_and_plot_all("SkipGram")
By default, this will run my implementation of SkipGram. We support a few other embedding algorithms and, most interestingly, for scientific reproducibility, we have support for wrapping arbitrary third-party libraries. For instance, we have support for PyKeen, and you can run (or, in this case, visualize) quite a few PyKeen models by executing:
GraphVisualizer(graph).fit_and_plot_all(
embedding_model="BoxE",
library_name="PyKeen"
)
If you'd like to learn more 🍇-related things, we have created a Telegram group and a (Discord server)[https://discord.gg/Nda2cqYvTN].
While I cannot share the node embedding (for now) since I am gzipping it to upload it on internet archive, in the meantime I can share some visualizations on the TransE embedding made with the GraPE library.