diff --git a/your-code/main.ipynb b/your-code/main.ipynb
index cdc1acb..cd527ac 100644
--- a/your-code/main.ipynb
+++ b/your-code/main.ipynb
@@ -14,12 +14,13 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"# import numpy and pandas\n",
- "\n"
+ "import numpy as np\n",
+ "import pandas as pd\n"
]
},
{
@@ -35,7 +36,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
@@ -53,12 +54,334 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 36,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/html": [
+ "
\n",
+ "\n",
+ "
\n",
+ " \n",
+ " \n",
+ " | \n",
+ " # | \n",
+ " Name | \n",
+ " Type 1 | \n",
+ " Type 2 | \n",
+ " Total | \n",
+ " HP | \n",
+ " Attack | \n",
+ " Defense | \n",
+ " Sp. Atk | \n",
+ " Sp. Def | \n",
+ " Speed | \n",
+ " Generation | \n",
+ " Legendary | \n",
+ "
\n",
+ " \n",
+ " \n",
+ " \n",
+ " | 0 | \n",
+ " 1 | \n",
+ " Bulbasaur | \n",
+ " Grass | \n",
+ " Poison | \n",
+ " 318 | \n",
+ " 45 | \n",
+ " 49 | \n",
+ " 49 | \n",
+ " 65 | \n",
+ " 65 | \n",
+ " 45 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 1 | \n",
+ " 2 | \n",
+ " Ivysaur | \n",
+ " Grass | \n",
+ " Poison | \n",
+ " 405 | \n",
+ " 60 | \n",
+ " 62 | \n",
+ " 63 | \n",
+ " 80 | \n",
+ " 80 | \n",
+ " 60 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 2 | \n",
+ " 3 | \n",
+ " Venusaur | \n",
+ " Grass | \n",
+ " Poison | \n",
+ " 525 | \n",
+ " 80 | \n",
+ " 82 | \n",
+ " 83 | \n",
+ " 100 | \n",
+ " 100 | \n",
+ " 80 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 3 | \n",
+ " 3 | \n",
+ " VenusaurMega Venusaur | \n",
+ " Grass | \n",
+ " Poison | \n",
+ " 625 | \n",
+ " 80 | \n",
+ " 100 | \n",
+ " 123 | \n",
+ " 122 | \n",
+ " 120 | \n",
+ " 80 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 4 | \n",
+ " 4 | \n",
+ " Charmander | \n",
+ " Fire | \n",
+ " NaN | \n",
+ " 309 | \n",
+ " 39 | \n",
+ " 52 | \n",
+ " 43 | \n",
+ " 60 | \n",
+ " 50 | \n",
+ " 65 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 5 | \n",
+ " 5 | \n",
+ " Charmeleon | \n",
+ " Fire | \n",
+ " NaN | \n",
+ " 405 | \n",
+ " 58 | \n",
+ " 64 | \n",
+ " 58 | \n",
+ " 80 | \n",
+ " 65 | \n",
+ " 80 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 6 | \n",
+ " 6 | \n",
+ " Charizard | \n",
+ " Fire | \n",
+ " Flying | \n",
+ " 534 | \n",
+ " 78 | \n",
+ " 84 | \n",
+ " 78 | \n",
+ " 109 | \n",
+ " 85 | \n",
+ " 100 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 7 | \n",
+ " 6 | \n",
+ " CharizardMega Charizard X | \n",
+ " Fire | \n",
+ " Dragon | \n",
+ " 634 | \n",
+ " 78 | \n",
+ " 130 | \n",
+ " 111 | \n",
+ " 130 | \n",
+ " 85 | \n",
+ " 100 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 8 | \n",
+ " 6 | \n",
+ " CharizardMega Charizard Y | \n",
+ " Fire | \n",
+ " Flying | \n",
+ " 634 | \n",
+ " 78 | \n",
+ " 104 | \n",
+ " 78 | \n",
+ " 159 | \n",
+ " 115 | \n",
+ " 100 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 9 | \n",
+ " 7 | \n",
+ " Squirtle | \n",
+ " Water | \n",
+ " NaN | \n",
+ " 314 | \n",
+ " 44 | \n",
+ " 48 | \n",
+ " 65 | \n",
+ " 50 | \n",
+ " 64 | \n",
+ " 43 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 10 | \n",
+ " 8 | \n",
+ " Wartortle | \n",
+ " Water | \n",
+ " NaN | \n",
+ " 405 | \n",
+ " 59 | \n",
+ " 63 | \n",
+ " 80 | \n",
+ " 65 | \n",
+ " 80 | \n",
+ " 58 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 11 | \n",
+ " 9 | \n",
+ " Blastoise | \n",
+ " Water | \n",
+ " NaN | \n",
+ " 530 | \n",
+ " 79 | \n",
+ " 83 | \n",
+ " 100 | \n",
+ " 85 | \n",
+ " 105 | \n",
+ " 78 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 12 | \n",
+ " 9 | \n",
+ " BlastoiseMega Blastoise | \n",
+ " Water | \n",
+ " NaN | \n",
+ " 630 | \n",
+ " 79 | \n",
+ " 103 | \n",
+ " 120 | \n",
+ " 135 | \n",
+ " 115 | \n",
+ " 78 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 13 | \n",
+ " 10 | \n",
+ " Caterpie | \n",
+ " Bug | \n",
+ " NaN | \n",
+ " 195 | \n",
+ " 45 | \n",
+ " 30 | \n",
+ " 35 | \n",
+ " 20 | \n",
+ " 20 | \n",
+ " 45 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ " | 14 | \n",
+ " 11 | \n",
+ " Metapod | \n",
+ " Bug | \n",
+ " NaN | \n",
+ " 205 | \n",
+ " 50 | \n",
+ " 20 | \n",
+ " 55 | \n",
+ " 25 | \n",
+ " 25 | \n",
+ " 30 | \n",
+ " 1 | \n",
+ " False | \n",
+ "
\n",
+ " \n",
+ "
\n",
+ "
"
+ ],
+ "text/plain": [
+ " # Name Type 1 Type 2 Total HP Attack Defense \\\n",
+ "0 1 Bulbasaur Grass Poison 318 45 49 49 \n",
+ "1 2 Ivysaur Grass Poison 405 60 62 63 \n",
+ "2 3 Venusaur Grass Poison 525 80 82 83 \n",
+ "3 3 VenusaurMega Venusaur Grass Poison 625 80 100 123 \n",
+ "4 4 Charmander Fire NaN 309 39 52 43 \n",
+ "5 5 Charmeleon Fire NaN 405 58 64 58 \n",
+ "6 6 Charizard Fire Flying 534 78 84 78 \n",
+ "7 6 CharizardMega Charizard X Fire Dragon 634 78 130 111 \n",
+ "8 6 CharizardMega Charizard Y Fire Flying 634 78 104 78 \n",
+ "9 7 Squirtle Water NaN 314 44 48 65 \n",
+ "10 8 Wartortle Water NaN 405 59 63 80 \n",
+ "11 9 Blastoise Water NaN 530 79 83 100 \n",
+ "12 9 BlastoiseMega Blastoise Water NaN 630 79 103 120 \n",
+ "13 10 Caterpie Bug NaN 195 45 30 35 \n",
+ "14 11 Metapod Bug NaN 205 50 20 55 \n",
+ "\n",
+ " Sp. Atk Sp. Def Speed Generation Legendary \n",
+ "0 65 65 45 1 False \n",
+ "1 80 80 60 1 False \n",
+ "2 100 100 80 1 False \n",
+ "3 122 120 80 1 False \n",
+ "4 60 50 65 1 False \n",
+ "5 80 65 80 1 False \n",
+ "6 109 85 100 1 False \n",
+ "7 130 85 100 1 False \n",
+ "8 159 115 100 1 False \n",
+ "9 50 64 43 1 False \n",
+ "10 65 80 58 1 False \n",
+ "11 85 105 78 1 False \n",
+ "12 135 115 78 1 False \n",
+ "13 20 20 45 1 False \n",
+ "14 25 25 30 1 False "
+ ]
+ },
+ "execution_count": 36,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "pokemon.head(15)\n"
]
},
{
@@ -70,12 +393,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 37,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Legendary\n",
+ "False 735\n",
+ "True 65\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 37,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "legendary_counts = pokemon['Legendary'].value_counts()\n",
+ "\n",
+ "legendary_counts"
]
},
{
@@ -87,12 +427,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 38,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "legendary_mean = 637.3846153846154\n",
+ "legendary_std = 60.93738905315344\n",
+ "non_legendary_mean = 417.21360544217686\n",
+ "non_legendary_std = 106.76041745713005\n"
+ ]
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "legendary_mean = pokemon[pokemon[\"Legendary\"] == True][\"Total\"].mean()\n",
+ "print(f\"legendary_mean = {legendary_mean}\")\n",
+ "\n",
+ "legendary_std = pokemon[pokemon[\"Legendary\"] == True][\"Total\"].std()\n",
+ "print(f\"legendary_std = {legendary_std}\")\n",
+ "\n",
+ "non_legendary_mean = pokemon[pokemon[\"Legendary\"] == False][\"Total\"].mean()\n",
+ "print(f\"non_legendary_mean = {non_legendary_mean}\")\n",
+ "\n",
+ "non_legendary_std = pokemon[pokemon[\"Legendary\"] == False][\"Total\"].std()\n",
+ "print(f\"non_legendary_std = {non_legendary_std}\")"
]
},
{
@@ -106,12 +467,107 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "# Null Hypothesis (H0): There is no significant difference in the mean total points between Legendary and Non-Legendary Pokémon.\n",
+ "# Alternative Hypothesis (H1): There is a significant difference in the mean total points between Legendary and Non-Legendary Pokémon.\n",
+ "\n",
+ "\n",
+ "from scipy.stats import ttest_ind\n",
+ "\n",
+ "# Separate Total points for Legendary and Non-Legendary\n",
+ "legendary_total = pokemon[pokemon[\"Legendary\"] == True][\"Total\"]\n",
+ "non_legendary_total = pokemon[pokemon[\"Legendary\"] == False][\"Total\"]\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 40,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "156 580\n",
+ "157 580\n",
+ "158 580\n",
+ "162 680\n",
+ "163 780\n",
+ " ... \n",
+ "795 600\n",
+ "796 700\n",
+ "797 600\n",
+ "798 680\n",
+ "799 600\n",
+ "Name: Total, Length: 65, dtype: int64"
+ ]
+ },
+ "execution_count": 40,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "\n",
+ "legendary_total"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 56,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "0 318\n",
+ "1 405\n",
+ "2 525\n",
+ "3 625\n",
+ "4 309\n",
+ " ... \n",
+ "787 494\n",
+ "788 304\n",
+ "789 514\n",
+ "790 245\n",
+ "791 535\n",
+ "Name: Total, Length: 735, dtype: int64"
+ ]
+ },
+ "execution_count": 56,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "\n",
+ "non_legendary_total"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "T-statistic: 25.8335743895517\n",
+ "P-value: 9.357954335957444e-47\n"
+ ]
+ }
+ ],
+ "source": [
+ "# T-test with unequal variances\n",
+ "t_stat, p_value = ttest_ind(legendary_total, non_legendary_total, equal_var=False)\n",
+ "\n",
+ "print(f\"T-statistic: {t_stat}\")\n",
+ "print(f\"P-value: {p_value}\") "
]
},
{
@@ -128,7 +584,8 @@
"outputs": [],
"source": [
"# Your conclusions here:\n",
- "\n"
+ "\n",
+ "# Reject the Null-Hypothesis: There is sufficient evidence to conclude that there is a significant difference in the mean total points between Legendary and Non-Legendary Pokémon.\n"
]
},
{
@@ -142,10 +599,43 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Type 1\n",
+ "Water 112\n",
+ "Normal 98\n",
+ "Grass 70\n",
+ "Bug 69\n",
+ "Psychic 57\n",
+ "Fire 52\n",
+ "Electric 44\n",
+ "Rock 44\n",
+ "Dragon 32\n",
+ "Ground 32\n",
+ "Ghost 32\n",
+ "Dark 31\n",
+ "Poison 28\n",
+ "Steel 27\n",
+ "Fighting 27\n",
+ "Ice 24\n",
+ "Fairy 17\n",
+ "Flying 4\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 67,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "type1_counts = pokemon[\"Type 1\"].value_counts()\n",
+ "\n",
+ "type1_counts\n"
]
},
{
@@ -157,12 +647,68 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 74,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "9 314\n",
+ "10 405\n",
+ "11 530\n",
+ "12 630\n",
+ "59 320\n",
+ " ... \n",
+ "724 314\n",
+ "725 405\n",
+ "726 530\n",
+ "762 330\n",
+ "763 500\n",
+ "Name: Total, Length: 112, dtype: int64"
+ ]
+ },
+ "execution_count": 74,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "water_pokemon_total = pokemon[pokemon[\"Type 1\"] == \"Water\"][\"Total\"]\n",
+ "non_water_pokemon_total = pokemon[pokemon[\"Type 1\"] != \"Water\"][\"Total\"]\n",
+ "\n",
+ "water_pokemon_total\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 77,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "water_total_mean = 430.45535714285717\n",
+ "water_total_std = 113.1882660643146\n",
+ "non_water_total_mean = 435.85901162790697\n",
+ "non_water_total_std = 121.0916823020807\n"
+ ]
+ }
+ ],
+ "source": [
+ "water_total_mean = water_pokemon_total.mean()\n",
+ "print(f\"water_total_mean = {water_total_mean}\")\n",
+ "\n",
+ "water_total_std = water_pokemon_total.std()\n",
+ "print(f\"water_total_std = {water_total_std}\")\n",
+ "\n",
+ "non_water_total_mean = non_water_pokemon_total.mean()\n",
+ "print(f\"non_water_total_mean = {non_water_total_mean}\")\n",
+ "\n",
+ "non_water_total_std = non_water_pokemon_total.std()\n",
+ "print(f\"non_water_total_std = {non_water_total_std}\")"
]
},
{
@@ -174,12 +720,29 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 81,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "T-statistic: -0.4418547448849676\n",
+ "P-value: 0.6587140317488793\n"
+ ]
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "# Null Hypothesis (H0): There is no significant difference in the mean total points between Water-type Pokémon and Non-Water Pokémon.\n",
+ "# Alternative Hypothesis (H1): There is a significant difference in the mean total points.\n",
+ "\n",
+ "\n",
+ "t_stat, p_value = ttest_ind(water_pokemon_total, non_water_pokemon_total, equal_var=True)\n",
+ "\n",
+ "print(f\"T-statistic: {t_stat}\")\n",
+ "print(f\"P-value: {p_value}\") # Scientific notation for small values"
]
},
{
@@ -196,6 +759,8 @@
"outputs": [],
"source": [
"# Your conclusions here:\n",
+ "\n",
+ "# Fail to reject Null Hypothesis: Not enough evidence to say there is a significant difference in the mean total points.\n",
"\n"
]
},
@@ -212,10 +777,31 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "T-statistic: -4.325566393330478\n",
+ "P-value: 1.7140303479358558e-05\n"
+ ]
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "# Null Hypothesis (H0): The defense and attack scores of each Pokemon are equal.\n",
+ "# Alternative Hypothesis (H1): The defense and attack scores of each Pokemon are NOT equal.\n",
+ "\n",
+ "# MY NOTE: Paired (dependant) t-test is needed because we are dealing with paired observations (each Pokémon has both an Attack and Defense score).\n",
+ "\n",
+ "from scipy.stats import ttest_rel\n",
+ "\n",
+ "t_stat, p_value = ttest_rel(pokemon[\"Defense\"], pokemon[\"Attack\"])\n",
+ "\n",
+ "\n",
+ "print(f\"T-statistic: {t_stat}\")\n",
+ "print(f\"P-value: {p_value}\") "
]
},
{
@@ -232,7 +818,8 @@
"outputs": [],
"source": [
"# Your conclusions here:\n",
- "\n"
+ "\n",
+ "# Reject the Null Hypothesis: There is significant statistical evidence that the Defense and Attack scores of Pokémon are not equal."
]
},
{
@@ -246,10 +833,28 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "T-statistic: 0.853986188453353\n",
+ "P-value: 0.3933685997548122\n"
+ ]
+ }
+ ],
"source": [
"# Your code here:\n",
- "\n"
+ "\n",
+ "# Null Hypothesis (H0): The mean Special Attack and Special Defense scores are equal.\n",
+ "# Alternative Hypothesis (H1): The mean Special Attack and Special Defense scores are NOT equal.\n",
+ "\n",
+ "# MY NOTE: Paired (dependant) t-test is needed because we are dealing with paired observations.\n",
+ "\n",
+ "t_stat, p_value = ttest_rel(pokemon[\"Sp. Atk\"], pokemon[\"Sp. Def\"])\n",
+ "\n",
+ "print(f\"T-statistic: {t_stat}\")\n",
+ "print(f\"P-value: {p_value}\") \n"
]
},
{
@@ -266,7 +871,8 @@
"outputs": [],
"source": [
"# Your conclusions here:\n",
- "\n"
+ "\n",
+ "# Failed to reject Null Hypothesis: There is not enough evidence to state that mean Special Attack and Special Defense scores are NOT equal.\n"
]
},
{
@@ -282,10 +888,31 @@
"cell_type": "code",
"execution_count": null,
"metadata": {},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "T-statistic: -0.853986188453353\n",
+ "P-value: 0.3933685997548122\n"
+ ]
+ }
+ ],
"source": [
"# Your code here:\n",
" \n",
+ "from scipy.stats import ttest_1samp\n",
+ "\n",
+ "differences = pokemon[\"Sp. Def\"] - pokemon[\"Sp. Atk\"]\n",
+ "\n",
+ "# one-sample t-test on the differences\n",
+ "t_stat, p_value = ttest_1samp(differences, 0) # Testing if the mean difference is 0\n",
+ "\n",
+ "\n",
+ "print(f\"T-statistic: {t_stat}\")\n",
+ "print(f\"P-value: {p_value}\")\n",
+ "\n",
+ "# Same result!\n",
" "
]
},
@@ -302,7 +929,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 53,
"metadata": {},
"outputs": [],
"source": [
@@ -319,7 +946,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 54,
"metadata": {},
"outputs": [],
"source": [
@@ -336,7 +963,7 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 55,
"metadata": {},
"outputs": [],
"source": [
@@ -368,7 +995,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.9"
+ "version": "3.11.1"
}
},
"nbformat": 4,