macro_rules! build_global_feature_adder {
    ($struct_name:ident, $prop_getter:expr, $( $column_names:expr ),* $(,)?) => { ... };
}
Expand description

This macro creates a global FeatureAdder struct and implements the necessary traits to add the calculated features to the data matrix. The macro exports a struct with the same name as passed in the parameter. The number of column names and the length of the feature array returned by $prop_getter are checked at compile time to ensure they match, in line with the LengthCheckedFeatureAdder trait. The output struct also provides an implementation of the FeatureAdder trait via the impl_feature_adder! macro, allowing it to be used in contexts where a FeatureAdder object is required.

Parameters

  • $struct_name: The name of the struct to be created.
  • $prop_getter: The function or closure used to calculate the features.
  • $( $column_names:expr ),*: A comma-separated list of column names as strings.

Example

use subtr_actor::*;

build_global_feature_adder!(
    SecondsRemainingExample,
    |_, processor: &ReplayProcessor, _frame, _index, _current_time| {
        convert_all_floats!(processor.get_seconds_remaining()?.clone() as f32)
    },
    "seconds remaining"
);

This will create a struct named SecondsRemaining and implement necessary traits to calculate features using the provided closure. The feature will be added under the column name “seconds remaining”. Note, however, that it is possible to add more than one feature with each feature adder