瀏覽代碼

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 月之前
父節點
當前提交
e46da363e0
共有 1 個檔案被更改,包括 25 行新增0 行删除
  1. +25
    -0
      pipeline/adjusters.py

+ 25
- 0
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."""

Loading…
取消
儲存