New York City Car Crash Analysis

New York City Car Crash Analysis

Background

In Summer of 2022 I took my first machine learning class as part of Master in Computer Science at NYU. We had to complete a project throughout the course to analyse a data set and see what conclusion we could garner from it.

There were three stages to this project: The Exploratory Data Analysis (EDA), Homework 1 where I utilised Machine Learning techniques on the data to train and test the data and lastly Homework 2 where I tried using methods to help refine my findings from Homework 1.

I settled on trying to find if there was any correlation between the given cause of the car crash and all other labels I deemed necessary. Below is my full project paper.

Conclusion

This class project gave me an great opportunity to learn how to utilise Machine Learning techniques to attain usable and helpful data. My overall conclusion was that there appears to be no clear correlation between type of crash and the other factors but more exploration of this data can definitely be done in future.

Driving Assistance System to Detect Road Signs Utilizing Faster-RCNN and Yolov3 Networks

Driving Assistance Systems to Detect Road Signs Utilizing Faster-RCNN and Yolov3 Networks

Background

In Spring semester 2022 during my Master’s in Computer in Computer Science at NYU I took a class in Computer Vision. The end goal of the class was to create a group project that would use aspects of what we learned.

My group decided to try using different Neural Networks to detect stop signs on roads. My group included: Jianglong He, Walter Lizardo and Wenxi Xu.

Conclusion

This was a great exploration of practically utilising neural networks in the computer vision setting. It was also very gratifying to create a system that was successful and could actually be utilised in a real world setting under the right circumstances.

Building a Pokémon Team Builder Suggestion AI using the Apriori Algorithm

Building a Pokémon Team Builder Suggestion AI using the Apriori Algorithm

Background

In my Spring 2022 semester at NYU I took AI for Games. The First half of the class was dedicated to the study of how AI was utilised in video games. This ranged from AI to play games, world generation, deep learning components and more. The second half we were then tasked with presenting an idea of our own to helm a group project.

I am a huge fan of competitive Pokémon, specifically 6v6 singles but I also enjoy the VGC Double battles. My idea revolved around utilising the Apriori itemset algorithm to use data on what teams of Pokémon players on showdown are using to then recommend the best Pokémon for the ones the player has already picked. The idea revolves around the concept that if a certain pairing or combination of Pokémon are being used more frequently it must be better, and therefore a good recommendation to give to the player. A similar logic is used in tiering Pokémon on showdown.

After presenting my idea I had three members join: Gavin Senger, Chun Wing Huang and Longtao Lyu. All of us worked together to make the Team Builder and wrote the below paper in the IEEE style about it.

The Paper

Final Thoughts

Overall this was a good start, as touched on in the conclusion of the paper it is promising but we came against the issue that the method is inefficient for training and with large datasets, and there is a lot of data to be garnered from Showdown. Furthermore it would need to be constantly updated for meta shifts. We also were unable to check for player bias in choices in teams.

If I were to take this project forward I would attempt to find a way to alter the Apriori algorithm for this specific use-case and hopefully make it more time efficient. I think with a system where we can live update the database of teams there is a lot potential for helping newer player’s build competitive teams.

Making a 3D Platformer Introduction

Making a 3D Platformer Introduction

I love all games but I tend to lean towards RPGs, strategy games, Action-Adventure and platform fighters. However, another type of genre that I find to be fundamentally linked to the idea of gaming is the 3D platformer. Games like Super Mario 64 and Bajoo Kazooie pioneered the idea of entertaining and well-designed 3D games.

Presently, my favourite 3D platformer is Mario Odessey, it is the classic formula yet refined such that it is efficient, fast and fun while still providing an incredible amount of content.

What Mario Odessey really gets right is the most crucial element for 3D platformers, the movement. Plus, the options provided by Cappy, Mario’s possessed cap, of diving onto him and allowing for another jump opens up the world so much, combined with Mario’s wide array of movement options and the further possibilities that are presented by possessing creatures, creates an amazingly exciting playground.

Another type of 3D platformer I enjoy, and that are fast-paced yet explorative games such as Sonic. I am aware that many people are of the opinion that 3D Sonic was never good but having grown up with 3D Sonic, and experienced great games like Sonic Colours and Sonic Generations, I appreciate the 3D aspect of the series (I have yet to play Forces or Sonic 06, which probably accounts for my perception).

My idea is to build a game inspired by 3D Sonic, with features that include a breathtaking sense of speed, and numerous discoveries via linear levels with branching paths. I plan to boost the game experience by adding several variations:  

  • Depending on the branch take in a level, a different path is unlocked in the story narrative.
  • Characters with varying play styles and abilities would unlock different paths.
  • Shooting for the quickest time and high scores results in lucrative rewards.

