diff --git a/your-code/main.ipynb b/your-code/main.ipynb
index cdc1acb..6ba53d3 100644
--- a/your-code/main.ipynb
+++ b/your-code/main.ipynb
@@ -14,12 +14,12 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
- "# import numpy and pandas\n",
- "\n"
+ "import pandas as pd\n",
+ "import numpy as np"
]
},
{
@@ -35,11 +35,10 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
- "# Run this code:\n",
"\n",
"pokemon = pd.read_csv('../pokemon.csv')"
]
@@ -53,12 +52,153 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- "\n"
+ "execution_count": 3,
+ "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",
+ "
\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",
+ "\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 "
+ ]
+ },
+ "execution_count": 3,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "pokemon.head()\n"
]
},
{
@@ -70,11 +210,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
+ "execution_count": 6,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "Legendary\n",
+ "False 735\n",
+ "True 65\n",
+ "Name: count, dtype: int64"
+ ]
+ },
+ "execution_count": 6,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "legendary_non_legendary = pokemon[\"Legendary\"].value_counts()\n",
+ "legendary_non_legendary\n",
"\n"
]
},
@@ -87,12 +242,32 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- "\n"
+ "execution_count": 7,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Mean total for legendary Pokémon: 637.3846153846154\n",
+ "Standard deviation for legendary Pokémon: 60.93738905315346\n",
+ "Mean total for non-legendary Pokémon: 417.21360544217686\n",
+ "Standard deviation for non-legendary Pokémon: 106.7604174571302\n"
+ ]
+ }
+ ],
+ "source": [
+ "legendary_pokemon = pokemon[pokemon['Legendary'] == True]\n",
+ "mean_legendary = legendary_pokemon['Total'].mean()\n",
+ "std_legendary = legendary_pokemon['Total'].std()\n",
+ "\n",
+ "non_legendary_pokemon = pokemon[pokemon['Legendary'] == False]\n",
+ "mean_non_legendary = non_legendary_pokemon['Total'].mean()\n",
+ "std_non_legendary = non_legendary_pokemon['Total'].std()\n",
+ "print(f'Mean total for legendary Pokémon: {mean_legendary}')\n",
+ "print(f'Standard deviation for legendary Pokémon: {std_legendary}')\n",
+ "print(f'Mean total for non-legendary Pokémon: {mean_non_legendary}')\n",
+ "print(f'Standard deviation for non-legendary Pokémon: {std_non_legendary}')\n"
]
},
{
@@ -106,12 +281,35 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- "\n"
+ "execution_count": 8,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The t-statistic is: 25.8335743895517\n",
+ "The p-value is: 9.357954335957446e-47\n",
+ "Reject the null hypothesis: The total points for legendary and non-legendary Pokémon are significantly different.\n"
+ ]
+ }
+ ],
+ "source": [
+ "from scipy import stats\n",
+ "legendary_pokemon = pokemon[pokemon['Legendary'] == True]['Total']\n",
+ "non_legendary_pokemon = pokemon[pokemon['Legendary'] == False]['Total']\n",
+ "\n",
+ "t_statistic, p_value = stats.ttest_ind(legendary_pokemon, non_legendary_pokemon, equal_var=False)\n",
+ "\n",
+ "print(f'The t-statistic is: {t_statistic}')\n",
+ "print(f'The p-value is: {p_value}')\n",
+ "\n",
+ "alpha = 0.05\n",
+ "\n",
+ "if p_value < alpha:\n",
+ " print(\"Reject the null hypothesis: The total points for legendary and non-legendary Pokémon are significantly different.\")\n",
+ "else:\n",
+ " print(\"Fail to reject the null hypothesis: The total points for legendary and non-legendary Pokémon are not significantly different.\")\n"
]
},
{
@@ -127,8 +325,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your conclusions here:\n",
- "\n"
+ "#Since the p-value is much smaller than the chosen significance level (α=0.05), we reject the null hypothesis. This means that there is strong evidence to suggest that the total points for legendary and non-legendary Pokémon are significantly different.\n"
]
},
{
@@ -140,11 +337,43 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 10,
+ "metadata": {},
+ "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": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# Your code here:\n",
+ "type_1_pokemons = pokemon[\"Type 1\"].value_counts()\n",
+ "type_1_pokemons\n",
"\n"
]
},
@@ -157,12 +386,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- "\n"
+ "execution_count": 11,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Mean for Water-type Pokémon: 430.45535714285717\n",
+ "Standard deviation for Water-type Pokémon: 113.18826606431458\n",
+ "Mean for all other Pokémon: 435.85901162790697\n",
+ "Standard deviation for all other Pokémon: 121.09168230208063\n"
+ ]
+ }
+ ],
+ "source": [
+ "water_pokemon = pokemon[pokemon[\"Type 1\"] == \"Water\"][\"Total\"]\n",
+ "other_pokemon = pokemon[pokemon[\"Type 1\"] != \"Water\"][\"Total\"]\n",
+ "\n",
+ "mean_water = water_pokemon.mean()\n",
+ "std_water = water_pokemon.std()\n",
+ "\n",
+ "mean_other = other_pokemon.mean()\n",
+ "std_other = other_pokemon.std()\n",
+ "\n",
+ "print(f'Mean for Water-type Pokémon: {mean_water}')\n",
+ "print(f'Standard deviation for Water-type Pokémon: {std_water}')\n",
+ "print(f'Mean for all other Pokémon: {mean_other}')\n",
+ "print(f'Standard deviation for all other Pokémon: {std_other}')"
]
},
{
@@ -178,8 +429,40 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your code here:\n",
- "\n"
+ "# 1. Null Hypothesis (H₀): The mean total points for Water-type Pokémon is equal to the mean total points for non-Water-type Pokémon.\n",
+ "# 2. Alternative Hypothesis (H₁): The mean total points for Water-type Pokémon is not equal to the mean total points for non-Water-type Pokémon.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The t-statistic is: -0.4418547448849676\n",
+ "The p-value is: 0.6587140317488793\n",
+ "Fail to reject the null hypothesis: The mean total points for Water-type and non-Water-type Pokémon are not significantly different.\n"
+ ]
+ }
+ ],
+ "source": [
+ "water_pokemon = pokemon[pokemon[\"Type 1\"] == \"Water\"][\"Total\"]\n",
+ "non_water_pokemon = pokemon[pokemon[\"Type 1\"] != \"Water\"][\"Total\"]\n",
+ "\n",
+ "t_statistic, p_value = stats.ttest_ind(water_pokemon, non_water_pokemon, equal_var=True)\n",
+ "\n",
+ "print(f'The t-statistic is: {t_statistic}')\n",
+ "print(f'The p-value is: {p_value}')\n",
+ "\n",
+ "alpha = 0.05\n",
+ "\n",
+ "if p_value < alpha:\n",
+ " print(\"Reject the null hypothesis: The mean total points for Water-type and non-Water-type Pokémon are significantly different.\")\n",
+ "else:\n",
+ " print(\"Fail to reject the null hypothesis: The mean total points for Water-type and non-Water-type Pokémon are not significantly different.\")"
]
},
{
@@ -195,8 +478,8 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your conclusions here:\n",
- "\n"
+ "\n",
+ "#The test indicates that there is no significant difference in the mean total points between Water-type and non-Water-type Pokémon in this dataset."
]
},
{
@@ -209,13 +492,40 @@
]
},
{
- "cell_type": "code",
- "execution_count": null,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": [
- "# Your code here:\n",
- "\n"
+ "1. Null Hypothesis (H₀): The mean Defense score is equal to the mean Attack score for the same Pokémon.\n",
+ "2. Alternative Hypothesis (H₁): The mean Defense score is not equal to the mean Attack score for the same Pokémon."
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The t-statistic is: 4.325566393330478\n",
+ "The p-value is: 1.7140303479358558e-05\n",
+ "Reject the null hypothesis: There is a significant difference between the Attack and Defense scores.\n"
+ ]
+ }
+ ],
+ "source": [
+ "t_statistic, p_value = stats.ttest_rel(pokemon[\"Attack\"], pokemon[\"Defense\"])\n",
+ "\n",
+ "print(f'The t-statistic is: {t_statistic}')\n",
+ "print(f'The p-value is: {p_value}')\n",
+ "\n",
+ "alpha = 0.05\n",
+ "\n",
+ "if p_value < alpha:\n",
+ " print(\"Reject the null hypothesis: There is a significant difference between the Attack and Defense scores.\")\n",
+ "else:\n",
+ " print(\"Fail to reject the null hypothesis: There is no significant difference between the Attack and Defense scores.\")"
]
},
{
@@ -226,13 +536,10 @@
]
},
{
- "cell_type": "code",
- "execution_count": null,
+ "cell_type": "markdown",
"metadata": {},
- "outputs": [],
"source": [
- "# Your conclusions here:\n",
- "\n"
+ "There is strong statistical evidence to suggest that there is a significant difference between the Attack and Defense scores of Pokémon in the dataset. Therefore, we can conclude that the mean Attack score is not equal to the mean Defense score for these Pokémon."
]
},
{
@@ -244,12 +551,31 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- "\n"
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The t-statistic is: 0.853986188453353\n",
+ "The p-value is: 0.3933685997548122\n",
+ "Fail to reject the null hypothesis: There is no significant difference between the Sp. Atk and Sp. Def scores.\n"
+ ]
+ }
+ ],
+ "source": [
+ "t_statistic, p_value = stats.ttest_rel(pokemon[\"Sp. Atk\"], pokemon[\"Sp. Def\"])\n",
+ "\n",
+ "print(f'The t-statistic is: {t_statistic}')\n",
+ "print(f'The p-value is: {p_value}')\n",
+ "\n",
+ "alpha = 0.05\n",
+ "\n",
+ "if p_value < alpha:\n",
+ " print(\"Reject the null hypothesis: There is a significant difference between the Sp. Atk and Sp. Def scores.\")\n",
+ "else:\n",
+ " print(\"Fail to reject the null hypothesis: There is no significant difference between the Sp. Atk and Sp. Def scores.\")\n"
]
},
{
@@ -265,8 +591,7 @@
"metadata": {},
"outputs": [],
"source": [
- "# Your conclusions here:\n",
- "\n"
+ "#Since the p-value is greater than 0.05, we fail to reject the null hypothesis. This means there is no statistically significant difference between the mean Special Attack and the mean Special Defense scores in the Pokémon dataset. Therefore, we conclude that, based on this analysis, the Special Attack and Special Defense scores appear to be similar on average and are not significantly different from each other."
]
},
{
@@ -280,12 +605,36 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "# Your code here:\n",
- " \n",
+ "execution_count": 15,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The t-statistic is: 4.325566393330478\n",
+ "The p-value is: 1.7140303479358558e-05\n",
+ "Reject the null hypothesis: There is a significant difference between the Attack and Defense scores.\n"
+ ]
+ }
+ ],
+ "source": [
+ "#Null Hypothesis (H₀): The mean of the differences between the Attack and Defense scores is zero. \n",
+ "#Alternative Hypothesis (H₁): The mean of the differences between the Attack and Defense scores is not zero.\n",
+ "\n",
+ "differences = pokemon[\"Attack\"] - pokemon[\"Defense\"]\n",
+ "\n",
+ "t_statistic, p_value = stats.ttest_1samp(differences, 0)\n",
+ "\n",
+ "print(f'The t-statistic is: {t_statistic}')\n",
+ "print(f'The p-value is: {p_value}')\n",
+ "\n",
+ "alpha = 0.05\n",
+ "\n",
+ "if p_value < alpha:\n",
+ " print(\"Reject the null hypothesis: There is a significant difference between the Attack and Defense scores.\")\n",
+ "else:\n",
+ " print(\"Fail to reject the null hypothesis: There is no significant difference between the Attack and Defense scores.\")\n",
" "
]
},
@@ -354,7 +703,7 @@
],
"metadata": {
"kernelspec": {
- "display_name": "Python 3",
+ "display_name": "base",
"language": "python",
"name": "python3"
},
@@ -368,7 +717,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.6.9"
+ "version": "3.12.7"
}
},
"nbformat": 4,