SnapShots class¶
- class zilean.SnapShots.SnapShots(timelines, frames=[8], creep_score=True, porportion=True, verbose=False)¶
Bases:
objectSnapShots is used for extracting interesting player data from Riot
MatchTimelineDtos. SnapShots is a helper object that facilitates data analysis on League of Legends matches.The reason for the name is because SnapShots can extract player data from a match at specific time intervals, or
frames(in minutes). Data at frames of interest can be used to, for example, predict the result of a match.- timelines¶
- The source data. It can be either a:
String, a file name where either a list of
MatchTimelineDtos (in JSON format) or the computed summary statistics (csv) is stored. The computed summary statistics (csv) should be an earlier saved DataFrame using the SnapShots.to_disk() method.List. A list of
MatchTimelineDtos.Dict. A single
MatchTimelineDto.
- Type
str | list | dict
- frames¶
Integers indicating the frames (in minutes) of interest. Default [8]. This argument does nothing if the specified input
timelinesfile is a stored summary file in csv.- Type
list
- creep_score¶
Compute the creep score for the players, then drop the
minionKilledandjungleMinionKilledfeature of the players. Defaults to True.- Type
bool
- porportion¶
Add
goldPorportionandxpPorportionas features to the players. Defaults to True.- Type
bool
- verbose¶
Print out the progress of loading the source data, defaults to False.
- Type
bool
- agg(type, func: ~typing.Callable[[...], float] = <built-in function sum>) list¶
Aggregate summary statistics either by team or by frame. If by team, the statistics across all five lanes are aggregated. If by frame, the statistics across all frames are aggregated. The default aggregate function is the summation.
- Parameters
type (str) –
Either “team” or “frame”. - “team”: Aggregate summary statistics
by team. A team consist of five lanes, marked by number 0 to 4 in the feature names. For example:
totalGold_0_frame8,totalGold_1_frame8, …,totalGold_4_frame8will be aggregated into a single featuretotalGold_frame8.”frame”: Aggregate summary statistics by frame. Frames are usually marked by a number after “frame” the feature names. For example:
totalGold_0_frame8andtotalGold_0_frame12will be aggregated into a single featuretotalGold_0.
func (function) – A function to perform the aggregation. Defaults to sum (the summation function).
- Returns
Summary statistics after aggregation.
- Return type
list
Notes
This method is not compatible with per frame summary. This feature will be developed in future versions.
- subset(features=[], lanes=[], frames=[])¶
Return a new SnapShots with only a subset of the original summary statistics. Features of the original summary statistics contain information that is seperated by underscores. The generic format of a feature is “FEATURE_LANE_frame#”. For example,
totalGold_0_frame8is the total gold difference between the TOP players at 8 minutes mark. This method will return a copy of the original SnapShots instance if no argument were provided.- Parameters
features (
list, optional) – Features of interest. For available options, please refer to the.feature_info_variable.lanes (
list, optional) – Lane options are any of {“TOP”, “JUG”, “MID”, “BOT”, “SUP”} or their corresponding index {0, 1, 2, 3, 4}.frames (
list, optional) – Frames options can only be chosen from the frames specified during the initiation of this SnapShots instance.
- Returns
A new SnapShots with only a subset of the original summary statistics.
- Return type
zilean.SnapShots
Notes
This method is not compatible does not support subsetting the per frame summary. Only the per match summary will be subsetted. Support of per frame summary will be developed in future versions.
- summary(per_frame=False) list¶
Return the summary for all the matches (
MatchTimelineDto). For each match, summary statistics of every time frame of interest is returned. The summary is ready for further data analysis.- Parameters
per_frame (bool) – If False (default), each match (
MatchTimelineDto) is one dictionary. If True, each frame (in minutes) of a match is one dictionary. Defaults to False.- Returns
A list of dictionaries, ready for further data analysis. Each dictionary is either a match or a frame (see per_frame).
- Return type
list
- to_disk(path='data/', verbose=True) None¶
Save the summaries to disk as csv files using pandas.DataFrame.to_csv()
- Parameters
path (str) – Path name relative to your working directory. Defaults to
data/verbose (bool) – Print the directory where of the saved file. Defaults to True