zilean.core¶
- zilean.core.add_creep_score(timeframes: dict) dict¶
Compute and append the creep score as a feature for a specific timeframe. The creep score is the amount of minion/jungle minions killed by a player.
- Parameters
timeframes (dict) – A dictionary with lists as values. Elememnts of each list value are dictionaries. Each nested dictionary represent a player at one frame of the timeframes.
- Returns
timeframes with creep score computed.
- Return type
dict
- zilean.core.add_proportion(timeframes: dict) dict¶
Transform original features to proportions, which include:
Total gold -> gold porportion. Gold porportion measures the porportion of gold in this position in relation to the total gold of the whole team. This feature is more advance because it considers the total gold of the team.
Xp -> xp porportion. Xp porportion measures the porportion of xp in this position in relation to the total xp of the whole team. This feature is more advance because it considers the total xp of the team.
- Parameters
timeframes (dict) – A dictionary with lists as values. Elememnts of each list value are dictionaries. Each nested dictionary represent a player at one frame of the
timeframes.- Returns
timeframeswith porportions computed.- Return type
dict
- zilean.core.clean_json(file: str, cutoff: int = 16) list¶
Clean a messy JSON file that store
MatchTimelineDtos. Only retain matches that last longer than a specific cutoff.- Parameters
file (str) – Messy file produced by write_messy_json(dic, file).
cutoff (int) – Minimum minutes the matches must have. Defaults to 16.
- Returns
The cleaned JSON content as a dictionary.
- Return type
dict
- zilean.core.clean_timeframe(timeline: dict, frames: list = [8]) dict¶
Clean unwanted features of a specific frame from a Riot
MatchTimelineDtoand fetch player data.- Parameters
timeline (dict) – A Riot
MatchTimelineDto. More info at (https://developer.riotgames.com/apis#match-v5/GET_getTimeline)frames (list) – Integers representing the frames of interest, defaults to [8].
- Returns
Timeline with cleaned data. It will be a dictionary with lists as values. Elememnts of each list value are dictionaries. Each nested dictionary represent a player at one
frameof thetimeline.- Return type
dict
Notes
The function does not handle cases where element of
framesis larger than the total number of frames of thetimeline.
- zilean.core.json_data_mask(dic: dict) list¶
Construct a list of keys that have dictionary as their corresponding value pair. The list acts as a mask for further cleaning.
- Parameters
dic (dict.) – Any dictionary.
- Returns
Keys of input dictionary which have dictionary as value.
- Return type
list
- zilean.core.process_timeframe(timeline: dict, frames: list = [8], matchid: Optional[str] = None, creep_score: bool = True, porportion: bool = True) dict¶
Return a single dictionary with cleaned and processed data for specific frames of a Riot
MatchTimelineDto.- Parameters
timeline (dict) – A Riot
MatchTimelineDto. More info at (https://developer.riotgames.com/apis#match-v5/GET_getTimeline)frames (list) – Integers representing the frames of interest, defaults to [8].
matchid (
str, optional) – The unique matchid corresponding totimeline, defaults to None.creep_score (bool) – Whether to compute the creep_score, defaults to True.
porportion (bool) – Whether to add
goldPorportionandxpPorportionas features to the players, default to True.
- Returns
Dictionary containing cleaned and processed data for each frame in
framesintimeline. Ready for further data analysis.- Return type
dict
Notes
The function does not handle cases where element of
framesis larger than the total number of frames of thetimeline.
- zilean.core.read_api_key(api_key: Optional[str] = None) str¶
Fetch the Riot Development API key. If None provided, it will try to read the file
apikeyin the working directory.- Parameters
api_key (
str, optional) – The api key.- Returns
The api_key.
- Return type
str
Notes
This function’s main purpose is to hide your api key on public resources. You would want to store your api key in a file named
apikeyin the working directory, and fetch your api key everytime through this function.
- zilean.core.validate_timeline(timeline: dict) str¶
Check if the given input is a valid
MatchTimelineDto.- Parameters
timeline (dict) – Any dictionary.
- Returns
matchId of a validated
MatchTimelineDto.- Return type
str
- zilean.core.write_messy_json(dic: dict, file: str) None¶
Append a dictionary to a file. The file are organized line-by-line (each dict is a line).
- Parameters
dic (dict) – Any dictionary.
file (str) – Name of file to append.