Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Interactive Track Analysis #11

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
9796ab9
A bit of a cleanup in log-analysis file
breadcentric Jun 22, 2019
4f9fcd4
Add normalize_reward to log_analysis, a bit of cleanup, added colour …
breadcentric Jun 22, 2019
e71484a
Add track_utils file
breadcentric Jun 22, 2019
861a998
Avoid downloading of an already existent file, but allow forcing it
breadcentric Jun 24, 2019
2f0e773
Improve plotting of grid world for evaluation (to work with negative …
breadcentric Jun 30, 2019
546ad3c
Move plotting of top laps from the notebook
breadcentric Jun 30, 2019
8d96466
Add functions to aggregate training data
breadcentric Jun 30, 2019
3ccd777
Add functions to load and analyse evaluations in bulk
breadcentric Jun 30, 2019
62b356b
readme, gitignore
breadcentric Jun 30, 2019
5bb33a2
Add evaluation analysis
breadcentric Jul 1, 2019
df39701
small fixes, store timestamp as decimal to make it readable
breadcentric Jul 1, 2019
209ac8e
add code for reward recalculation
breadcentric Jul 2, 2019
9730bb6
Add reward calculation, fix reward, Provide a Training_analysis.ipynb
breadcentric Jul 2, 2019
6005efa
Make episodes per iteration configurable when parsing logs
breadcentric Jul 2, 2019
8545d7f
Add action breakdown and small improvements all around
breadcentric Jul 2, 2019
ba2fd9a
Add evaluation analysis notebook
breadcentric Jul 2, 2019
3e86859
Improve the readme
breadcentric Jul 2, 2019
07cc2a2
Improve the readme
breadcentric Jul 2, 2019
b62a2a3
Add graphs per starting point to aggregates
breadcentric Jul 12, 2019
dc5a48a
Set x axis in progress of buckets to (0,100)
breadcentric Jul 12, 2019
e974b51
Add minimum and maximum complete times per iteration
breadcentric Jul 12, 2019
79b1851
New York tracks for analysis
breadcentric Jul 13, 2019
5e0c209
Fix minimum and maximum time plot
breadcentric Jul 13, 2019
92f276f
Small updates and cleanups, reruns of updated functions
breadcentric Jul 13, 2019
46e15f5
Clean up aggregate graphs for evaluation and fix timestap issue in no…
breadcentric Jul 17, 2019
5f5399c
Preserve shape of top laps graphs
breadcentric Jul 17, 2019
bd61533
Speed up analysis of training progress and reorganise plotting in tra…
breadcentric Jul 17, 2019
cc95464
Speed up plotting of evaluation laps
breadcentric Jul 18, 2019
18deb7f
Updated notebooks to fixes, fine-tune log_analysis, fix some memory i…
breadcentric Jul 20, 2019
4c69b6f
Added China training track npy
breadcentric Aug 3, 2019
7986125
Add China track training and eval npys
breadcentric Aug 19, 2019
c58f818
Fix the bug with episodes per iteration in original notebook
breadcentric Aug 19, 2019
213de10
Add local logs loading to Training_analysis, a little bit of cleanup
breadcentric Aug 19, 2019
7143fc4
Support logs split by size and named with .# suffix
breadcentric Aug 23, 2019
38d5815
Add more descriptions to Training_analysis
breadcentric Aug 24, 2019
776feba
Mexico track
breadcentric Sep 2, 2019
648c01c
Merge pull request #1 from breadcentric/mexico
breadcentric Sep 2, 2019
5dae3e9
Add Mexico eval npy
breadcentric Sep 3, 2019
7b7c140
Improve descriptions for loaded data and new reward
breadcentric Sep 25, 2019
7c3a30d
Add first descriptions to graphs
breadcentric Sep 26, 2019
b1ff60a
Add Canada Training
breadcentric Oct 1, 2019
7a4c86a
Add Canada Eval Track file
breadcentric Oct 5, 2019
43ffda6
Improve descriptions for Training_analysis.ipynb and add minor code i…
breadcentric Oct 6, 2019
757fa87
Improve descriptions for Evaluation_analysis.ipynb, reorganise slight…
breadcentric Oct 6, 2019
f1d8e13
An interative training analysis notebook and shell script to start the
cahya-wirawan Oct 23, 2019
216c48b
renamed the shell
cahya-wirawan Oct 23, 2019
1171385
Updated the notebook
cahya-wirawan Oct 23, 2019
7bece24
Added more informations on hover text
cahya-wirawan Oct 24, 2019
b2bd4a1
Added a legend/colorbar, improved the color maping to its throttle
cahya-wirawan Oct 27, 2019
01aa2ea
moved the interactive code to a new file as a python class
cahya-wirawan Oct 30, 2019
c28ee3f
switched the 1st argument to 2nd
cahya-wirawan Oct 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.iml
.idea
venv
log-analysis/venv
reward
!reward/reward_sample.py
logs
!logs/*-sample.log
.ipynb_checkpoints
6 changes: 4 additions & 2 deletions log-analysis/DeepRacer Log Analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,9 @@
}
],
"source": [
"df = convert_to_pandas(data, None)\n",
"EPISODES_PER_ITERATION = 20\n",
"\n",
"df = convert_to_pandas(data, EPISODES_PER_ITERATION)\n",
"df.head()"
]
},
Expand Down Expand Up @@ -1793,7 +1795,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.5"
"version": "3.6.8"
}
},
"nbformat": 4,
Expand Down
1,302 changes: 1,302 additions & 0 deletions log-analysis/Evaluation_analysis.ipynb

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions log-analysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Log Analysis
This folder contains tools making it simple to read information from training and evaluation logs.

The main part of this project are [Jupyter](https://jupyter.org/) notebooks - think of it as a text editor document enriched with executable code.

## What you need to know to use this

If you just want to have a look, GitHub has a viewer for the notebooks, just click into them and enjoy.

For working with the notebooks you need to be familiar with Python code, but the whole process is reasonably simple. Getting to know pandas and matplotlib will help you evolve from the solutions provided to your own bespoke analysis toolkit.

Tinkering and trying things out is highly desirable. Please share your ideas

## Notebooks

There are currently following notebooks:
* `DeepRacer Log Analysis.ipynb` - original notebook provided by the AWS folks (it has things not used in notebooks listed below)
* `Training_analysis.ipynb` - built on top of the first one with some things removed and many added, prepared to monitor the training progress
* `Evaluation_analysis.ipynb` - built on top of the first one, prepared to analyse evaluation data

## Running the notebooks

I recommend setting up a venv for this:
```
python3 -m venv venv
```
(I recommend folder venv as I have already added it to .gitignore)
Then activate:
```
source venv/bin/activate
```
Then install dependencies:
```
pip install shapely matplotlib pandas sklearn boto3 awscli jupyter
```
Then run
```
jupyter notebook
```
From the opened page you can select a notebook to work with.

## Useful hints
* logs and reward folders have been configured to be ignored by git. This is so that you don't accidentally submit your reward functions or other useful info. Just make sure you secure it somehow yourself.
* have a look at new_reward function usage in the notebooks. It lets you try and evaluate what the reward would look like for a different reward function.

## What can I contribute?

There is a number of opportunities for improvement:
* Report issues/feature requests
* Fix things
* Improve descriptions
* Provide more resources
* Add analysis bits to notebooks
* Complete the `logs_to_params` method in log_analysis to improve the logs replay for a different reward
* Fill in track data used in breakdown in `Training_analysis.ipynb`
* Make the notebooks work with more tracks
2,609 changes: 2,609 additions & 0 deletions log-analysis/Training_analysis.ipynb

Large diffs are not rendered by default.

15,583 changes: 15,583 additions & 0 deletions log-analysis/Training_analysis_interactive.ipynb

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions log-analysis/cw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import boto3
import sys
import dateutil.parser
import os


def get_log_events(log_group, stream_name=None, stream_prefix=None, start_time=None, end_time=None):
Expand Down Expand Up @@ -42,7 +43,11 @@ def get_log_events(log_group, stream_name=None, stream_prefix=None, start_time=N


def download_log(fname, stream_name=None, stream_prefix=None,
log_group=None, start_time=None, end_time=None):
log_group=None, start_time=None, end_time=None, force=False):
if os.path.isfile(fname) and not force:
print('Log file exists, use force=True to download again')
return

if start_time is None:
start_time = 1451490400000 # 2018
if end_time is None:
Expand All @@ -63,7 +68,7 @@ def download_log(fname, stream_name=None, stream_prefix=None,
f.write("\n")


def download_all_logs(pathprefix, log_group, not_older_than=None, older_than=None):
def download_all_logs(pathprefix, log_group, not_older_than=None, older_than=None, force = False):
client = boto3.client('logs')

lower_timestamp = iso_to_timestamp(not_older_than)
Expand All @@ -84,7 +89,10 @@ def download_all_logs(pathprefix, log_group, not_older_than=None, older_than=Non
continue
stream_prefix = stream['logStreamName'].split("/")[0]
file_name = "%s%s.log" % (pathprefix, stream_prefix)
download_log(file_name, stream_prefix=stream_prefix, log_group=log_group)

if not os.path.isfile(file_name) or force:
download_log(file_name, stream_prefix=stream_prefix, log_group=log_group)

fetched_files.append(
(file_name, stream_prefix, stream['firstEventTimestamp'], stream['lastEventTimestamp']))

Expand Down
Loading