Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add notebook for visualizing projections with PyVis #766

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

adamnsch
Copy link
Contributor

@adamnsch adamnsch commented Oct 15, 2024

Thank you for your contribution to the Graph Data Science Client project.

Before submitting this PR, please read Contributing to the Neo4j Ecosystem.

Make sure:

  • You signed the Neo4j CLA (Contributor License Agreement) so that we are allowed to ship your code in our library
  • Your contribution is covered by tests

Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for neo4j-graph-data-science-client ready!

Name Link
🔨 Latest commit 450af65
🔍 Latest deploy log https://app.netlify.com/sites/neo4j-graph-data-science-client/deploys/670e79d3a4079f00082ef94e
😎 Deploy Preview https://deploy-preview-766--neo4j-graph-data-science-client.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Oct 15, 2024

Deploy Preview for neo4j-graph-data-science-client canceled.

Name Link
🔨 Latest commit 0703121
🔍 Latest deploy log https://app.netlify.com/sites/neo4j-graph-data-science-client/deploys/67125add65baf600083c4f1c

[source, python, role=no-test]
----
net = Network(notebook = True,
cdn_resources="remote",
Copy link
Contributor Author

@adamnsch adamnsch Oct 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought ruff would fix this ugly indentation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to format notebooks according to https://docs.astral.sh/ruff/configuration/#jupyter-notebook-discovery

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue with our setup .. see #768

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried after rebasing on main, but the formatting issue remains the same after running makestyle locally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

likely wrong pandoc version installed locally.

@adamnsch
Copy link
Contributor Author

It would be nice to include either a html or image for the visualization in the docs somehow...

@adamnsch
Copy link
Contributor Author

Screenshot 2024-10-15 at 16 35 11
What the visualization looks like :)

Copy link
Contributor

@FlorentinD FlorentinD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start!

Looking forward to extend this notebook with other options.

README.md Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
[source, python, role=no-test]
----
net = Network(notebook = True,
cdn_resources="remote",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be able to format notebooks according to https://docs.astral.sh/ruff/configuration/#jupyter-notebook-discovery

doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
doc/modules/ROOT/pages/tutorials/visualize-with-pyvis.adoc Outdated Show resolved Hide resolved
@FlorentinD
Copy link
Contributor

looked a bit into the convert.sh complain ... resulted in #767 use the correct version in dev.txt

@adamnsch
Copy link
Contributor Author

looked a bit into the convert.sh complain ... resulted in #767 use the correct version in dev.txt

Ok, nice! I will have a look

adamnsch and others added 2 commits October 16, 2024 14:17
Co-Authored-By: Florentin Dörre <[email protected]>
Comment on lines 177 to 178
Unsuprisingly we can see that papers largely seem clustered by academic
subject. We also note that some nodes appear larger in size, indicating
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just the visualization does not explain to us what the academic subjects are right?
How about we add the subject as a label?

@FlorentinD
Copy link
Contributor

@adamnsch updated pandoc on CI -> the checkstyle should go green now 🤞

@adamnsch
Copy link
Contributor Author

@adamnsch updated pandoc on CI -> the checkstyle should go green now 🤞

Excellent work 👏

= Visualizing GDS Projections


https://colab.research.google.com/github/neo4j/graph-data-science-client/blob/main/examples/import-sample-export-gnn.ipynb[image:https://colab.research.google.com/assets/colab-badge.svg[Open
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it a wrong link?

Copy link
Contributor

@FlorentinD FlorentinD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to pull the logic into a graph method for convenience

an interactive graphical visualization of the specified graph
"""

actual_node_properties = list(chain.from_iterable(self.node_properties().to_dict().values()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can reduce it to set()

Comment on lines +359 to +370
if visual_graph != self._name:
self._query_runner.call_procedure(
endpoint="gds.graph.drop",
params=CallParameters(graph_name=visual_graph),
custom_error=False,
)
elif clean_up_size_prop:
self._query_runner.call_procedure(
endpoint="gds.graph.nodeProperties.drop",
params=CallParameters(graph_name=visual_graph, nodeProperties=size_property),
custom_error=False,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest to have its own Graph.sample method and warn if the graph is too big.
Would avoid side-effect, the user is not aware off.

@@ -230,3 +231,194 @@ def __repr__(self) -> str:
"memoryUsage",
]
return f"{self.__class__.__name__}({self._graph_info(yields=yield_fields).to_dict()})"

def visualize(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i like the idea of this.
maybe we can have different backends to be used?
pyvis/nvl? (with default to nvl)

should have a thought on the dependency. Likely similar optional dependency as for networkx

@FlorentinD
Copy link
Contributor

#772 is the PR to allow replacing outputs for the doc version. Not yet ready but closing in :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants