Using machine learning to predict League of Legends ARAM matches and scoring the best to worst champions in ARAM.
I deployed this project using pythonanywhere.com, you can check it out here
For more information on what I did, you can check out the accompanying report
Steps I performed in this project:
- Extract sample matches from the riot API
- Get the champions present in each match and create a (sparse) dataframe
- Train a logistic regression classifier onto the data
- Deploy onto flask!
The notebook Data Extraction.ipynb
contains the code that I used to extract sample ARAM matches. To get a list of champions and their associated key (the match data contains the key values not the actually champion names), we use the json file champion.json
taken from the riot website. To convert a list of champions into a p-dimensional vector (where p is the number of champions) we use sklearn's CountVectorizer, this will be used to convert the teams into vectors.
This produces: countvectorizer.p
To extract data from riot, you will need to have a league of legends account to get an KPI key, check out here to get a key and enter it into the notebook. The notebook exports the sample match ID's into a sorted list that is saved as a pickle file: pulled_match_ids.p
I primarily used the Cassiopeia package to extract the sample matches.
The second portion in the Data Extraction.ipynb
notebook takes each the match ID's and finds the champions in each team present in that particular match, and which team won (which would be our target) and creates a dataframe (columns represent champions, rows represent a particular match) using the count vectorizer from above.
This exports the final dataframe as a pickle file final_df.p
.
The python file train_and_scoring.py
takes in the final dataframe and trains the data using logistic regression, ridge classifier, SVM, and decision trees. A simple cross validation was utilized to tune each of the 4 models. For my project, I utilized the logistic regression classifier.
This produces the pickle file logistic_regression.p
as the fitted model.
Secondly, I produced a dataframe that contained a sorted dataframe of the champions using their coefficients (I converted it into a 0 to 100 range)
This produces the pickled dataframe: scores.p
,
which will be used in the flask app
To deploy locally make sure you have
champions.json
countvectorizer.p
logistic_regression.p
scores.p
Then simply run app.py