Visual Analysis of Pokemon Dataset

Pokemon Attributes :

  • Name: Name of each pokemon
  • base_experience : Base Experience of Pokemon
  • height : Height Of pokemon
  • weight : Weight Of pokemon
  • Type 1: Each pokemon has a type, this determines weakness/resistance to attacks
  • Type 2: Some pokemon are dual type and have 2
  • Abilities : (1,2,Hidden) Abilities of pokemon determines behavior or responding to certain conditions such as terrain,stat change etc.
  • Total: sum of all stats that come after this, a general guide to how strong a pokemon is
  • HP: hit points, or health, defines how much damage a pokemon can withstand before fainting
  • Attack: the base modifier for normal attacks (eg. Scratch, Punch)
  • Defense: the base damage resistance against normal attacks
  • SP Atk: special attack, the base modifier for special attacks (e.g. fire blast, bubble beam)
  • SP Def: the base damage resistance against special attacks
  • Speed: determines which pokemon attacks first each round

Importing Modules :

# Ignore warnings
import warnings
warnings.filterwarnings('ignore')

# Handle table-like data and matrices
import numpy as np
import pandas as pd

# Modelling Algorithms
from sklearn.linear_model import LogisticRegression
from sklearn.svm import SVC, LinearSVC
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.naive_bayes import GaussianNB
from sklearn.linear_model import Perceptron
from sklearn.linear_model import SGDClassifier
from sklearn.tree import DecisionTreeClassifier

# Modelling Helpers
from sklearn.preprocessing import Imputer , Normalizer , scale
from sklearn.cross_validation import train_test_split , StratifiedKFold
from sklearn.feature_selection import RFECV

# Visualisation
import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab
import seaborn as sns

# Configure visualisations
%matplotlib inline
mpl.style.use( 'ggplot' )
sns.set_style( 'white' )
pylab.rcParams[ 'figure.figsize' ] = 8 , 6

Dataset Description :

pokemons.describe()
id species_id height weight base_experience
count 721.00000 721.00000 721.000000 721.000000 721.000000
mean 361.00000 361.00000 11.399445 568.753121 142.081831
std 208.27906 208.27906 10.304594 901.054114 74.391851
min 1.00000 1.00000 1.000000 1.000000 36.000000
25% 181.00000 181.00000 6.000000 94.000000 66.000000
50% 361.00000 361.00000 10.000000 280.000000 147.000000
75% 541.00000 541.00000 14.000000 610.000000 178.000000
max 721.00000 721.00000 145.000000 9500.000000 608.000000
attack defense hp special_attack special_defense
count 721.000000 721.000000 721.000000 721.000000 721.000000
mean 74.986130 70.836338 68.380028 68.710125 69.319001
std 28.950913 29.333681 25.848272 28.748150 27.057671
min 5.000000 5.000000 1.000000 10.000000 20.000000
25% 53.000000 50.000000 50.000000 45.000000 50.000000
50% 74.000000 65.000000 65.000000 65.000000 65.000000
75% 95.000000 85.000000 80.000000 90.000000 85.000000
max 165.000000 230.000000 255.000000 154.000000 230.000000

speed generation_id evolves_from_species_id evolution_chain_id shape_id
count 721.000000 721.000000 355.000000 721.000000 721.000000
mean 65.714286 3.323162 333.819718 175.660194 7.604716
std 27.277920 1.669873 211.629743 110.757190 3.435587
min 5.000000 1.000000 1.000000 1.000000 1.000000
25% 45.000000 2.000000 139.000000 76.000000 6.000000
50% 65.000000 3.000000 315.000000 168.000000 8.000000
75% 85.000000 5.000000 526.000000 276.000000 10.000000
max 160.000000 6.000000 714.000000 373.000000 14.000000

Correlation Heat map :

plot_correlation_map( pokemons )

Demography of Pokemons :

Primary type  :

pokemons['type_1'].value_counts()
labels = ('Water', 'Normal', 'Grass', 'Bug', 'Psychic', 'Fire', 'Electric', 'Rock','Ground','Dark'
,'Dragon','Poison','Fighting','Ice','Steel','Ghost','Fairy','Flying')
sizes = [105, 93, 66, 63, 47, 47, 41, 36, 30,28,28,25,24,23,23,22,17,3]
colors = ['#2196f3', '#ffc849', '#9deb3a', '#fbff00', '#e000ff', '#ff6800', '#fffb00', '#ad7102','#fecb6a','#5a5a5a', '#ec0000', '#9e00ff', '#c11e1e', '#1eaac1', '#ccc5c5' , '#6468ff', '#fd6cff', '#6cbcff']
explode = (0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2 ,0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2) # only "explode" the 3rd slice 
plt.pie(sizes, explode=explode, labels=labels, colors=colors,
 autopct='%1.1f%%', shadow=True, startangle=90)
plt.axis('equal')
plt.title("Percentage of Different Types of Pokemon")
plt.plot()
fig=plt.gcf()
fig.set_size_inches(7,7)
plt.show()
water       105
normal       93
grass        66
bug          63
fire         47
psychic      47
rock         41
electric     36
ground       30
poison       28
dark         28
fighting     25
dragon       24
ice          23
ghost        23
steel        22
fairy        17
flying        3

Secondary Type :

flying 87 
poison 31
ground 30
psychic 27
fighting 19
steel 19
fairy 18
grass 18
dark 16
dragon 14
rock 14
water 13
ghost 12
ice 10
fire 9
electric 6
normal 4
bug 3

Stats Comparison between Legendary and Non-Legendary  Pokemons :

plot_distribution( pokemons , var = 'Attack' , target = 'Generation' , row = 'Legendary' )
plot_distribution( pokemons , var = 'Defense' , target = 'Generation' , row = 'Legendary' )
plot_distribution( pokemons , var = 'Sp. Atk' , target = 'Generation' , row = 'Legendary' )
plot_distribution( pokemons , var = 'Sp. Def' , target = 'Generation' , row = 'Legendary' )
plot_distribution( pokemons , var = 'Speed' , target = 'Generation' , row = 'Legendary' )

This slideshow requires JavaScript.

 

Leave a Reply Here