I am confident that I have a solid game concept, but the task ahead is marginally trickier, how do I realise my game idea? I consider it’s best to start from the basics, and decided to use the Unity Engine, my rationale being that I have coding experience in C++ and I believe I can easily manage the change to C# which is used in Unity. Therefore, to this end I have been engaging and learning from free online tutorials, and I am excited to post updates of my progress on my blog.

Pokemon Showdown AI Introduction

Pokemon Showdown AI Introduction

Introduction

In my first semester of grad school, I have been taking Artificial Intelligence, learning about the theory and algorithms behind AI. All I have been able to think about in every class is how can I apply this to Pokémon, literally, every class! So, I thought why not give it a go? I haven’t completed the class, therefore as I develop the idea I might think of a better way to enact my vision but for now, I have a basic concept of what I want to achieve and what algorithm to use.

Background on Pokémon Showdown and 6v6 singles battling and mechanics

Pokémon Showdown is an online battle simulator where you can build teams of 6 to battle in different formats. My most played format is the Gen 8 OverUsed Tier. During Lockdown in 2020, I got back into playing on the competitive OU ladder and managed to reach the 1700s for the first time, which placed me top 500 for a brief few days.

Pokémon are tiered so that more Pokémon can be viable despite there being big discrepancies in which ones are good and bad. OU is the second-highest tier, with the most overpowered Legendaries being put into Ubers, and overall, it is the most played tier. The tiers for 6v6 singles are Ubers, OverUsed, UnderUsed, RarelyUsed and NeverUsed. You are also allowed to use Pokémon in tiers lower than the one you are playing in. There are other formats of play but we will be focusing on 6v6 singles.

In competitive battling 6 of your Pokémon versus 6 of your opponent’s Pokémon, with each Pokémon able to have a held item and no consumable items (no potions, revives etc.) that are usually available when playing the main series Pokémon games. Other than Tiering Pokémon, there are certain moves and conditions put into place to keep the game competitive, such as only one Pokémon can be put to sleep at a time, no one-hit KO moves, no Baton Pass etc.

Each Tier develops its own metagame, whereby a certain Pokémon rises to prominence because of how well it does against the Pokémon available in the Tier. This helps when playing competitively because you can develop intuition and understanding of what Pokémon your opponents will play and what sets they have.

The complexity in the battle comes from how you build your team. Pokémon have 6 Stats, which are values that determine the amount of damage dealt or taken by a Pokémon, such values are derived using a damage calculation. These Stats are HP (health points), Attack, Special Attack, Defense, Special Defence and Speed. You also have access to 252 Effort Values (EVs) to assign across the 6 Stats to specify the exact Stats of your Pokémon. This means you could build a Pokémon to be a fast and strong attacker or have a lot of bulk and high Defence. A great deal of effort goes into building a team and then playing it against others. However, all of these factors make developing a Pokémon AI difficult as there are numerous considerations to account for.

Other factors to think about are Status Conditions such as:

  • Paralysis, which halves a Pokémon’s speed and may result in the Pokémon being unable to move.
  • Burn, which reduces the damage a Pokémon can inflict by 1/16thof its total health and halves its attack.
  • Poison, which reduces Pokémon’s health by 1/8th each turn.
  • Toxic Poisoning, which deals n/16th of the Pokémon’s total health, where n starts as 1 and increases by 1 each turn (1/16, 2/16, 3/16 etc.),
  • Sleep, makes a Pokémon unable to move with a 1/3 chance of waking up each turn.
  • Freeze, renders a Pokémon unable to move with a 1/5 chance to thaw out.

There are also Entry Hazards, which can be set up by Moves that damage a Pokémon and reduce a Stat or inflict a Status Condition on the switch in. They are a great way to set up a consistent way to weaken opposing Pokemon on the switch-in.

Complexity is increased further when Pokémon have 4 Moves available to them which can achieve numerous things. Such Moves can damage an opposing Pokémon, inflict a Status Condition, set up Entry Hazards, lower the opposing Pokémon’s Stats, make them flinch, any combination of these effects and more. Each Move also includes a Base Power, determining how much damage it deals, and accuracy, and how likely a Move is to hit.

Damaging Moves are either Special or Physical;

  • Physical Moves are calculated with a Pokémon’s Attack Stat against the opponent’s Defence Stat.
  • Special Moves are calculated with a Pokémon’s Special Attack Stat against the opponents Special Defence Stat.

