How to Add New Features or Results¶
Features, Results and Autoencoders all implement the ParameterizedInterface, making it very simple to add new types.
Adding a New Feature¶
1. Define a New Feature Class¶
To add a new feature, first implement your new feature as a new class in python/src/backend/features.py that implements Feature. When writing this class, be sure to implement the necessary abstract methods declared in Feature. These methods include:
__init__(self): Initialize your Feature with any instance variable settings required. (Make sure to callsuper().__init__()as well)process(self, data): Compute the Feature given thedataargument in the form of a 2d matrix of filtered raw data, where the first dimension is time and the second dimension is channels. The length ofdatain the first dimension is defined inglobals.raw_settings.buffer_size.
2. Create a New Feature Type¶
In python/src/common/enums.py, add a new enum name for your new Feature to the FeatureType Enum. The name of this new type should be short and sweet as it will be used in the code, and the value should be readable since it will be displayed to the user.
4. Update your new class¶
At the top of your new class, define the class attribute _type as the new FeatureType enum name that you created.
Now you are done! If your new Feature class is implemented correctly, it will show up in the GUI and CLI, and the user will be use it to compute features from training and testing.
*Remember to update the class attribute excluded_params on your new Feature class to declare the names of any instance variables in your class that shouldn’t be saved or displayed to the user. See https://github.com/DamonGeorge/Parameterized for more information.
Adding a New Result¶
Following the same steps described above for adding a new Feature, except this time add a new class in python/src/backend/results.py that implements the Result class and add a new Enum type to the ResultType enum in python/src/common/enums.py. Your new Result class should define the good_threshold class attribute which defines the a threshold on your result that defines a ‘Good’ result. Your new class should also define the following methods:
__init__(self): Initialize your Result with any instance variable settings required. (Make sure to callsuper().__init__()as well)calc(self, data, timestep): Compute the Result at the giventimestepof thedataobject, which is of the typeData, containing the decoder output indata.x_hatand the desired decoder output indata.x_d. This should return the result.compare(cls, res1, res2=None): This@staticmethodfunction compares two results of your type to see which is better.def print(cls, printer=print, data=None): This@classmethodfunction is optional and defines how to print your result to the user in the console.