My submission for the April 2015 Riot api challenge
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
tests
urf_analyzer
LICENSE
README.md
riot.txt
setup.py
urf_analyzer.ini

README.md

api_challenge

My submission for the April 2015 Riot api challenge

Installation

This works on mac/linux systems.

First install package using pip.

pip install git+https://github.com/benkaufman1757/api_challenge/

The only non-standard python libraries used are numpy, scikit-learn, and matplotlib

In your home directory (~) create a file called ".urf_analyzer.ini" It should look like this:

[urfanalyzer]
api_key=<your api key here no quotes>
data_dir=<directory you want to put your data ex) ~/urf_analyzer_data/>

Lastly, create the data directory

mkdir ~/urf_analyzer_data (or whatever you put as data_dir)

Usage

First get your data.

from urf_analyzer.common.urf_data import UrfData
from urf_analyzer.common.champion_data import ChampionData

u = UrfData()
# get 5 minutes of urf games
ids = u.download_urf_game_ids('na', 1428213600, 1428213900) 
# please keep timeline set to true for now to keep data consistent
u.download_urf_games(ids, timeline=True, max_file_size=15728640)

c = ChampionData()
# one time thing
c.download_champion_data('na')

You have your data in all of the analyzer classes matches and champions attributes.

One cool function is the kill/death heatmap. Pretty self explanatory. Death bush is clearly marked ;)

from urf_analyzer.analyzer.position_grapher import PositionGrapher
pg = PositionGrapher()
# takes region as an argument make sure you have data from this region
pg.graph_kill_positions('na')

This isn't very well named but the DamageDealt class has some funky functions.

from urf_analyzer.analyzer.damage_dealt import DamageDealt
d = DamageDealt()
# woo! specific function names!
d.average_stat_by_champion_to_champions_by_game_per_second('na', 'totalCrowdControlDealt')
d.end_game_stats_by_region_by_game_per_second('na', 'totalDamageDealt')

Before moving on to the next part I just wanted to mention some cool things I noticed while using these functions. I got some weird data and it was especially weird when I used very few games worth of data.

  1. Alistar's total healing done per second (to all entities) was higher than ~90% of champions the average damage per second dealt. But remember that this is aggregated over an entire game. On a related note, the damage dealt to champions graph which is generally used to show who carried the most is a bit misleading because that is aggregated over an entire game. I would like to have a chart in the match history showing the damage dealt to champions over time (RITO PLZ)

  2. Again with the healing. I looked at the chart and Alistar/Sona/Soraka led but then Zac, Sion, Anivia and Zilean showed up in a few of the following healing leaders. So, as you can probably easily guess, Riot counts revives as healing done to champions (however I don't really agree with the Sion one because its like Kogmaw's so I don't think it should count)

  3. Casseopia had unreal crowd control time dealt to champions per second. The graph was a total hockey stick, I looked into it and buying a rylai's on her first item was just insane because the CC lasts forever with the poison/rylai's. Also it was good to see an AP Ashe doing well up there for CC. (Slows really skew the CC charts unsure if they should be counted)

That's I'll I will tell you now, you can go find more weird/cool stuff for yourself.

The TeamStats class has some some functions for seeing what teams do collectively.

from urf_analyzer.analyzer.team_stats import TeamStats
ts = TeamStats()

ban_dict, num_matches = ts.team_bans('na')
# this is more of a helper function, just lets you see that 
# the color shouldn't really have an impact on win %
ts.team_wins_by_color('na')

# anything prefixed with 'first' in the match->team->stat.keys() list
ts.team_wins_by_first_objective('na', 'firstDragon')
[out]: {'Blue team firstDragon losses': 8,
 'Blue team firstDragon wins': 18,
 'Red team firstDragon losses': 14,
 'Red team firstDragon wins': 22,
 'Total Matches': 62}
 
# Warning: this will only work with a lot of games due to the nature of machine learning
# Essentially this will tell you 1 or 0, win or loss if you choose the champion
# Did this part quickly may need to fix some bugs (not very stable)

ts.train_win_classifier()
t.predict_win(['Ryze','Teemo'])
[out]
[('Ryze', 1.0),('Teemo', 0.0)]

# Uses multinomial naive bayes to come up with the answer, I may switch this to Bernoulli naive bayes because I think
# it makes a bit more sense
# The next step for this is to have it predict based on both team comps (trying to not just use win %s of champions)

Additional Notes

The data is meant to be downloaded in the data directory into 3 types of files. There is the match_ids file with contains a set of the match urf match ids. A champion data file with champion info. The match data files are split on user-defined size limits. The default is 15MB per file, this was intended for use if uploading data to aws's s3 but not many people use s3 outside of work (I think)

Plz add ward positions back =)

Shh be quiet about this, most of my commits are just from messing with pathing (I haven't made a fully installable python package with pip before but I wanted it to be easy for yall)

Next Steps

Animate the heatmap. Use bokeh to have a cool, shifting heatmap of the deaths over time in all urf games.

With static data calculate the change in damage potential of each character in urf from classic and see how close people came to it.

Get other people in community actively involved. Honestly I've been waiting for this for a while. I contacted the League of Graphs guy a while ago but I got 1 email back and that was all from him. When I'm less busy I'll maybe try to rally the forums.