Pokémon and Moves also have Typing (Fire, Water, Grass, Electric, Ghost etc.) If a Move Type is super effective against your defending Pokémon’s Type, it deals double damage, if a Move is not very effective it does half damage etc. Pokémon also have Dual Typings, so you can have Pokémon that is 4 times weaker against Moves or on the other hand can resist Moves by 4 times (that they only deal 1/4 damage). Additionally, if a Move used by a Pokémon is the same type as the Pokémon there is a 1.5 times damage bonus.

There are more factors involved in Pokémon battling, this is by no means a comprehensive summary, but I wanted to provide some background to illustrate the obstacles that need to be overcome when designing AI for singles battling.

Representation of how Pokemon may be tiered
Damage Formula
Pokemon type matchup chart

Thoughts on how to approach this problem

Monte Carlo Search tree algorithm

Developing AI has been a popular endeavour for classic games, such as Chess and Go. However, these games have a few major differences from Pokémon 6v6 battles.

  • The first difference is that both the classic games are fully observable, meaning you can see all your opponent’s pieces and see all the moves they can make. In Pokémon, you can only see your opponent’s Pokémon, but you do not know their Moves, Ability and EV distribution.
  • The second difference is that Chess and Go are deterministic, meaning they are not luck-based games, there is no random chance or chaotic factor. In Pokémon, Moves have accuracy, but there are chances for Moves to trigger secondary effects and more, which makes Pokémon a stochastic game.
  • The final difference is that Pokémon isn’t turn-based, whereas in Chess and Go each player makes consecutive moves allowing the players to analyse the state of the board after their opponents move and make their next move accordingly. However, in Pokémon, both players make their Moves simultaneously based on the state of the game, and which Pokémon goes first is dependent on the Pokémon’s Speed Stat.

I had to consider all these variables in order to formulate the best method to develop an appropriate AI program. Based on what I have learned, the best solution I can think of is to use the Monte Carlo search tree method. This method analyses a state, all the possible moves, and then runs what is called rollout functions to see which option is best.

The rollout function randomly simulates the game for a certain number of turns and evaluates the final state based on a heuristic function. At each point in the game, a player has a total of 9 options, that is 4 Moves and 5 possible Pokémon to switch into (assuming none have been defeated). The challenge is that the opponent’s Moves and EV distribution are unknown at the outset.

The question is how do I manage the rollout function? I found the solution is to create a Data Set of games, containing data on what Sets and Moves the Pokémon are running, then based on that, pick the most common Set and use that in the rollout. Following that, as information is gained in the battle, use the gained information to predict which particular Set is being used from the Data Sets. For example, when a Dragaplut is using the Move Dragon Dance, the algorithm would adjust the predicted Set to be the most common Set using Dragon Dance, as opposed to the common default Set, being the Choice Specs Set, using the gen 8 ou tier as an example. This can also predict Pokémon’s Stats.

The next issue is how to evaluate the State after the rollout? I believe a suitable option is a Heuristic function that takes into account;

  • Pokémon not defeated on your team against Pokémon not defeated on your opponent’s team
  • the difference of your teams’ % health against your opponent’s team % health,
  • the amount of hazards on your side of the field against hazards on your opponent’s side of the field
  • the number of Pokémon inflicted with Status on your team against the number of Pokémon inflicted with Status on your opponent’s team.

I could also possibly assess the best weighting for this function by implementing a perceptron algorithm.

AI is a new and exciting realm for me, and I am uncertain of the outcomes of applying my strategy, however, I am keen to learn what obstacles I need to overcome and the final result of my effort. 

Lost in translation

Lost in translation

Short Story by Hasan Zubairi Masud


19/10/2016

Hey Diary,

University has been a time. 3 weeks in and it just keeps on getting more and more. American Uni is bloody weird, like why do we have midterms during the 3rd week?! Doesn’t midterm mean middle of the term? So like, isn’t that week 5 in a 10 week term, not week 3. So yeah midterms took me by surprise. I got through the stress only to figure out I have both Maths and Physics midterms next week! So, have to start studying for that, grind don’t stop I guess. I’m still making friends here slowly. Getting closer with my roommates, they’re really nice guys and fun to be around. My floor in my dorm is also really cool and friendly. I was so nervous coming here from home but I’m settling alright and learning the ways of the American people.

