Skip to content

Balancing the recorded data

NotGayBut5CentsAre5Cents edited this page Jun 7, 2018 · 3 revisions

balancing_data.py

Data balancing is important because when we train the model we will need to have an equal amount of keypresses for wasd (as naturally we will press w the most) in our train data for the model to train properly.

get_indexes

Given a list and a key, finds all the indexes of the key in the list

process_counters

params:

counters # a list with counters for amount of key presses
train_data # the npy representation of train data

finds the shortest amount of presses

balance_data

params:

file_path # the path at which the file will be saved
train_data # the data that will be balanced

Uses the counters to make all the counters equall (e.g A:100, W:300, D: 320 will become A:100, W:100, D:100)

print_screen

params:

screen # the screen that should be visualised

A debug function that shows the screen

concat_data

params:

file_path # The path of the first file 
second_file_path # The path of the second file that will 
                 #be concatenated, this path will be used for the save file too
## remove_empty
params:
```python
train_data # the trained data that will be processed

This will remove all entries from a npy array that have no action determined (e.g no key was pressed when recording)

Clone this wiki locally