stellargraph / stellargraph

StellarGraph - Machine Learning on Graphs
https://stellargraph.readthedocs.io/
Apache License 2.0
2.94k stars 430 forks source link

Standardise neighbour/neighbor spelling #666

Open kjun9 opened 4 years ago

kjun9 commented 4 years ago

Description

Both spelling alternatives are used in various places, and it's a bit confusing especially if this happens for function names and parameters.

$ grep -ri --exclude-dir "__pycache__" "neighbor" stellargraph
stellargraph/core/graph.py:    def neighbors(
stellargraph/core/graph.py:        return self._graph.neighbors(
stellargraph/core/graph_networkx.py:    def neighbors(
stellargraph/core/graph_networkx.py:        return self.neighbors(node, include_edge_weight, edge_types)
stellargraph/core/graph_networkx.py:        return self.neighbors(node, include_edge_weight, edge_types)
stellargraph/layer/graph_attention.py:            # Linear combination with neighbors' features [YT: see Eq. 4]
stellargraph/layer/graph_attention.py:            # Linear combination with neighbors' features [YT: see Eq. 4]
stellargraph/layer/hinsage.py:        * input_neighbor_tree: A list of (node_type, [children]) tuples that specify the
stellargraph/layer/hinsage.py:            self.subtree_schema = kwargs["input_neighbor_tree"]
stellargraph/layer/hinsage.py:        neighbor_sizes = list(it.accumulate([1] + self.n_samples, op.mul))
stellargraph/layer/hinsage.py:                cnode: (neighbor_sizes[level], self.input_dims[stree[cnode][0]])
stellargraph/data/explorer.py:    def neighbors(self, node):
stellargraph/data/explorer.py:        return list(self.graph.neighbors(node))
stellargraph/data/explorer.py:            neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:                for neighbor in self.graph.neighbors(node):
stellargraph/data/explorer.py:                    for weight in self.graph.edge_weights(node, neighbor):
stellargraph/data/explorer.py:                                    weight, node, neighbor
stellargraph/data/explorer.py:                                    node, neighbor, weight
stellargraph/data/explorer.py:                                    node, neighbor, weight
stellargraph/data/explorer.py:                                node, neighbor, list(wts)
stellargraph/data/explorer.py:                neighbours = self.neighbors(node)
stellargraph/data/explorer.py:                        neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:                        neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:                        self.neighbors(cur_node) if cur_node is not None else []
stellargraph/data/edge_splitter.py:                            neighbours = list(nx.neighbors(self.g, v))
stellargraph/data/edge_splitter.py:                            neighbours = list(nx.neighbors(self.g, v))

vs

$ grep -ri --exclude-dir "__pycache__" "neighbour" stellargraph
stellargraph/core/graph.py:        Obtains the collection of neighbouring nodes connected
stellargraph/core/graph.py:            include_edge_weight (bool, default False): If True, each neighbour in the
stellargraph/core/graph.py:                via the provided edge types when collecting neighbours.
stellargraph/core/graph.py:            iterable: The neighbouring nodes.
stellargraph/core/graph.py:        Obtains the collection of neighbouring nodes with edges
stellargraph/core/graph.py:        neighbours are treated as both in-nodes and out-nodes.
stellargraph/core/graph.py:            include_edge_weight (bool, default False): If True, each neighbour in the
stellargraph/core/graph.py:                via the provided edge types when collecting neighbours.
stellargraph/core/graph.py:            iterable: The neighbouring in-nodes.
stellargraph/core/graph.py:        Obtains the collection of neighbouring nodes with edges
stellargraph/core/graph.py:        neighbours are treated as both in-nodes and out-nodes.
stellargraph/core/graph.py:            include_edge_weight (bool, default False): If True, each neighbour in the
stellargraph/core/graph.py:                via the provided edge types when collecting neighbours.
stellargraph/core/graph.py:            iterable: The neighbouring out-nodes.
stellargraph/core/graph_networkx.py:NeighbourWithWeight = namedtuple("NeighbourWithWeight", ["node", "weight"])
stellargraph/core/graph_networkx.py:        # 1. node ID of None (representing sampling for a missing neighbour)
stellargraph/core/graph_networkx.py:                return NeighbourWithWeight(
stellargraph/core/schema.py:        for neighbours up to n_hops away.
stellargraph/core/schema.py:            num_samples: A list of integers that are the number of neighbours
stellargraph/mapper/sequences.py:            batch_feats (list): Node features for nodes and neighbours sampled from a
stellargraph/mapper/sequences.py:            batch_feats (list): Node features for nodes and neighbours sampled from a
stellargraph/mapper/sequences.py:        sampler (UnsupersizedSampler):  An object that encapsulates the neighbourhood sampling of a graph.
stellargraph/mapper/sequences.py:            batch_feats<list>: Node features for nodes and neighbours sampled from a
stellargraph/mapper/sampled_node_generators.py:    DirectedBreadthFirstNeighbours,
stellargraph/mapper/sampled_node_generators.py:        Sample neighbours recursively from the head nodes, collect the features of the
stellargraph/mapper/sampled_node_generators.py:        # Resize features to (batch_size, n_neighbours, feature_size)
stellargraph/mapper/sampled_node_generators.py:        self.sampler = DirectedBreadthFirstNeighbours(
stellargraph/mapper/sampled_node_generators.py:        Sample neighbours recursively from the head nodes, collect the features of the
stellargraph/mapper/sampled_node_generators.py:        # Each 'slot' represents the list of nodes sampled from some neighbourhood, and will have a corresponding
stellargraph/mapper/sampled_node_generators.py:        Sample neighbours recursively from the head nodes, collect the features of the
stellargraph/mapper/sampled_node_generators.py:        # Resize features to (batch_size, n_neighbours, feature_size)
stellargraph/mapper/sampled_link_generators.py:        num_samples (list): List of number of neighbour node samples per GraphSAGE layer (hop) to take.
stellargraph/mapper/sampled_link_generators.py:        # The sampler used to generate random samples of neighbours
stellargraph/mapper/sampled_link_generators.py:        Sample neighbours recursively from the head nodes, collect the features of the
stellargraph/mapper/sampled_link_generators.py:        # Resize features to (batch_size, n_neighbours, feature_size)
stellargraph/mapper/sampled_link_generators.py:        num_samples (list): List of number of neighbour node samples per GraphSAGE layer (hop) to take.
stellargraph/mapper/sampled_link_generators.py:        # The sampler used to generate random samples of neighbours
stellargraph/mapper/sampled_link_generators.py:        # Resize features to (batch_size, n_neighbours, feature_size)
stellargraph/mapper/sampled_link_generators.py:        # Resize features to (batch_size, n_neighbours, feature_size)
stellargraph/mapper/sampled_link_generators.py:        Sample neighbours recursively from the head nodes, collect the features of the
stellargraph/layer/hinsage.py:            input_shape (list of list of int): Shape of input per neighbour type.
stellargraph/layer/hinsage.py:        # Weight matrix for each type of neighbour
stellargraph/layer/hinsage.py:        # If there are no neighbours (input_shape[x][2]) for an input
stellargraph/layer/hinsage.py:            - x[1+r]: tensors of neighbour features each of shape (n_batch, n_head, n_neighbour[r], n_feat[r])
stellargraph/layer/hinsage.py:            # The neighbour input tensors for relation r
stellargraph/layer/hinsage.py:            # If there are neighbours aggregate over them
stellargraph/layer/hinsage.py:        # Sum the contributions from all neighbour averages shape (n_batch, n_head, n_out_neigh)
stellargraph/layer/hinsage.py:        # Concatenate self + neighbour features, shape (n_batch, n_head, n_out)
stellargraph/layer/hinsage.py:        and 10 neighbours sampled at each layer using an existing :class:`StellarGraph` object `G`
stellargraph/layer/hinsage.py:        with hidden node sizes of 8 and 4 and 5 neighbours sampled at each layer::
stellargraph/layer/hinsage.py:        # Neighbourhood info per layer
stellargraph/layer/hinsage.py:                "n_samples, input_dim, multiplicity, and input_neighbour_tree must be specified."
stellargraph/layer/hinsage.py:        Function to evaluate the neighbourhood tree structure for every layer. The tree
stellargraph/layer/hinsage.py:            input_tree: Neighbourhood tree for the input batch
stellargraph/layer/hinsage.py:            List of neighbourhood trees
stellargraph/layer/hinsage.py:                # The shape of the head node is used for reshaping the neighbour inputs
stellargraph/layer/hinsage.py:                # Aplly dropout and reshape neighbours per node per layer
stellargraph/layer/hinsage.py:                # Apply aggregator to head node and reshaped neighbour nodes
stellargraph/layer/hinsage.py:        # Remove neighbourhood dimension from output tensors
stellargraph/layer/hinsage.py:        Returns the input shapes for the tensors of the supplied neighbourhood type tree
stellargraph/layer/hinsage.py:            the corresponding item in the neighbourhood type tree (self.subtree_schema)
stellargraph/layer/graphsage.py:                and neighbour features
stellargraph/layer/graphsage.py:        # If the neighbours are zero-dimensional for any of the shapes
stellargraph/layer/graphsage.py:                "There must be at least one input with a non-zero neighbourhood dimension"
stellargraph/layer/graphsage.py:        to sampled neighbourhoods, if required.
stellargraph/layer/graphsage.py:                and neighbour features
stellargraph/layer/graphsage.py:    def aggregate_neighbours(self, x_neigh, group_idx: int = 0):
stellargraph/layer/graphsage.py:        Override with a method to aggregate tensors over neighbourhood.
stellargraph/layer/graphsage.py:            x_neigh: The input tensor representing the sampled neighbour nodes.
stellargraph/layer/graphsage.py:            group_idx: Optional neighbourhood index used for multi-dimensional hops.
stellargraph/layer/graphsage.py:        # If a neighbourhood dimension exists for the group, aggregate over the neighbours
stellargraph/layer/graphsage.py:        Override with a method to aggregate tensors over the neighbourhood for each group.
stellargraph/layer/graphsage.py:            x_neigh (tf.Tensor): : The input tensor representing the sampled neighbour nodes.
stellargraph/layer/graphsage.py:        Mean aggregator for tensors over the neighbourhood for each group.
stellargraph/layer/graphsage.py:            x_group (tf.Tensor): : The input tensor representing the sampled neighbour nodes.
stellargraph/layer/graphsage.py:        Aggregates the group tensors by max-pooling of neighbours
stellargraph/layer/graphsage.py:            x_group (tf.Tensor): : The input tensor representing the sampled neighbour nodes.
stellargraph/layer/graphsage.py:            # Pass neighbour features through a dense layer with w_pool, b_pool
stellargraph/layer/graphsage.py:            # Take max of this tensor over neighbour dimension
stellargraph/layer/graphsage.py:        Aggregates the group tensors by mean-pooling of neighbours
stellargraph/layer/graphsage.py:            x_group (tf.Tensor): : The input tensor representing the sampled neighbour nodes.
stellargraph/layer/graphsage.py:            # Pass neighbour features through a dense layer with w_pool, b_pool
stellargraph/layer/graphsage.py:            # Take max of this tensor over neighbour dimension
stellargraph/layer/graphsage.py:                and neighbour features
stellargraph/layer/graphsage.py:        # If the neighbours are zero-dimensional for any of the shapes
stellargraph/layer/graphsage.py:          inputs (List[Tensor]): Tensors giving self and neighbour features
stellargraph/layer/graphsage.py:                x[k>0]: group Tensors for neighbourhood (batch_size, head size, neighbours, feature_size)
stellargraph/layer/graphsage.py:        # If a neighbourhood dimension exists for the group, aggregate over the neighbours
stellargraph/layer/graphsage.py:            # Group transform for self & neighbours
stellargraph/layer/graphsage.py:            # Concatenate self vector to neighbour vectors
stellargraph/layer/graphsage.py:            # Add self and neighbour attn and apply activation
stellargraph/layer/graphsage.py:            # Attn coefficients, softmax over the neighbours
stellargraph/layer/graphsage.py:            # Multiply attn coefficients by neighbours (and self) and aggregate
stellargraph/layer/graphsage.py:    Different neighbour node aggregators can also be specified with the ``aggregator``
stellargraph/layer/graphsage.py:        and 10 neighbours sampled at each layer using an existing :class:`StellarGraph` object `G`
stellargraph/layer/graphsage.py:        # Compute size of each sampled neighbourhood
stellargraph/layer/graphsage.py:        self._compute_neighbourhood_sizes()
stellargraph/layer/graphsage.py:                "Mismatched lengths: neighbourhood sample sizes {} versus layer sizes {}".format(
stellargraph/layer/graphsage.py:                "Mismatched lengths: neighbourhood sample sizes {} versus layer sizes {}".format(
stellargraph/layer/graphsage.py:    def _compute_neighbourhood_sizes(self):
stellargraph/layer/graphsage.py:        sampled at each neighbourhood.
stellargraph/layer/graphsage.py:        Each hop samples from the neighbours of the previous nodes.
stellargraph/layer/graphsage.py:        self.neighbourhood_sizes = [size_at(i) for i in range(self.max_hops + 1)]
stellargraph/layer/graphsage.py:                # Reshape neighbours per node per layer
stellargraph/layer/graphsage.py:                # Apply aggregator to head node and neighbour nodes
stellargraph/layer/graphsage.py:        # Remove neighbourhood dimension from output tensors of the stack
stellargraph/layer/graphsage.py:        # Create tensor inputs for neighbourhood sampling
stellargraph/layer/graphsage.py:            Input(shape=(s, self.input_feature_size)) for s in self.neighbourhood_sizes
stellargraph/layer/graphsage.py:    Different neighbour node aggregators can also be specified with the ``aggregator``
stellargraph/layer/graphsage.py:    def _compute_neighbourhood_sizes(self):
stellargraph/layer/graphsage.py:        sampled at each neighbourhood.
stellargraph/layer/graphsage.py:        This gives rise to a binary tree of directed neighbourhoods.
stellargraph/layer/graphsage.py:        self.neighbourhood_sizes = [1] + [
stellargraph/layer/graphsage.py:        def aggregate_neighbours(tree: List, stage: int):
stellargraph/layer/graphsage.py:                    self.neighbourhood_sizes[child_slot] // num_head_nodes
stellargraph/layer/graphsage.py:                    self.neighbourhood_sizes[child_slot] // num_head_nodes
stellargraph/layer/graphsage.py:                # aggregate neighbourhoods
stellargraph/layer/graphsage.py:            stage_tree = aggregate_neighbours(stage_tree, stage)
stellargraph/layer/graphsage.py:        # Remove neighbourhood dimension from output tensors of the stack
stellargraph/data/explorer.py:    "DirectedBreadthFirstNeighbours",
stellargraph/data/explorer.py:            # Create a dict of adjacency lists per edge type, for faster neighbour sampling from graph in SampledHeteroBFS:
stellargraph/data/explorer.py:    # For neighbourhood sampling
stellargraph/data/explorer.py:        err_msg = "The neighbourhood size must be a list of non-negative integers."
stellargraph/data/explorer.py:            self._raise_error("The neighbourhood size list should not be empty.")
stellargraph/data/explorer.py:            neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:            if not neighbours:
stellargraph/data/explorer.py:                # has neighbours, so pick one to walk to
stellargraph/data/explorer.py:                current_node = rs.choice(neighbours)
stellargraph/data/explorer.py:                neighbours = self.neighbors(node)
stellargraph/data/explorer.py:                previous_node_neighbours = neighbours
stellargraph/data/explorer.py:                    elif nn in previous_node_neighbours:  # d_tx = 1
stellargraph/data/explorer.py:                if neighbours:
stellargraph/data/explorer.py:                    current_node = rs.choice(neighbours)
stellargraph/data/explorer.py:                        neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:                        if not neighbours:
stellargraph/data/explorer.py:                        # select one of the neighbours using the
stellargraph/data/explorer.py:                                for nn in neighbours
stellargraph/data/explorer.py:                        previous_node_neighbours = neighbours
stellargraph/data/explorer.py:                        current_node = neighbours[choice]
stellargraph/data/explorer.py:                        neighbours = self.neighbors(current_node)
stellargraph/data/explorer.py:                        neighbours = [
stellargraph/data/explorer.py:                            for n_node in neighbours
stellargraph/data/explorer.py:                        if len(neighbours) == 0:
stellargraph/data/explorer.py:                            # if no neighbours of the required type as dictated by the metapath exist, then stop.
stellargraph/data/explorer.py:                        # select one of the neighbours uniformly at random
stellargraph/data/explorer.py:                            neighbours
stellargraph/data/explorer.py:            n_size: <list> The number of neighbouring nodes to expand at each depth of the walk. Sampling of
stellargraph/data/explorer.py:            neighbours with replacement is always used regardless of the node degree and number of neighbours
stellargraph/data/explorer.py:                q = deque()  # the queue of neighbours
stellargraph/data/explorer.py:                    depth = cur_depth + 1  # the depth of the neighbouring nodes
stellargraph/data/explorer.py:                    neighbours = (
stellargraph/data/explorer.py:                    if len(neighbours) == 0:
stellargraph/data/explorer.py:                        neighbours = [None] * n_size[cur_depth]
stellargraph/data/explorer.py:                        neighbours = [
stellargraph/data/explorer.py:                            rs.choice(neighbours) for _ in range(n_size[cur_depth])
stellargraph/data/explorer.py:                    q.extend((sampled_node, depth) for sampled_node in neighbours)
stellargraph/data/explorer.py:            n_size: <list> The number of neighbouring nodes to expand at each depth of the walk. Sampling of
stellargraph/data/explorer.py:            neighbours with replacement is always used regardless of the node degree and number of neighbours
stellargraph/data/explorer.py:                q = list()  # the queue of neighbours
stellargraph/data/explorer.py:                    depth = depth + 1  # the depth of the neighbouring nodes
stellargraph/data/explorer.py:                            # If there are no neighbours of this type then we return None
stellargraph/data/explorer.py:                            # In case of no neighbours of the current node for et, neigh_et == [None],
stellargraph/data/explorer.py:class DirectedBreadthFirstNeighbours(GraphWalk):
stellargraph/data/explorer.py:            A list of multi-hop neighbourhood samples. Each sample expresses multiple undirected walks, but the in-node
stellargraph/data/explorer.py:            neighbours and out-node neighbours are sampled separately. Each sample has the format:
stellargraph/data/explorer.py:        self._check_neighbourhood_sizes(in_size, out_size)
stellargraph/data/explorer.py:                q = list()  # the queue of neighbours
stellargraph/data/explorer.py:                    depth = cur_depth + 1  # the depth of the neighbouring nodes
stellargraph/data/explorer.py:                    neighbours = self._sample_neighbours(
stellargraph/data/explorer.py:                        [(sampled_node, depth, slot) for sampled_node in neighbours]
stellargraph/data/explorer.py:                    neighbours = self._sample_neighbours(
stellargraph/data/explorer.py:                        [(sampled_node, depth, slot) for sampled_node in neighbours]
stellargraph/data/explorer.py:                # finished multi-hop neighbourhood sampling
stellargraph/data/explorer.py:    def _sample_neighbours(self, rs, node, idx, size):
stellargraph/data/explorer.py:        from the directed neighbourhood of the given starting node.
stellargraph/data/explorer.py:        If the neighbourhood is empty, then the result will contain
stellargraph/data/explorer.py:                neighbourhood to be sampled: 0 => in-nodes;
stellargraph/data/explorer.py:            The fixed-length list of neighbouring nodes (or None values
stellargraph/data/explorer.py:            if the neighbourhood is empty).
stellargraph/data/explorer.py:            # Non-node, e.g. previously sampled from empty neighbourhood
stellargraph/data/explorer.py:        neighbours = list(
stellargraph/data/explorer.py:        if len(neighbours) == 0:
stellargraph/data/explorer.py:            # Sampling from empty neighbourhood
stellargraph/data/explorer.py:        return [rs.choice(neighbours) for _ in range(size)]
stellargraph/data/explorer.py:    def _check_neighbourhood_sizes(self, in_size, out_size):
stellargraph/data/explorer.py:            n_size: <list> The number of neighbouring nodes to expand at each depth of the walk.
stellargraph/data/explorer.py:                "The number of hops for the in and out neighbourhoods must be the same."
stellargraph/data/epgm.py:def node_neighbours(v, edges):
stellargraph/data/epgm.py:    """Returns a list of neighbours of vertex v"""
stellargraph/data/epgm.py:def node_neighbours_extended(v, nodes, edges):
stellargraph/data/epgm.py:    """Returns a list of neighbours of vertex v"""
stellargraph/data/epgm.py:            # create a graph as dict of lists in the format (node_id: [neighbour nodes])
stellargraph/data/epgm.py:                    # _ = [pool.apply_async(partial(node_neighbours, edges=edges), args=(v,),
stellargraph/data/epgm.py:                        partial(node_neighbours, edges=edges), nodes, chunksize
stellargraph/data/epgm.py:                        pool.map(partial(node_neighbours, edges=edges), nodes)
stellargraph/data/epgm.py:    #         data = data = partial(node_neighbours_extended, nodes=nodes, edges=edges)(v) # node_neighbours_extended(v, nodes, edges)
stellargraph/data/edge_splitter.py:             chosen to be from the former's local neighbourhood.
stellargraph/data/edge_splitter.py:        neighbourhood of randomly (uniformly) sampled source nodes at distances defined by the probabilities in probs.
stellargraph/data/edge_splitter.py:                        # target node for a negative edge sample. Otherwise add its neighbours to the stack, only
stellargraph/data/edge_splitter.py:                            neighbours = list(nx.neighbors(self.g, v))
stellargraph/data/edge_splitter.py:                            self._random.shuffle(neighbours)
stellargraph/data/edge_splitter.py:                            neighbours = [(k, dv + 1) for k in neighbours]
stellargraph/data/edge_splitter.py:                            nodes_stack.extend(neighbours)
stellargraph/data/edge_splitter.py:        neighbourhood of randomly (uniformly) sampled source nodes at distances defined by the probabilities in probs.
stellargraph/data/edge_splitter.py:                        # target node for a negative edge sample. Otherwise add its neighbours to the stack, only
stellargraph/data/edge_splitter.py:                            neighbours = list(nx.neighbors(self.g, v))
stellargraph/data/edge_splitter.py:                            self._random.shuffle(neighbours)
stellargraph/data/edge_splitter.py:                            neighbours = [(k, dv + 1) for k in neighbours]
stellargraph/data/edge_splitter.py:                            nodes_stack.extend(neighbours)

User Story

As a data scientist

I want to use Stellargraph methods that have a consistent way of spelling neighbour/neighbor

So that I can more easily remember them and encounter less errors from getting confused between the two.

Done Checklist

kjun9 commented 4 years ago

Or why don't we have both

huonw commented 4 years ago

Vague update: With #1368 and #1583, we now spellcheck our documentation as en-AU:

https://github.com/stellargraph/stellargraph/blob/292ac3d96149788275b95842c272ea605e9588a4/docs/conf.py#L232-L235

This flags instances of various US spellings in the text, that are whitelisted:

https://github.com/stellargraph/stellargraph/blob/292ac3d96149788275b95842c272ea605e9588a4/docs/spelling_wordlist.txt#L219-L223

If we were to decide to switch to one or the other, we should switch the language and/or remove the whitelisting (as appropriate).

However, this doesn't/won't flag the spelling in functions and classes in the actual API, only in the description.