There have been so many things to get used to. Like, why is everything named to be so obvious. A trolley is shopping cart, a bin is a trash can, a lift is an elevator… okay so that last one might actually be the other way around, but you get my point. Also why is there no ground floor? Only in like specific buildings do you have a ground floor but the rest, nah. America always has to be different. The amount of times I press the first-floor button and just reopen the lift is too much. Also, on the topic of lifts, whenever I say should I call the lift, ie. The elevator, I’m sick of hearing “Oh how is a Lyft meant to drive up the stairs?!” I get it, I call it a different word, I laughed the first time, 238 times later. My Neighbors keep on calling me banana but pronounced how I say it as a brit. They either like how I say banana or are making fun of me, but I can’t really tell. It was fun at first but getting to be a bit much tbh. Also figuring out what year a sophomore and junior are has really been confusing to me, as senior and freshman are rather self-explanatory those 2 have messing with my head. ALSO, big one. Why is football not football here! American football is not football I am sorry. The rest of the world calls it football, why do Americans call it soccer and have their own weird rugby called football? If anything, it should be called Runball or game play for 10 seconds every 2 hours. Oh, and Americans seem to be weirdly into cults.

Earlier this week when I was walking to class I got a flyer saying ‘come learn the American truth, free ice cream and pizza!” There was free food, so I went, and I was curious what the American truth as well. So, I went to the address, there were some weird Greek looking letters on top of the house. I went in and I was brought into a dark ass room with candles placed everywhere. There is some weird ass red symbol on the ground in the center room, and a table with pizza and ice cream on the side. I helped myself and went and sat in some chairs that had been put out. The club President entered wearing a pure white hoodie with the same red mark from the floor placed in the center of their chest. We were told to refer to the president as ‘Divine leader of the holy 48th order that wishes to smite all wrong doers in the eyes of those who defile the true lord’ or ‘DL’ for short. They started explaining the background of the club, how they came to America on the Mayflower, how they shaped American society and its values, and how they must remove all who oppose their one true and absolute vision. Honestly, it was fascinating, it was amazing that I didn’t know about this key aspect of the mysterious American culture, though I guess mass murder like the DL was describing wasn’t something you’d teach kids at school, felt far more college level.

Following the address from the DL, the members, dubbed ‘followers’, handed out these intricate yet rather dirty knives to all the attendees. They all had what was either dried up blood or ketchup on them. A baby lamb was then put in front of all the attendees. DL explained how entrance by murder was a deep cultural tradition, and using humans is just far too inconvenient. Okay Diary, I didn’t particularly want to kill the lamb, but I also didn’t want to disrespect the culture of the country I was a guest in, so I slit its throat. The other attendees did not seem as concerned about being disrespectful and refused to kill the lambs. They were ushered to another room, the DL simply said they were going to get a talking to. It must have been quite the talking too, I could hear their screams on my way out.

Apparently, I passed the first stage initiation and was assigned a mentor called a ‘big.’ His name was Chet, he was the only one cool with dealing an immigrant. He said he thinks having someone like me was important for the ‘look’ of the organization and is willing to help me out as such. We met up for lunch yesterday and he explained the second stage of the initiation. I had to murder someone. Not gonna lie, it made me a little uncomfortable being asked to end a human life, other than the clear moral issues with it, what would happen to my Visa, I don’t want to get deported! Did you know that when you get deported, they charge for the flight you get sent back on, it’s wild. However, Chet assured me they have connections that would protect me, they murder hundreds of people every year and cover it with ease. Still wasn’t totally cool with the idea of murder, but I guess you gotta do what you gotta do to assimilate. I was definitely getting immersed in the culture.

For the rest of lunch Chet taught me how to choke someone out and handed me a go pro to set up in a shower where I’ll do the deed. He also slipped me the knife from the first stage to use to cut out the persons heart as further proof of my act. Diary, America is so weird, but I think slowly, I’m fitting in.


Lucy

Lucy

a short story by Hasan Zubairi Masud


Lucy felt as if she’d been going up this elevator for an eternity. There wasn’t much to look at, just the pristine almost surgical white walls, and looking at them for too long hurt her eyes. She sighed and pressed up against the wall. She began to lightly click her red ballpoint pen.

click                                               click                                              click                                               click                                         click                   click               click          click      click   click  click  Click Click Click CLickClickClickCliCKCLiCKCLICKCLiCKCLICKCLICKCLICKCLICKLCIKCLCIKCLCICKK

Her feet start tapping furiously to the same chaotic rhythm of the pen. Her left hand in a clenched fist. Being in the elevator was just getting her blood boiling. The longer she had to wait the more time she had to think about what was so very fucking wrong,

The elevator began to slow down.

Lucy quickly unclenched her fist and pocketed her pen. She fixed her red hair and stood up straight. Her mouth smiled, her black eyes did not.

Ding

The elevator stopped.

Two men in all white walked in. They both had golden name tags in contrast to Lucy’s dingy aluminium one. Lucy glanced at the name tags quickly. One read Michael and the other Gabriel. They gave a slight side-eye to Lucy as they walked in, Gabriel for uncomfortably long, but they both quickly turned their backs on her and went to select their floor. They soon realised their floor was already pressed to their puzzlement.

