Feature extraction

There are feature extractors available for three kinds of features: monophonic, polyphonic and generic.

digraph "Feature extraction structure" { generic [label="Generic features"] mono [label="Monophonic features"]; poly [label="Polyphonic features"]; generic -> mono; generic -> poly; }

All feature extractor classes and function can be found in the beatsearch.feature_extraction package. Features are extracted with implementations of the FeatureExtractor interface.

class beatsearch.feature_extraction.FeatureExtractor
construct_full_auxiliary_tree(obj, root_auxiliary=None)

Constructs the complete feature auxiliary tree containing all auxiliaries needed to compute this feature for the given object. The following statements are true for the tree:

  • the root node represents this feature extractor (highest abstraction level)
  • the children of a node are its direct feature auxiliaries
  • leaf nodes represent auxiliaries with an independent extractor (auxiliaries on lowest abstraction level)
Returns:the root node of the tree
get_auxiliary_extractors(extractor_type=None)

Returns an iterator over this extractor’s auxiliary extractors

Returns an iterator over the auxiliary feature extractors registered with beatsearch.feature_extraction. FeatureExtractor.register_auxiliary_extractor(). When given an extractor type, only the extractors returning isinstance(extr, extractor_type) will be returned.

Parameters:extractor_type – if given, only extractors of this exact type will be returned
Returns:iterator over registered auxiliary feature extractors
is_independent()

Returns whether this feature extractor is independent. A feature extractor is considered to be independent if it has not registered any auxiliary feature extractors and therefore doesn’t depend on any other extractors.

Return type:bool
Returns:True if this extractor is independent
process(obj, pre_computed_auxiliary_features=())

Computes and returns a feature

Computes a feature of the given object and returns it.

Parameters:
  • obj – object of which to compute the feature
  • pre_computed_auxiliary_features – pre-computed auxiliary features as a dictionary holding the pre-computed auxiliary features by beatsearch.feature_extraction. FeatureExtractorAuxiliaryFeature objects
Returns:

the feature value

register_auxiliary_extractor(extractor)

Registers the given feature extractor as an auxiliary feature extractor

Parameters:

extractor – auxiliary feature extractor

Returns:

given feature extractor

Raises:
  • TypeError – if given extractor is not a FeatureExtractor object
  • ValueError – if given feature extractor has already been registered

Generic rhythm features

Generic rhythm features are based on generic rhythm properties and apply to both monophonic and polyphonic rhythms. Feature extractors for these type of features are implemented as RhythmFeatureExtractor subclasses.

There hasn’t yet been implemented any generic rhythm feature extractor.