Feature extraction¶
There are feature extractors available for three kinds of features: monophonic, polyphonic and generic.
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: boolReturns: 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. FeatureExtractorAuxiliaryFeatureobjects
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.
Monophonic rhythm features¶
Monophonic rhythm features are based on monophonic rhythm properties and are implemented as
MonophonicRhythmFeatureExtractor subclasses. For example, to compute the onset density of a rhythm:
from beatsearch.rhythm import MonophonicRhythm
from beatsearch.feature_extraction import OnsetDensity
rhythm = MonophonicRhythm.create.from_string("x--x--x---x-x---")
onset_density = OnsetDensity().process(rhythm)
Implementations
beatsearch.feature_extraction.BinaryOnsetVectorbeatsearch.feature_extraction.NoteVectorbeatsearch.feature_extraction.BinarySchillingerChainbeatsearch.feature_extraction.ChronotonicChainbeatsearch.feature_extraction.OnsetDensitybeatsearch.feature_extraction.OnsetPositionVectorbeatsearch.feature_extraction.MonophonicOnsetLikelihoodVectorbeatsearch.feature_extraction.MonophonicVariabilityVectorbeatsearch.feature_extraction.MonophonicSyncopationVectorbeatsearch.feature_extraction.SyncopatedOnsetRatiobeatsearch.feature_extraction.MeanSyncopationStrengthbeatsearch.feature_extraction.MonophonicMetricalTensionVectorbeatsearch.feature_extraction.MonophonicMetricalTensionMagnitudebeatsearch.feature_extraction.IOIVectorbeatsearch.feature_extraction.IOIDifferenceVectorbeatsearch.feature_extraction.IOIHistogram
Polyphonic rhythm features¶
Polyphonic rhythm features are based on polyphonic rhythm properties and are implemented as
PolyphonicRhythmFeatureExtractor subclasses.
Implementations