Silence.

In the rather awkward situation, Lucy couldn’t help but fiddle around. Nonetheless, she tried to minimize her movement.

“So Michael, how was work yesterday?” asked Gabriel.

“Messy, I spilt on myself while working on asset management, it took ages to get the red stain out last night!”

“Oh god, I can imagine. Why not send it down to the basement and just have them wash it?”

“Gabriel, you know you can’t trust them they’re absolute…” Michael trailed off while shooting a glance at Lucy. Lucy’s mouth smiled at him, her black eyes did not.

“Regardless… how about you Gabriel? How was work yesterday?”

“Real fun honestly. It’s not often I get to go out into the field and do some hands-on work with our clients.”
“I totally understand. As much good as we do through our work in administration, to be able to go out and physically make a change for our clients is truly brilliant.”

Both men straightened up, clearly rather happy with themselves. Lucy rolled her eyes but quickly resumed staring off in front of herself.

Lucy hated them. How they dominated over her and her people, ending their careers at a drop of a penny. Asset management, trying to minimize losses throughout the company. Lucy was forced to watch her best friend permanently removed from the department. Her friend had never done anything wrong in her job. No, it was only about dominance and power. A reminder of who held it. And it wasn’t Lucy and her co-workers in the basement.

“Oi, sweetheart!”

Lucy was startled out of her thoughts. Both men had their bright, white eyes shining onto her.

“I’m sorry, I was in my thoughts.” She brushed her red hair back in a panic but pricked her thumb on the points on her skull. A little bit of red blood came out, but she quickly wiped it away.

“Well I’d say so,” said Michael with a bellowing laugh. “So, what’re you seeing the man upstairs for?”

“I’m sorry?”

“You daft? Why are you seeing the CEO?” Gabriel gestured to the only button pressed in the elevator, the top one.

“Oh, uh” Lucy had to think of a quick excuse. “I’m honestly not too sure, he called for me you see.”

“Well, aren’t you a lucky devil!” exclaimed Michael. “Wonder what’s so special about you then?”
“Shall we find out?” Gabriel started moving his hand towards Lucy’s blouse.

Lucy had been holding it in. Everyone had a limit and she was well past hers.

Lucy clicked her red pen.

Gabriel’s eyes widened; a red sword penetrated his chest. Blue blood slowly dripped down it. Lucy pulled the sword out and he fell to the floor with an ever so ungraceful thud.

“You Bitch!” Michael exploded into action. Now enveloped in light, and with his wings out, he quickly materialised his ‘bow.’ Lucy never understood why they called them ‘bows.’ Maybe because it sounded nicer than ‘gun.’ Regardless Lucy was more experienced than most, and as such, found Michael’s actions rather predictable. She side-stepped him and cut his wings off. While he was still shocked at the loss of his wings, she then slit his throat. He collapsed to the floor as his blue blood spurted everywhere.

Lucy clicked her sword back into a pen. She gazed around at the elevator. She’d made a right mess that’s for sure. The elevator looked like a Jackson Pollock where he was particularly favourable to the colour blue. She felt a little better though; she guessed stabbing had more positive mental health benefits than most realised.

With the adrenaline wearing off, she noticed her face was also splattered with blue blood. She reached down into Michael’s corpses suit pocket and retrieved a handkerchief to clean her face.

“Don’t… Don’t touch him.”

Lucy glanced down and saw some movement from Gabriel. Guess she missed his heart. Did he actually even have a heart? Shower thoughts for later.

“Alive, are we? Want me to change that?”

“You fucking devil! You and the other little shits like you can go to hell!”

Lucy bent down so her deep, pure black eyes could stare him in the face.

“We already are.”
She glanced up at their current floor. “Ah almost there.” She stood up.

“You deserve to be there you know.”

Lucy glared down at Gabriel. “Like fuck we do! If I hadn’t fed his fucking creation, he’d have no clients, no one to worship him! I don’t care if it was his personal fruit tree, I saved this bloody company!!! One mess up and to hell you go! It’s fucking bullshit! And you privileged angels are only okay with it ‘til it’s you who’s the fuck up and you end up down there with the rest of us. I’m going to change this shit.”

“They need someone to fear.”

“Fear of God should be enough. It is for us”

Lucy clicked her sword back and sliced Gabriel’s head off. The doors opened, an intensely bright light shone into the elevator, illuminating the now partially white walls. Lucy stepped out.

“Oh, Lucifer my old friend, what brings you here?”