Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 33 additions & 19 deletions notebook/1 . EDA STUDENT PERFORMANCE .ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1412,14 +1412,32 @@
"#### BIVARIATE ANALYSIS ( Is gender has any impact on student's performance ? ) "
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "526d49f9",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.preprocessing import LabelEncoder\n"

"# Create an instance of LabelEncoder\n"
"label_encoder = LabelEncoder()\n"

"# Fit and transform the 'gender' column\n"
"df['gender_encoded'] = label_encoder.fit_transform(df['gender'])\n"
"df['gender_encoded']\n"
"non_numeric_data = pd.to_numeric(df['gender_encoded'],errors='coerce').isna().any() # to check is there any numeric data non_numeric_data\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "526d49f9",
"metadata": {},
"outputs": [],
"source": [
"gender_group = df.groupby('gender').mean()\n",
"gender_group = df.groupby('gender_encoded').mean()\n",
"gender_group"
]
},
Expand All @@ -1430,24 +1448,20 @@
"metadata": {},
"outputs": [],
"source": [
"plt.figure(figsize=(10, 8))\n",
"\n",
"X = ['Total Average','Math Average']\n",
"\n",
"\n",
"female_scores = [gender_group['average'][0], gender_group['math score'][0]]\n",
"male_scores = [gender_group['average'][1], gender_group['math score'][1]]\n",
"\n",
"X_axis = np.arange(len(X))\n",
" \n",
"plt.bar(X_axis - 0.2, male_scores, 0.4, label = 'Male')\n",
"plt.bar(X_axis + 0.2, female_scores, 0.4, label = 'Female')\n",
" \n",
"plt.xticks(X_axis, X)\n",
"plt.ylabel(\"Marks\")\n",
"plt.title(\"Total average v/s Math average marks of both the genders\", fontweight='bold')\n",
"plt.legend()\n",
"plt.show()"
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"plt.figure(figsize=(10, 8))\n",
"X = ['Total Average', 'Math Average']\n",
"female_scores = [df.loc[0, 'average'], df.loc[0, 'math_score']]\n",
"male_scores = [df.loc[1, 'average'], df.loc[1, 'math_score']]\n",
"X_axis = np.arange(len(X)) \n",
"plt.bar(X_axis - 0.2, male_scores, 0.4, label='Male') \n",
"plt.bar(X_axis + 0.2, female_scores, 0.4, label='Female') \n",
"plt.xticks(X_axis, X) \n",
"plt.ylabel("Marks") \n",
"plt.title("Total average v/s Math average marks of both genders",fontweight='bold') \n",
"plt.legend() \n",
"plt.show()"
]
},
{
Expand Down