Enabled flexible feature selection and config portability#24
Enabled flexible feature selection and config portability#24MihirT906 wants to merge 46 commits intoUnravelSports:mainfrom
Conversation
|
Hi @MihirT906, apologies for the long reply. I think this is really starting to look good, but here are some things I think we need to change to make this as seamless as possible. From JSON converter = SoccerGraphConverterPolars(
dataset=kloppy_polars_dataset,
from_json="tests/files/default_feature_specs.json"
)To make this work properly we should borrow: This would then allow us to do something like this, although we probably need to verify that from_json is indeed a FileLike object. if self.from_json is not None:
with open_as_file(self.from_json) as json_config:
self.load_from_json(json.load(json_config))When we now change The Validating Feature Specs def _validate_feature_specs_general(self):
if self.feature_specs is None or not self.feature_specs:
self.feature_specs = DEFAULT_SOCCER_FEATURE_SPECS
.... etc
if (
self.feature_specs["node_features"] == {}
and self.feature_specs["edge_features"] == {}
):
raise ValueError(
"Please provide feature_specs for either 'node_features' or 'edge_features' or both..."
)Then, inside this one function we can call all the other things related to feature specs validation too (i.e. None > {} It might even be a good idea to differentiate between 'is not set Default Settings DEFAULT_SOCCER_FEATURE_SPECS = {
"edge_features": {
"x_normed": None,
"y_normed": None,,
"s_normed": None,
"v_sin_normed": None,
"v_cos_normed": None,
"normed_dist_to_goal": None,
"normed_dist_to_ball": None,
"is_possession_team": None,
"is_gk": False,
"is_ball": False,
"goal_sin_normed": None,
"goal_cos_normed": None,
"ball_sin_normed":None,
"ball_cos_normed":None,
"ball_carrier": None,
},
"node_features": {
"dist_matrix_normed": None,
"speed_diff_matrix_normed": None,
"pos_cos_matrix": None,
"pos_sin_matrix": None,
"vel_cos_matrix": None,
"vel_sin_matrix": None, (or False, not sure)
},
}Settings Output When we use "graph_settings" do we, from scratch, create the PitchDimensions object with all it's settings? Because I think that should/could simply come from the However, I do think 'orientation' is important, and we should verify the orientation is the same. Settings Output 2 I don't mind storing all the dataset columns btw, but they should probably be it's own key in the json, and then we can verify that we have the same columns after loading from json. That's probably a check that's always going to be correct, but it's good to verify we have all the columns in our American Football |
|
Hi @UnravelSports, please review the following: From JSON I have modified the implementation to take the json file as a parameter during the initialization. Now, it will be passed as such: This calls Validating Feature Specs None > {} Default Settings Settings Output I am confused about x_dim min/max. Aren't all the pitch dimensions different for each game? Settings Ouptut 2 |
Overview
This PR enhances the
GraphConverterclass by introducing flexible feature selection and configuration portability. Users can now definefeature_specsas a dictionary to specify which graph features to include and configure their parameters. With this update, theGraphConverteris more adaptable to different datasets, research objectives, and analytical approaches. Additionally, configurations can be imported from or exported to a JSON file, ensuring reproducibility and easy sharing.Summary of Changes
feature_specsattribute inGraphConverterfeature_specsconfiguration is accurateunravel/soccer/graphs/features/edge_feature_func_map.pyandunravel/soccer/graphs/features/node_feature_func_map.pyto compute graph features based onfeature_specspackage_version", "graph_converter_attributes", "graph_settings", "graph_feature_cols" and "dataset_features". A sample of this can be seen intests/files/default_feature_specs.jsonTesting
These functionalities can be validated by running
pytest tests/test_polar_flexUsing new features: