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
- get_lanes(lanes, per_frame=None) list¶
Return a slice of the summery statistics that represents specific lanes in the game. Statistics of a specific lane in the summary is marked by an underscore and a number at the end of each feature. For example,
totalGold_0represents the total gold difference of the TOP lane.- Parameters
lane (list) – Position options are any of {“TOP”, “JUG”, “MID”, “BOT”, “SUP”} or their corresponding index {0, 1, 2, 3, 4}.
per_frame (
bool, optional) – 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 including the statistics for the lanes of interest, the matchid, and the label (win).
- Return type
list
- 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