sketchgraphs.pipeline.graph_model.quantization.EntityFeatureMapping

class sketchgraphs.pipeline.graph_model.quantization.EntityFeatureMapping(bin_centers_by_target=None)

Helper class for extracting sparse features from entities.

In addition to features shared by all entity types (e.g. isConstruction), many entity types have their own features. In order to process them appropriately in batched fashion, they must be extracted into a set of sparse features.

__init__(bin_centers_by_target=None)

Initialize a new mapping from the given bin definitions.

Parameters

bin_centers_by_target (dict) – A dictionary specifying bin center locations for each target type (i.e. entity type)

features_from_index(index, target)

Obtains categorical features from the given indices.

numerical_features(ops, target)numpy.ndarray

Produces a dense array of numerical features.

The operations in the ops array must all match the given target type.

sparse_features_for_target(node_ops, target)

Produces sparse features for given target type.

This function produces a sparse feature batch for the given sequence of ops and target type. The sparse features are emitted for each node in node_ops which matches the specified target type.