lookout.style.format.features
¶
Features definition.
Module Contents¶
-
lookout.style.format.features.
FEATURES_NUMPY_TYPE
¶
-
lookout.style.format.features.
FEATURES_MIN
¶
-
lookout.style.format.features.
FEATURES_MAX
¶
-
class
lookout.style.format.features.
FeatureGroup
¶ Bases:
enum.Enum
Feature groups.
Each feature belongs to one and only one of these classes.
-
node
= 1¶
-
left
= 2¶
-
right
= 3¶
-
parents
= 4¶
-
format
(self, value)¶ Represent the feature group for user interfaces. The trailing dot is appended as needed.
Parameters: value – The feature group parameter. E.g., the index of the node for “left” and “right”. Returns: pretty-printed string, the trailing dot is appended as needed.
-
__lt__
(self, other:'FeatureGroup')¶ Compare two groups: am I less than the other.
-
-
lookout.style.format.features.
FEATURE_GROUP_TYPES
¶
-
class
lookout.style.format.features.
FeatureId
¶ Bases:
enum.Enum
Feature identifiers.
-
diff_col
= 0¶
-
diff_line
= 1¶
-
diff_offset
= 2¶
-
index_internal_type
= 3¶
-
index_label
= 4¶
-
index_reserved
= 5¶
-
internal_type
= 6¶
-
label
= 7¶
-
reserved
= 8¶
-
roles
= 9¶
-
length
= 10¶
-
start_col
= 11¶
-
start_line
= 12¶
-
__lt__
(self, other:'FeatureId')¶ Compare two identifiers: am I less than the other.
This does not make much apart from ordering enums.
-
-
lookout.style.format.features.
TV
¶
-
lookout.style.format.features.
Layout
¶
-
lookout.style.format.features.
MutableLayout
¶
-
lookout.style.format.features.
FeatureLayout
¶
-
lookout.style.format.features.
MutableFeatureLayout
¶
-
lookout.style.format.features.
TVFeature
¶
-
lookout.style.format.features.
TVAnyNode
¶
-
class
lookout.style.format.features.
Feature
(*, language:str, labels_to_class_sequences:Sequence[Tuple[int, ...]], selected_indices:Optional[Sequence[int]]=None, **kwargs)¶ Base type for features.
-
id
¶
-
selected_indices
¶ Return the sequence of selected indices.
-
selected_indices_index
¶ Return the set of selected indices.
-
selected_names
¶ Return the names of the features this Feature computes (after feature selection).
-
names
¶ Return the names of the features this Feature computes (before feature selection).
-
selected_names_index
¶ Return the index of a name to its position (after feature selection).
-
__call__
(self, neighbours:Layout[Sequence[Optional[AnyNode]]])¶ Compute the relevant values for this feature.
This method only creates the resulting array and delegates the filling to subclasses.
Parameters: neighbours – Neighbouring nodes to the current sample. Returns: Numpy array containing the feature values. 2-dimensional.
-
static
_clip_int
(integer:int)¶
-
_compute
(self, neighbours:Layout[Sequence[Optional[AnyNode]]])¶
-
-
class
lookout.style.format.features.
MultipleValuesFeature
¶ Bases:
lookout.style.format.features.Feature
Base type for features that produce multiple values.
-
class
lookout.style.format.features.
CategoricalFeature
¶ Bases:
lookout.style.format.features.MultipleValuesFeature
Base type for features that have a one hot encoded value.
-
class
lookout.style.format.features.
BagFeature
¶ Bases:
lookout.style.format.features.MultipleValuesFeature
Base type for features that have multiple values.
-
class
lookout.style.format.features.
OrdinalFeature
(**kwargs)¶ Bases:
lookout.style.format.features.Feature
Base type for ordinal features.
-
class
lookout.style.format.features.
NeighbourFeature
(neighbour_group:FeatureGroup, neighbour_index:int, **kwargs)¶ Bases:
lookout.style.format.features.Feature
,Generic[TVAnyNode]
Base type for features that focus on a node among the neighbours of the current node.
-
_convert_nodes
(self, nodes:Sequence[Optional[AnyNode]])¶
-
_check_whitelist
(self)¶
-
-
class
lookout.style.format.features.
ComparisonFeature
¶ Bases:
NeighbourFeature[TVAnyNode]
Base type for features that compare the current node to one of its neighbours.
-
_compute
(self, neighbours:Layout[Sequence[Optional[AnyNode]]])¶ Focus on the relevant nodes and compute the feature values.
-
_focused_compute
(self, nodes:Sequence[VirtualNode], neighbours:Sequence[Optional[TVAnyNode]])¶ Compute the feature values.
-
_compute_row
(self, node:VirtualNode, neighbour:TVAnyNode)¶ Compute the feature value(s) for a given node and its neighbour.
-
-
class
lookout.style.format.features.
VirtualNodeComparisonFeature
¶ Bases:
ComparisonFeature[VirtualNode]
Base type for Feature-s that compare the current virtual node to another virtual node.
-
target_type
¶
-
-
class
lookout.style.format.features.
NodeFeature
¶ Bases:
NeighbourFeature[TVAnyNode]
Base type for features that compute a property of a single node.
-
_compute
(self, neighbours:Layout[Sequence[Optional[AnyNode]]])¶ Focus on the relevant nodes and compute the feature values.
-
_focused_compute
(self, nodes:Sequence[Optional[TVAnyNode]])¶ Compute the feature values.
-
_compute_row
(self, node:TVAnyNode)¶ Compute the feature value(s) for a given node.
-
-
class
lookout.style.format.features.
VirtualNodeFeature
¶ Bases:
NodeFeature[VirtualNode]
Base type for Feature-s computed on a virtual node per sample.
-
target_type
¶
-
-
class
lookout.style.format.features.
BblfshNodeFeature
¶ Bases:
NodeFeature[bblfsh.Node]
Base type for Feature-s computed on a bblfsh node per sample.
-
target_type
¶
-
-
lookout.style.format.features.
FEATURE_CLASSES
¶
-
lookout.style.format.features.
register_feature
(cls:Type[TVFeature])¶ Register features in the __features__ module attribute.
-
class
lookout.style.format.features.
_FeatureDiffCol
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeComparisonFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode, neighbour:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureDiffLine
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeComparisonFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode, neighbour:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureDiffOffset
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeComparisonFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode, neighbour:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureIndexInternalType
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.BblfshNodeFeature
-
id
¶
-
_compute_row
(self, node:bblfsh.Node)¶
-
-
class
lookout.style.format.features.
_FeatureIndexLabel
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureIndexReserved
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureInternalType
(**kwargs)¶ Bases:
lookout.style.format.features.CategoricalFeature
,lookout.style.format.features.BblfshNodeFeature
-
id
¶
-
_compute_row
(self, node:bblfsh.Node)¶
-
-
class
lookout.style.format.features.
_FeatureLabel
(**kwargs)¶ Bases:
lookout.style.format.features.BagFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureReserved
(**kwargs)¶ Bases:
lookout.style.format.features.CategoricalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureRoles
(**kwargs)¶ Bases:
lookout.style.format.features.BagFeature
,lookout.style.format.features.BblfshNodeFeature
-
id
¶
-
_compute_row
(self, node:bblfsh.Node)¶
-
-
class
lookout.style.format.features.
_FeatureLength
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureStartCol
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode)¶
-
-
class
lookout.style.format.features.
_FeatureStartLine
¶ Bases:
lookout.style.format.features.OrdinalFeature
,lookout.style.format.features.VirtualNodeFeature
-
id
¶
-
feature_groups_whitelist
¶
-
_compute_row
(self, node:VirtualNode)¶
-