pysoccer.algorithms.playerank.features package¶
Submodules¶
pysoccer.algorithms.playerank.features.abstract module¶
-
class
pysoccer.algorithms.playerank.features.abstract.Aggregation¶ Bases:
objectDefines the methods to aggregate one/more collection of features for each match it have to provide results as a dataframe, e.g. it is used to compute relative feature for each match match -> team (or entity) -> featureTeam - featureOppositor
-
abstract
aggregate()¶ Merge the collections of feature and aggregate by match and team, computing the relative value for each team e.g. match -> team (or entity) -> featureTeam - featureOppositor
- Returns
a dataframe
-
abstract property
get_features¶
-
abstract property
set_features¶ Set the list of collection to use for relative features computing
- Parameters
collection_list – list of collection. E.g. we could have a collection of quality features, one for quantity features, one for goals scored etc
-
abstract
-
class
pysoccer.algorithms.playerank.features.abstract.Feature¶ Bases:
objectClass to wrap all the scripts/method to aggregate features from the database
-
abstract
createFeature(collectionName, param)¶ Method to define how a feature/set of features is computed.
- Parameters
param – contains eventual parameters for querying database competion, subset of teams, whatever
collectionName – best practice: features have to be stored into a collection of documents in the form: {_id: {match: (numeric) unique identifier of the match, name: (string) name of the feature, entity: (string) name of the entity target of the aggregation. It could be teamId, playerID, teamID + role or whatever significant for an aggregation}, value: (numeric) the count for the feature}
- Returns
the name of the collection where the features have been stored
-
abstract
pysoccer.algorithms.playerank.features.centerOfPerformanceFeature module¶
-
class
pysoccer.algorithms.playerank.features.centerOfPerformanceFeature.centerOfPerformanceFeature¶ Bases:
pysoccer.algorithms.playerank.features.abstract.Feature-
createFeature(serialized_events, players_file, select=None)¶ Compute centerOfPerformanceFeatures
- Parameters
serialiazed_events – folder path of events file
players_file – file path of players data file
select – function for filtering matches collection. Default: aggregate over all matches
entity – it could either ‘team’ or ‘player’. It selects the aggregation for qualityFeatures among teams or players qualityfeatures. Note: aggregation by team is exploited during learning phase, for features weights estimation, while aggregation by players is involved for rating phase.
- Returns
list of json docs dictionaries in the format: {matchId : int , entity : int, feature: string , value}
-
pysoccer.algorithms.playerank.features.goalScoredFeatures module¶
-
class
pysoccer.algorithms.playerank.features.goalScoredFeatures.goalScoredFeatures¶ Bases:
pysoccer.algorithms.playerank.features.abstract.FeatureGoals scored by each team in each match
-
createFeature(serialized_matches, select=None)¶ Stores qualityFeatures on database
- Parameters
serialized_matches – file path of matches file
select – function for filtering matches collection. Default: aggregate over all matches
- Returns
list of documents in the format: match: matchId, entity: team, feature: feature, value: value
-
pysoccer.algorithms.playerank.features.matchPlayedFeatures module¶
-
class
pysoccer.algorithms.playerank.features.matchPlayedFeatures.matchPlayedFeatures¶ Bases:
pysoccer.algorithms.playerank.features.abstract.Feature-
createFeature(serialized_matches, players_file, select=None)¶ It computes, for each player and match, total time (in minutes) played, goals scored and
- Parameters
serialized_matches – folder with json files corresponding to matches data
select – function for filtering matches collection. Default: aggregate over all matches
- Returns
a collection of documents in the format _id-> {‘match’: this.wyId, ‘player’ : player, ‘name’: ‘minutesPlayed’|’team’|’goalScored’|’timestamp’},value: <float>|<string>;
-
pysoccer.algorithms.playerank.features.plainAggregation module¶
-
class
pysoccer.algorithms.playerank.features.plainAggregation.plainAggregation¶ Bases:
pysoccer.algorithms.playerank.features.abstract.AggregationMerge features for each player and return a data frame match -> team (or entity) -> feature (playerank, timestamp, team, etc..)
-
aggregate(to_dataframe=False)¶ Merge the collections of feature and aggregate by match and team, computing the relative value for each team e.g. match -> team (or entity) -> featureTeam - featureOppositor
- Returns
a dataframe
-
get_aggregated_collection()¶
-
get_features()¶
-
set_aggregated_collection(collection)¶
-
set_features(collection_list)¶ Set the list of collection to use for relative features computing
- Parameters
collection_list – list of collection. E.g. we could have a collection of quality features, one for quantity features, one for goals scored etc
-
pysoccer.algorithms.playerank.features.playerankFeatures module¶
-
class
pysoccer.algorithms.playerank.features.playerankFeatures.playerankFeatures¶ Bases:
pysoccer.algorithms.playerank.features.abstract.FeatureGiven a method to aggregate features and the corresponding weight of each feature, it computes playerank for each player and match
:param features weights, computed within learning phase of playerank framework
- Returns
a collection of json documents in the format: {match:match_id, name: ‘playerankScore’, player:player_id, value: playerankScore(float)}
-
createFeature(weights_file)¶ Method to define how a feature/set of features is computed.
- Parameters
param – contains eventual parameters for querying database competion, subset of teams, whatever
collectionName – best practice: features have to be stored into a collection of documents in the form: {_id: {match: (numeric) unique identifier of the match, name: (string) name of the feature, entity: (string) name of the entity target of the aggregation. It could be teamId, playerID, teamID + role or whatever significant for an aggregation}, value: (numeric) the count for the feature}
- Returns
the name of the collection where the features have been stored
-
get_features()¶
-
set_features(collection_list)¶
pysoccer.algorithms.playerank.features.qualityFeatures module¶
-
class
pysoccer.algorithms.playerank.features.qualityFeatures.qualityFeatures¶ Bases:
pysoccer.algorithms.playerank.features.abstract.FeatureQuality features are the count of events with outcomes. E.g. - number of accurate passes - number of wrong passes …
-
createFeature(serialized_events, players_file, entity='team', select=None)¶ Compute qualityFeatures
- Parameters
serialized_events – file path of events file
select – function for filtering events collection. Default: aggregate over all events
entity – it could either ‘team’ or ‘player’. It selects the aggregation for qualityFeatures among teams or players qualityfeatures
- Returns
list of dictionaries in the format: matchId -> entity -> feature -> value
-
pysoccer.algorithms.playerank.features.relativeAggregation module¶
-
class
pysoccer.algorithms.playerank.features.relativeAggregation.relativeAggregation¶ Bases:
pysoccer.algorithms.playerank.features.abstract.AggregationCompute relative feature for each match match -> team (or entity) -> featureTeam - featureOpponents
-
aggregate(to_dataframe=False)¶ Compute relative aggregation: give a set of features it compute the A-Bvalue for each entity in each team. Ex: passes for team A in match 111 : 500 passes for team B in match 111 : 300 lead to output: {‘passes’: 200} This method is involved for feature weight estimation phase of playerank framework.
:param to_dataframe : return a dataframe instead of a list of documents
-
get_features()¶
-
set_features(collection_list)¶ Set the list of collection to use for relative features computing
- Parameters
collection_list – list of collection. E.g. we could have a collection of quality features, one for quantity features, one for goals scored etc
-
pysoccer.algorithms.playerank.features.roleFeatures module¶
-
class
pysoccer.algorithms.playerank.features.roleFeatures.roleFeatures¶ Bases:
pysoccer.algorithms.playerank.features.abstract.Feature-
createFeature(matrix_role_file)¶ Given the matrix for roles, it computes, for each player and match, the role of a player. A role matrix is a data structure where, given x and y (between 0 and 100), it contains the correspinding roles for a player having center of performance = x,y Role_matrix is computed within learning phase of playerank framework.
- Parameters
role_matrix – file patch for dictionary in the format x->y->role
feature_lists – lists of features for each player in each match, describing players’ average position
-
get_features()¶
-
set_features(collection_list)¶
-