Dynamic Feature Selection and export settings #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The following changes have been made:
Summary of Changes
Dynamic selection of node features
The goal of this enhancement is to provide users with the flexibility to configure which features should be included in the nodes of the
GraphConverter
Originally, the
GraphConverter
’s node features were static and pre-defined like this:With this update, users can dynamically select features when instantiating the
GraphConverter()
. In the future, we also would like to implement aadd_my_custom_feature()
functionalityTo facilitate this functionality, we introduced a
NodeFeatureSet
class. This class enables users to dynamically add node features to the feature set and customize how it is calculated. The feature set is then populated with a feature function which includes the name, the function and the parameters required in the function. The code is present inunravel/utils/features/node_feature_set.py
The function defined above in the
NodeFeatureSet
allows the user to add the x-coordinate of the ball and player to node features. Ifnormed=True
, it normalized the x-coordinate. This dynamic configuration allows users to define the specific functions employed to calculate node features at the time of instantiating theGraphConverter
. Similarly all the node feature calculations were captured using:Export settings feature
Introduced a function
export_settings()
inGraphConverter
class which stores the version of unravel, node and edge features used along with graph settings into a json filesettings.json
in the rootAlso created a function
to_dict()
ingraph_settings.py
to serialize the object into a JSON subscriptable format. The following is a sample JSON file that was exported:Verifying correctness
I conducted a sanity check by utilizing the dynamic feature selection introduced in the recent update to reproduce the output of the previous static configuration.
X
that is returned fromnode_features
from the original and updated version into a txt file and ran a script to verify if the text files are identical.e
that is returned fromedge_features
from the original and updated versions and the script verifies that they are identical.This means that this update has ensured correctness of output