From e46da363e0e807bf493fbb9edd3a47bf4f6c72f9 Mon Sep 17 00:00:00 2001 From: Rob Hallam <0504004h@student.gla.ac.uk> Date: Tue, 3 Sep 2024 12:10:22 +0100 Subject: [PATCH] feat: imlpement generic Adjuster class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adjusters will be used to modify a list of Features. This could either be: - to modify the overall set (eg to target a time) - to modify individual Features The most important Adjuster will be one that targets an overall time, eg: "modify this list of Features such that their times add up to 1 minute (either ± a % or a hard limit)" @see: feature_extractors.py::FeatureExtractor --- pipeline/adjusters.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 pipeline/adjusters.py diff --git a/pipeline/adjusters.py b/pipeline/adjusters.py new file mode 100644 index 0000000..cb97a7a --- /dev/null +++ b/pipeline/adjusters.py @@ -0,0 +1,25 @@ +"""adjusters.py -- adjust the gathered Features + +This is usually done to either modify to reduce the Features in some way. + +For example: + + - TargetTimeAdjuster: drop Features until the target time is reached + - FeatureCountAdjuster: drop Features until the target number of Features is reached + +TODO: Consider eg a generic PredicateAdjuster -- supply a predicate/lambda that will be used to determine whether to keep a Feature or not. +""" + +class Adjuster(): + """Generic Adjuster class. Expects a list of Features and returns a list of Features.""" + + def __init__(self, features: list=[]): + """Initialize the Adjuster with Features. + + NOTE: an empty feature list is permitted, since a FeatureExtractor may not produce features. Adjusters subclassing should be aware of this. + """ + self.features = features + + + def adjust(self): + """Adjust the Features. Override this method in subclasses."""