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

Graph Profiler class to create a profile of an input graph #546

Merged
merged 18 commits into from
Jul 22, 2022

Conversation

MisterPNP
Copy link
Contributor

The graph profiler computes the following:

  • num_nodes
  • avg_node_degree
  • global_max_component_size
  • continuous_distributions
  • categorical_probabilities

WIP: case-specific properties, testing distributions

@taylorfturner taylorfturner enabled auto-merge (squash) July 19, 2022 16:34
auto-merge was automatically disabled July 19, 2022 17:09

Head branch was pushed to by a user without write access

@taylorfturner taylorfturner enabled auto-merge (squash) July 19, 2022 17:11
@JGSweets JGSweets added the Work In Progress Solution is being developed label Jul 19, 2022
auto-merge was automatically disabled July 19, 2022 17:14

Head branch was pushed to by a user without write access

@taylorfturner taylorfturner enabled auto-merge (squash) July 19, 2022 17:14
auto-merge was automatically disabled July 19, 2022 17:25

Head branch was pushed to by a user without write access

Comment on lines 268 to 280
"""
The following functions compute case-specific properties for the graph profile
"""
def _compute_conditional_probabilities(self):
return
def _compute_end_state_probabilities(self):
return
def _compute_link_probabilities(self):
return
def _compute_activation_probabilities(self):
return
def _compute_deactivation_probabilities(self):
return
Copy link
Contributor

Choose a reason for hiding this comment

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

cut these out since not doing yet

Comment on lines 135 to 123
if profile_key == "<PROP>":
if "<PROP>" in calcs_dict_keys:
continue
profile.pop(profile_key)
Copy link
Contributor

Choose a reason for hiding this comment

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

need to update these specific to the props we are tracking

Comment on lines 79 to 76
self._load_data()

Copy link
Contributor

Choose a reason for hiding this comment

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

let's remove this

list_edges = []
list_nodes = set()

for line in range(0, len(csv_as_list)):
Copy link
Contributor

Choose a reason for hiding this comment

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

is this supposed to be updated?

self.assertTrue(True, True)

# WIP
def test_diff(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

sounds weird, but maybe just validate not implemented and that we raise the expected error str


# WIP
def test_report(self):
self.assertTrue(True, True)
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above, we should raise not implemented for this as well.

Comment on lines 15 to 29
def setUp(self):
self.graph = nx.Graph()
self.graph.add_nodes_from([1, 2, 3, 4])
self.graph.add_edges_from(
[
(1, 2, {"id": 1, "weight": 2.5}),
(2, 3, {"id": 2, "weight": 1.7}),
(3, 4, {"id": 3, "weight": 1.8}),
(4, 1, {"id": 4, "weight": 4.1}),
(1, 3, {"id": 4, "weight": 2.1}),
]
)
self.graph_profile = GraphProfile("graph")
Copy link
Contributor

Choose a reason for hiding this comment

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

this will run before every test.
we can do a setUpTestData to do it once at class init
need to add the classmethod dec and change self -> cls


class TestGraphProfiler(unittest.TestCase):
def setUp(self):
self.graph = nx.Graph()
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to ensure the GraphProfile can ingest a GraphData, hence ideal if we setup our own GraphData class.
We could mock it such that create a GraphData Class and set the values to be this graph.

Copy link
Contributor

Choose a reason for hiding this comment

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

or mock the class


# WIP
def test_init(self):
self.assertTrue(True, True)
Copy link
Contributor

Choose a reason for hiding this comment

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

we should test being able to init and that the proper checks occur. given setup. e.g. base conditions

Comment on lines 85 to 90
def test_continuous_distribution(self):
self.assertTrue(True)

# WIP
def test_categorical_distribution(self):
self.assertTrue(True)
Copy link
Contributor

Choose a reason for hiding this comment

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

are we able to get values for these to tests from the graph?

Comment on lines 108 to 122
for profile_key in profile_keys:
# need to add props
if profile_key == "num_nodes":
if "num_nodes" in calcs_dict_keys:
continue
if profile_key == "num_edges":
if "num_edges" in calcs_dict_keys:
continue
if profile_key == "categorical_attributes":
if "categorical_attributes" in calcs_dict_keys:
continue
if profile_key == "continuous_attributes":
if "continuous_attributes" in calcs_dict_keys:
continue
if profile_key == "avg_node_degree":
if "avg_node_degree" in calcs_dict_keys:
continue
if profile_key == "global_max_component_size":
if "global_max_component_size" in calcs_dict_keys:
continue
if profile_key == "continuous_distribution":
if "continuous_distribution" in calcs_dict_keys:
continue
if profile_key == "categorical_distribution":
if "categorical_distribution" in calcs_dict_keys:
continue
Copy link
Contributor

@JGSweets JGSweets Jul 21, 2022

Choose a reason for hiding this comment

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

could we reduce this with a list and:

for profile_key in profile_keys:
    # need to add props
    if profile_key in ["num_nodes", ....]:
        if profile_key in calcs_dict_keys:
            continue

@JGSweets JGSweets enabled auto-merge (squash) July 21, 2022 21:32
auto-merge was automatically disabled July 22, 2022 17:45

Head branch was pushed to by a user without write access

auto-merge was automatically disabled July 22, 2022 18:05

Head branch was pushed to by a user without write access

from collections import defaultdict

import networkx as nx
import utils
Copy link
Contributor

Choose a reason for hiding this comment

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

this is internal so should be moved below

@taylorfturner taylorfturner enabled auto-merge (squash) July 22, 2022 20:28
@taylorfturner taylorfturner merged commit 926608e into capitalone:main Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Work In Progress Solution is being developed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants