Browse Source

feat: imlpement generic Adjuster class

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
main
Rob Hallam 1 month ago
parent
commit
e46da363e0
1 changed files with 25 additions and 0 deletions
  1. +25
    -0
      pipeline/adjusters.py

+ 25
- 0
pipeline/adjusters.py View File

@@ -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."""

Loading…
Cancel
Save