In the world of Pokémon there are 18 types that are properties of the Pokémon and their moves. A Pokémon may have one or two types (dual type), meaning that there are 324 posible combinations, 18 single type Pokémon and 306 dual types Pokémon. However in the games, there are no differences between the order of the types in a dual type Pokémon, in other words, a Flying/Dragon Pokémon is treated in the same way a Dragon/Flying Pokémon is treated.
In this work we will take a look at dual type Pokémon. The analysis is mostly an exploratory data analysis where we will study topics such as most frequent secondary type by primary type, the most common secondary types by region and in the last part, we will introduce a prediction model to see if there is any relation between dual types Pokémon and their region of origin.
Unlike the games, we will consider the order of the types of a dual type Pokémon using the way it is documented in the Pokedex. For example, we will treat a Flying/Dragon Pokémon such as Noivern and Dragon/Flying Pokémon like Altaria as having two different types.
The Pokémon included in this study are the ones currently available in the National Pokedex, starting with Bulbasaur and ending with Zygarde; a total of 718 Pokémon. Also, Mega Pokémon and alternate forms of Pokémon like Rotom forms and the Therian forms are not included.
Our original dataset consists of two columns called dataset.Type.1
and dataset.Type.2
. The first column, dataset.Type.1
has the primary type of the Pokémon and the second one, dataset.Type.2
, the secondary type. If the Pokémon does not have a secondary type, the corresponding entry in dataset.Type.2
is <NA>
(not applicable). The dataset has a total of 718 observations (rows) because we are working with the National Pokedex and you may have noticed, the name of the Pokémon is not included, the reason behind this is that it is not really necessary since we are just interested in the types. Instead, we use the index or the number of the row. For example, row number 4 is a pure Fire type Pokémon (Charmander).
## dataset.Type.1 dataset.Type.2
## 1 Grass Poison
## 2 Grass Poison
## 3 Grass Poison
## 4 Fire <NA>
## 5 Fire <NA>
## 6 Fire Flying
The following matrix shows the total of dual types Pokémon per each primary type. Each row represents a primary type and the columns the secondary type. For example, the matrix shows there are 2 Bug/Electric Pokémon, 1 Bug/Fighting, 2 Bug/Fire and so on. The -1 entries means that it does not apply, since for example a Bug/Bug Pokémon would be a pure Bug type, and pure types are out of the score of this analysis.
## dataset.Type.2
## dataset.Type.1 Bug Dark Dragon Electric Fairy Fighting Fire Flying Ghost
## Bug -1 0 0 2 0 1 2 13 1
## Dark 0 -1 3 0 0 2 2 5 1
## Dragon 0 0 -1 1 0 0 1 4 0
## Electric 0 0 0 -1 1 0 0 3 1
## Fairy 0 0 0 0 -1 0 0 2 0
## Fighting 0 1 0 0 0 -1 0 1 0
## Fire 0 0 0 0 0 6 -1 5 0
## Flying 0 0 2 0 0 0 0 -1 0
## Ghost 0 1 1 0 0 0 3 2 -1
## Grass 0 3 0 0 2 3 0 4 0
## Ground 0 3 2 1 0 0 0 3 2
## Ice 0 0 0 0 0 0 0 2 1
## Normal 0 0 0 0 4 0 0 23 0
## Poison 1 3 1 0 0 2 0 3 0
## Psychic 0 0 0 0 5 1 1 6 0
## Rock 2 1 2 0 1 1 0 3 0
## Steel 0 0 1 0 2 1 0 1 3
## Water 0 4 2 2 2 2 0 7 2
## dataset.Type.2
## dataset.Type.1 Grass Ground Ice Normal Poison Psychic Rock Steel Water
## Bug 6 1 0 0 11 0 3 5 1
## Dark 0 0 2 0 0 2 0 2 0
## Dragon 0 4 1 0 0 2 0 0 0
## Electric 0 0 0 2 0 0 0 3 0
## Fairy 0 0 0 0 0 0 0 0 0
## Fighting 0 0 0 0 0 2 0 1 0
## Fire 0 2 0 2 0 1 1 1 0
## Flying 0 0 0 0 0 0 0 0 0
## Ghost 4 0 0 0 3 0 0 0 0
## Grass -1 1 2 0 14 2 0 2 0
## Ground 0 -1 0 0 0 2 3 1 0
## Ice 0 3 -1 0 0 2 0 0 3
## Normal 2 1 0 -1 0 2 0 0 1
## Poison 0 2 0 0 -1 0 0 0 1
## Psychic 1 0 0 0 0 -1 0 0 0
## Rock 2 6 2 0 0 2 -1 3 6
## Steel 0 1 0 0 0 6 3 -1 0
## Water 3 9 3 0 3 4 4 1 -1
The next figure, a heat map, shows the same information from the previous table in another way. The Y axis is the primary type and the X axis the secondary one. Regardings the colors, the darker they are, the smaller the frequency is and the lighest the color is, higher the frequency is.
The figures in the section shows the quantity of secondary types by primary type. For example the first plot can be interpreted as this, “there are 13 Bug/Flying Pokémon, 11 Bug/Poison and so on.”
## dataset.Type.1 dataset.Type.2 Freq
## Bug Flying 13
## Bug Poison 11
## Bug Grass 6
## Bug Steel 5
## Bug Rock 3
## Bug Electric 2
## Bug Fire 2
## Bug Fighting 1
## Bug Ghost 1
## Bug Ground 1
## Bug Water 1
## Bug Dark 0
## Bug Dragon 0
## Bug Fairy 0
## Bug Ice 0
## Bug Normal 0
## Bug Psychic 0
## dataset.Type.1 dataset.Type.2 Freq
## Dark Flying 5
## Dark Dragon 3
## Dark Fighting 2
## Dark Fire 2
## Dark Ice 2
## Dark Psychic 2
## Dark Steel 2
## Dark Ghost 1
## Dark Bug 0
## Dark Electric 0
## Dark Fairy 0
## Dark Grass 0
## Dark Ground 0
## Dark Normal 0
## Dark Poison 0
## Dark Rock 0
## Dark Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Dragon Flying 4
## Dragon Ground 4
## Dragon Psychic 2
## Dragon Electric 1
## Dragon Fire 1
## Dragon Ice 1
## Dragon Bug 0
## Dragon Dark 0
## Dragon Fairy 0
## Dragon Fighting 0
## Dragon Ghost 0
## Dragon Grass 0
## Dragon Normal 0
## Dragon Poison 0
## Dragon Rock 0
## Dragon Steel 0
## Dragon Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Electric Flying 3
## Electric Steel 3
## Electric Normal 2
## Electric Fairy 1
## Electric Ghost 1
## Electric Bug 0
## Electric Dark 0
## Electric Dragon 0
## Electric Fighting 0
## Electric Fire 0
## Electric Grass 0
## Electric Ground 0
## Electric Ice 0
## Electric Poison 0
## Electric Psychic 0
## Electric Rock 0
## Electric Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Fairy Flying 2
## Fairy Bug 0
## Fairy Dark 0
## Fairy Dragon 0
## Fairy Electric 0
## Fairy Fighting 0
## Fairy Fire 0
## Fairy Ghost 0
## Fairy Grass 0
## Fairy Ground 0
## Fairy Ice 0
## Fairy Normal 0
## Fairy Poison 0
## Fairy Psychic 0
## Fairy Rock 0
## Fairy Steel 0
## Fairy Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Fighting Psychic 2
## Fighting Dark 1
## Fighting Flying 1
## Fighting Steel 1
## Fighting Bug 0
## Fighting Dragon 0
## Fighting Electric 0
## Fighting Fairy 0
## Fighting Fire 0
## Fighting Ghost 0
## Fighting Grass 0
## Fighting Ground 0
## Fighting Ice 0
## Fighting Normal 0
## Fighting Poison 0
## Fighting Rock 0
## Fighting Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Fire Fighting 6
## Fire Flying 5
## Fire Ground 2
## Fire Normal 2
## Fire Psychic 1
## Fire Rock 1
## Fire Steel 1
## Fire Bug 0
## Fire Dark 0
## Fire Dragon 0
## Fire Electric 0
## Fire Fairy 0
## Fire Ghost 0
## Fire Grass 0
## Fire Ice 0
## Fire Poison 0
## Fire Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Flying Dragon 2
## Flying Bug 0
## Flying Dark 0
## Flying Electric 0
## Flying Fairy 0
## Flying Fighting 0
## Flying Fire 0
## Flying Ghost 0
## Flying Grass 0
## Flying Ground 0
## Flying Ice 0
## Flying Normal 0
## Flying Poison 0
## Flying Psychic 0
## Flying Rock 0
## Flying Steel 0
## Flying Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Ghost Grass 4
## Ghost Fire 3
## Ghost Poison 3
## Ghost Flying 2
## Ghost Dark 1
## Ghost Dragon 1
## Ghost Bug 0
## Ghost Electric 0
## Ghost Fairy 0
## Ghost Fighting 0
## Ghost Ground 0
## Ghost Ice 0
## Ghost Normal 0
## Ghost Psychic 0
## Ghost Rock 0
## Ghost Steel 0
## Ghost Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Grass Poison 14
## Grass Flying 4
## Grass Dark 3
## Grass Fighting 3
## Grass Fairy 2
## Grass Ice 2
## Grass Psychic 2
## Grass Steel 2
## Grass Ground 1
## Grass Bug 0
## Grass Dragon 0
## Grass Electric 0
## Grass Fire 0
## Grass Ghost 0
## Grass Normal 0
## Grass Rock 0
## Grass Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Ground Dark 3
## Ground Flying 3
## Ground Rock 3
## Ground Dragon 2
## Ground Ghost 2
## Ground Psychic 2
## Ground Electric 1
## Ground Steel 1
## Ground Bug 0
## Ground Fairy 0
## Ground Fighting 0
## Ground Fire 0
## Ground Grass 0
## Ground Ice 0
## Ground Normal 0
## Ground Poison 0
## Ground Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Ice Ground 3
## Ice Water 3
## Ice Flying 2
## Ice Psychic 2
## Ice Ghost 1
## Ice Bug 0
## Ice Dark 0
## Ice Dragon 0
## Ice Electric 0
## Ice Fairy 0
## Ice Fighting 0
## Ice Fire 0
## Ice Grass 0
## Ice Normal 0
## Ice Poison 0
## Ice Rock 0
## Ice Steel 0
## dataset.Type.1 dataset.Type.2 Freq
## Normal Flying 23
## Normal Fairy 4
## Normal Grass 2
## Normal Psychic 2
## Normal Ground 1
## Normal Water 1
## Normal Bug 0
## Normal Dark 0
## Normal Dragon 0
## Normal Electric 0
## Normal Fighting 0
## Normal Fire 0
## Normal Ghost 0
## Normal Ice 0
## Normal Poison 0
## Normal Rock 0
## Normal Steel 0
## dataset.Type.1 dataset.Type.2 Freq
## Poison Dark 3
## Poison Flying 3
## Poison Fighting 2
## Poison Ground 2
## Poison Bug 1
## Poison Dragon 1
## Poison Water 1
## Poison Electric 0
## Poison Fairy 0
## Poison Fire 0
## Poison Ghost 0
## Poison Grass 0
## Poison Ice 0
## Poison Normal 0
## Poison Psychic 0
## Poison Rock 0
## Poison Steel 0
## dataset.Type.1 dataset.Type.2 Freq
## Psychic Flying 6
## Psychic Fairy 5
## Psychic Fighting 1
## Psychic Fire 1
## Psychic Grass 1
## Psychic Bug 0
## Psychic Dark 0
## Psychic Dragon 0
## Psychic Electric 0
## Psychic Ghost 0
## Psychic Ground 0
## Psychic Ice 0
## Psychic Normal 0
## Psychic Poison 0
## Psychic Rock 0
## Psychic Steel 0
## Psychic Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Rock Ground 6
## Rock Water 6
## Rock Flying 3
## Rock Steel 3
## Rock Bug 2
## Rock Dragon 2
## Rock Grass 2
## Rock Ice 2
## Rock Psychic 2
## Rock Dark 1
## Rock Fairy 1
## Rock Fighting 1
## Rock Electric 0
## Rock Fire 0
## Rock Ghost 0
## Rock Normal 0
## Rock Poison 0
## dataset.Type.1 dataset.Type.2 Freq
## Steel Psychic 6
## Steel Ghost 3
## Steel Rock 3
## Steel Fairy 2
## Steel Dragon 1
## Steel Fighting 1
## Steel Flying 1
## Steel Ground 1
## Steel Bug 0
## Steel Dark 0
## Steel Electric 0
## Steel Fire 0
## Steel Grass 0
## Steel Ice 0
## Steel Normal 0
## Steel Poison 0
## Steel Steel 0
## Steel Water 0
## dataset.Type.1 dataset.Type.2 Freq
## Water Ground 9
## Water Flying 7
## Water Dark 4
## Water Psychic 4
## Water Rock 4
## Water Grass 3
## Water Ice 3
## Water Poison 3
## Water Dragon 2
## Water Electric 2
## Water Fairy 2
## Water Fighting 2
## Water Ghost 2
## Water Steel 1
## Water Bug 0
## Water Fire 0
## Water Normal 0
## Water Water 0
This table shows the frequency of secondary types. For example, there are 3 Pokémon with Bug as a secondary type (Anorith, Armaldo and Skorupi).
## Bug Dark Dragon Electric Fairy Fighting Fire Flying
## 3 16 14 6 17 19 9 87
## Ghost Grass Ground Ice Normal Poison Psychic Rock
## 11 18 30 10 4 31 27 14
## Steel Water
## 19 12
The most common secondary type is Flying with 87 and the rarest is Bug with just 3.
In this section we will summarize the dual types per region (Kanto, Johto, Hoenn, Sinnoh, Unova and Kalos). The following tables shows the top five dual types per region.
## dataset.Type.1 dataset.Type.2 region Freq
## Grass Poison Kanto 9
## Normal Flying Kanto 8
## Bug Poison Kanto 5
## Rock Ground Kanto 4
## Rock Water Kanto 4
## Water Ice Kanto 3
## dataset.Type.1 dataset.Type.2 region Freq
## Bug Flying Johto 3
## Grass Flying Johto 3
## Psychic Flying Johto 3
## Water Electric Johto 2
## Water Fairy Johto 2
## Dark Fire Johto 2
## dataset.Type.1 dataset.Type.2 region Freq
## Water Ground Hoenn 4
## Steel Psychic Hoenn 4
## Grass Dark Hoenn 3
## Water Dark Hoenn 3
## Psychic Fairy Hoenn 3
## Bug Flying Hoenn 3
## dataset.Type.1 dataset.Type.2 region Freq
## Bug Flying Sinnoh 4
## Normal Flying Sinnoh 4
## Poison Dark Sinnoh 3
## Dragon Ground Sinnoh 3
## Rock Steel Sinnoh 3
## Fire Fighting Sinnoh 2
## dataset.Type.1 dataset.Type.2 region Freq
## Normal Flying Unova 5
## Ground Dark Unova 3
## Dark Dragon Unova 3
## Ghost Fire Unova 3
## Psychic Flying Unova 3
## Bug Grass Unova 3
## dataset.Type.1 dataset.Type.2 region Freq
## Ghost Grass Kalos 4
## Steel Ghost Kalos 3
## Flying Dragon Kalos 2
## Rock Dragon Kalos 2
## Fire Flying Kalos 2
## Rock Ice Kalos 2
The previous figure shows that the Unova region has the most dual type Pokémon and Kalos has the least.
The next and last figure of this section shows the frequency of dual type Pokémon per each unique type splitted by generation. The x axis shows the different types, the y axis the frequency and each colored line represents a region. For example, there are 15 Bug Pokémon with a secondary type originally from Unova.
This section is in some way different than the previous ones. Here we will introduce a classification model called a decision tree. A decision tree is a prediction model that uses a flow-chart structure to reach certain conclusions about a dataset based on previous observations. This simple decision tree was made to check if there is any relation between dual types Pokémon and their region of origin (Kanto, Johto, Hoenn, Sinnoh, Unova and Kalos). For example, are most Normal-Flying Pokémon from the Kanto region?
What we did in this decision tree model was to split the dataset into a training set and a test set. The training set was used to teach the model about the dual types Pokémon and their original region and the test set for detecting how well our model can “guess” the original region of a certain dual type Pokémon based on what it learned.
Note that this model is not optimized at all. The purpose of doing this is just to see if there is any correlation at all.
##
## Classification tree:
## tree(formula = region ~ ., data = types, subset = train)
## Number of terminal nodes: 18
## Residual mean deviance: 2.249 = 409.4 / 182
## Misclassification error rate: 0.465 = 93 / 200
## region
## tree.pred Hoenn Johto Kalos Kanto Sinnoh Unova
## Hoenn 9 3 5 6 4 5
## Johto 0 1 2 2 2 0
## Kalos 4 0 10 4 3 1
## Kanto 13 8 2 12 5 6
## Sinnoh 1 3 2 0 4 1
## Unova 1 6 2 2 4 14
If we count the correct predictions (the numbers in the diagonal) and using length of the test set (147) we get a correct prediction percentage of 34.0136054 which means that 1 out of 3 dual types Pokémon gets a correct prediction of its region based on its dual type. A 33% correct rate does not say much about this model; as seen from the table there is some connection in Kanto dual type Pokémon and Unova but generally speaking my interpretation is that there is not a constant connection between a dual type Pokémon and its origin region.
The next figure is a representation of the tree. Each internal node represents a test on the attribute, which in this case is the primary type and the secondary type of the Pokémon. For example, at the first internal node we have all the secondary types except for Electric, Fire, Poison and Steel. At this node we ask, is our Pokémon secondary type any of these? If the answer if yes, we take the left route otherwise the right now. Suppose the answer to this question is no, so we take the right branch. At this new branch we ask, is our Pokémon secondary type either Electric, Fire or Steel? If the answer is yes we take the left branch and performed another test, otherwise we take the right split and the Pokémon is categorized as Kanto. In this exact case, the only remaining secondary type not seen in the branches is Poison, thus according to this tree, a Pokémon that has Poison as a secondary type comes from the Kanto region. In some sense this is correct because out of all the 31 Pokémon that has secondary Poison type, 19 comes from the Kanto region (61.3%), 3 from Johto (9.7%), 2 from Hoenn (6.5%), 2 from Sinnoh (6.5%) and 5 from Unova (16%).