To answer that we created a scatter plot of their HP vs their attack. We expect strong pokemon to have both lots of HP and a strong attack. Altair allows us to easily implement a selection tool that helps us look at subsets of our data. That combined with a bar plot showing the distribution of Pokemon types in our selection helps us find the strongest type.
Creating plots like this can be done in just a few lines. Now what altair does is it creates a JSON description of the plot that is Human (and Vega) readable and may look like this:
{
"config": {"view": {"width": 400, "height": 300}},
"data": {
"values": [
{
"Type 1": "Bug",
"Total": 0,
"HP": 0,
"Attack": 9.44160272804774,
"Defense": 10.877698905649218,
"Sp. Atk": 0.7584541062801904,
"Sp. Def": 2.0471014492753596,
"Speed": 13.092924126172207
}
]
},
"mark": "point",
"encoding": {
"color": {"type": "nominal", "field": "Type 1"},
"x": {"type": "quantitative", "field": "HP"},
"y": {"type": "quantitative", "field": "Attack"}
},
"$schema": "https://vega.github.io/schema/vega-lite/v2.4.1.json"
}
There is a Vega Editor that allows you to edit and render JSONs like this in your browser. You may also notice that there are type declarations like nominal and quantitative. One of the main ideas behind projects like Altair is to create visualizations declarative, which means instead of telling your plotting tool how data should be treated in what way, you simply declare that your data is e.g. quantitative or temporal and your plotting tool knows what to do.Now back to our question. By looking at our data we discovered that there appear to be a lot of strong dragon Pokemon. To further investigate this we split our data by the type, computed the means and combined the data back together using pandas groupby method. Here is how our final scatter plot looks like:
We also uploaded interactive versions of our plots to our github.


Keine Kommentare:
Kommentar veröffentlichen