pub struct NDArrayCollector<F> { /* private fields */ }Expand description
NDArrayCollector is a Collector which transforms frame-based replay
data into a 2-dimensional array of type ndarray::Array2, where each
element is of a specified floating point type.
It’s initialized with collections of FeatureAdder instances which
extract global, player independent features for each frame, and
PlayerFeatureAdder, which add player specific features for each frame.
It’s main entrypoint is Self::get_meta_and_ndarray, which provides
ndarray::Array2 along with column headers and replay metadata.
Implementations§
Source§impl<F> NDArrayCollector<F>
impl<F> NDArrayCollector<F>
Sourcepub fn new(
feature_adders: FeatureAdders<F>,
player_feature_adders: PlayerFeatureAdders<F>,
) -> Self
pub fn new( feature_adders: FeatureAdders<F>, player_feature_adders: PlayerFeatureAdders<F>, ) -> Self
Creates a new instance of NDArrayCollector.
§Arguments
-
feature_adders- A vector ofArc<dyn FeatureAdder<F>>, each implementing theFeatureAddertrait. These are used to add global features to the replay data. -
player_feature_adders- A vector ofArc<dyn PlayerFeatureAdder<F>>, each implementing thePlayerFeatureAddertrait. These are used to add player-specific features to the replay data.
§Returns
A new NDArrayCollector instance. This instance is initialized with
empty data, no replay metadata and zero frames added.
Sourcepub fn get_column_headers(&self) -> NDArrayColumnHeaders
pub fn get_column_headers(&self) -> NDArrayColumnHeaders
Returns the column headers of the 2-dimensional array produced by the
NDArrayCollector.
§Returns
An instance of NDArrayColumnHeaders representing the column headers
in the collected data.
Sourcepub fn get_ndarray(self) -> SubtrActorResult<Array2<F>>
pub fn get_ndarray(self) -> SubtrActorResult<Array2<F>>
This function consumes the NDArrayCollector instance and returns the
data collected as an ndarray::Array2.
§Returns
A SubtrActorResult containing the collected data as an
ndarray::Array2.
This method is a shorthand for calling Self::get_meta_and_ndarray
and discarding the replay metadata and headers.
Sourcepub fn get_meta_and_ndarray(
self,
) -> SubtrActorResult<(ReplayMetaWithHeaders, Array2<F>)>
pub fn get_meta_and_ndarray( self, ) -> SubtrActorResult<(ReplayMetaWithHeaders, Array2<F>)>
Consumes the NDArrayCollector and returns the collected features as a
2D ndarray, along with replay metadata and headers.
§Returns
A SubtrActorResult containing a tuple:
ReplayMetaWithHeaders: The replay metadata along with the headers for each column in the ndarray.ndarray::Array2<F>: The collected features as a 2D ndarray.
Sourcepub fn process_and_get_meta_and_headers(
&mut self,
replay: &Replay,
) -> SubtrActorResult<ReplayMetaWithHeaders>
pub fn process_and_get_meta_and_headers( &mut self, replay: &Replay, ) -> SubtrActorResult<ReplayMetaWithHeaders>
Processes a boxcars::Replay and returns its metadata along with column headers.
This method first processes the replay using a ReplayProcessor. It
then updates the replay_meta field if it’s not already set, and
returns a clone of the replay_meta field along with column headers of
the data.
§Arguments
replay: A reference to theboxcars::Replayto process.
§Returns
A SubtrActorResult containing a ReplayMetaWithHeaders that
includes the metadata of the replay and column headers.