Week 8: Classification and Class
June 6, 2024
Greetings! I split my attention this week between work on the Classifier function and doing some more classes with Wolfram- specifically about Neural Network programming.
Classifier Function
After some initial drafts experimenting with it, I came across some problems with its basic functionality. Basically, my idea of how to input the data (pictured below) does not work — the “jagged array” structure is not supported for data science inputs, and is typically a non-ideal approach. So, I had to look into a function that could flatten out the Key names and make all the data into a flattened list. An analogous process is how in a file explorer, you save files under folders inside of folders etc. The directory for these files then looks something like users/username/desktop/file/document.format
. These directories are the reasons you can have files with the same name in different locations. The name identifier is actually the last step in the directory identification.
I can’t pull this same kind of thing with data processing. Instead, I have to compress down the nested association directories into a singular Key name. Now, instead of a Pokémon’s status being stored as attacker/pokemon/status/statuscondition
, the pathway is condensed down so that the statuscondition attribute is now known as attacker_pokemon_status_statuscondition
. It’s a small fix, but it does wonders for readability in the code and my own personal sanity.
Input scrambling
After I made the function that flattens out association directory names, I had to grapple with another issue. How do I assure that the Classifier knows what all available inputs are and knows what it can output instead of just making things up? To fix this, I need to create a series of encoding indices. These encoding indices are basically lists of all potential values that a Pokémon’s aspect can be. (e.g. what species can it be, what abilities can it have, what moves can it use).
To make these indices, I had to go back to the mountain of scrambled lines of data from https://www.smogon.com/dex/sv/pokemon/ , and find a way to parse the very interweaved data values into specific names. This was frustrating, but eventually I got a rhythm down. I use StringSplit to split a long line of code into multiple smaller lines based on some pattern identified throughout. Multiple iterations of this to cut down on the amount of data I have to parse at once. I would eventually get the lists I need to turn into encoders. The only encoders I made this way are: species, moves, abilities, and types. I may think of more later, but this is all the data intrinsic to the website. (at least for right now)
Neural Network Class
The first of my classes this week was a 2.5 hour-long course on the workflow behind NN’s. It taught me a few things that I can apply to this project. Firstly, there’s the general idea of reward-based reinforcement learning. Reinforcement learning operates on a randomly initialized neural network (e.g. a dumb baby). Then it runs the data through it to see how close its result is to the intended result, then adjusts the parameters of the layers inside of the neural network to get closer to the intended result. This turns the dumb baby algorithm into a smart professor algorithm with enough steps. Then, the smart professor is tested on never-before-seen data, and gets tested to see if it performs well when faced with that too.
Overfitting
One issue with reinforcement learning is overfitting- training the network on the same data too many times can accustom it solely to that data specifically. This means it becomes really good at knowing how to work with that data but completely fails when it sees something new. It’s kinda similar to memorizing for a test without understanding the underlying systems. One way to prevent this is with validation data on top of the test data, kind of like a third test to assure that the function can process unseen tasks. You can also use regularization, which sees when a network becomes too complicated and tells it to stop. Both of these have their pros and cons, and you can read more about them here.
Workflow
With supervised machine learning, a typical workflow looks like this:
- Get data
- Choose a model
- Train the model
- Test the model performance
- Deploy for real-world use
I’m working right now on the data-collection part, and once I get that done it could be smooth sailing if I take the easy route and use the built-in Classifier[] function. However, I want to design my own custom NN so that I can declare explicit connections between certain data types specifically (like saying that the typing of the opponent’s active Pokémon has more of an effect on what a player does than the defense stat of a Pokémon in their party).
Next time, I hope to finally nail down the data structure and extraction process.
Until then,
Alex R.
Leave a Reply
You must be logged in to post a comment.