aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2024-02-23 22:36:01 -0800
committerGravatar GitHub <noreply@github.com> 2024-02-23 22:36:01 -0800
commit45b11b87c29c2c391a98f0a0209eb7a3e3b1efbd (patch)
tree75fddeb8cb00fd9e48d9558b0fa69c710557ec10
parent9b2ac979ef4f2f679a3efdfeff786e697c066cd3 (diff)
parent2758560e8a7ed84d3cc1d68e4c77f6880bbb62a1 (diff)
downloadCS105MiniProject-45b11b87c29c2c391a98f0a0209eb7a3e3b1efbd.tar.gz
CS105MiniProject-45b11b87c29c2c391a98f0a0209eb7a3e3b1efbd.tar.zst
CS105MiniProject-45b11b87c29c2c391a98f0a0209eb7a3e3b1efbd.zip
Merge pull request #28 from ansg191/hypot3
Completes Hypothesis 3
-rw-r--r--CS105MiniProject.ipynb128
1 files changed, 98 insertions, 30 deletions
diff --git a/CS105MiniProject.ipynb b/CS105MiniProject.ipynb
index 2bbfd79..3fc4eb7 100644
--- a/CS105MiniProject.ipynb
+++ b/CS105MiniProject.ipynb
@@ -31,8 +31,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:10.685764Z",
- "start_time": "2024-02-24T06:19:10.663631Z"
+ "end_time": "2024-02-24T06:34:39.410627Z",
+ "start_time": "2024-02-24T06:34:39.389092Z"
}
},
"outputs": [
@@ -79,8 +79,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:10.697650Z",
- "start_time": "2024-02-24T06:19:10.686423Z"
+ "end_time": "2024-02-24T06:34:39.422395Z",
+ "start_time": "2024-02-24T06:34:39.411276Z"
}
},
"outputs": [
@@ -140,8 +140,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:10.705920Z",
- "start_time": "2024-02-24T06:19:10.699096Z"
+ "end_time": "2024-02-24T06:34:39.430868Z",
+ "start_time": "2024-02-24T06:34:39.423750Z"
}
},
"outputs": [
@@ -170,8 +170,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:10.712944Z",
- "start_time": "2024-02-24T06:19:10.706544Z"
+ "end_time": "2024-02-24T06:34:39.445408Z",
+ "start_time": "2024-02-24T06:34:39.434297Z"
}
},
"outputs": [
@@ -206,8 +206,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:10.895599Z",
- "start_time": "2024-02-24T06:19:10.713548Z"
+ "end_time": "2024-02-24T06:34:39.625934Z",
+ "start_time": "2024-02-24T06:34:39.447091Z"
}
},
"outputs": [
@@ -277,8 +277,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:11.134307Z",
- "start_time": "2024-02-24T06:19:10.902740Z"
+ "end_time": "2024-02-24T06:34:39.852958Z",
+ "start_time": "2024-02-24T06:34:39.628331Z"
}
},
"id": "c533e52f7d64a4df",
@@ -320,8 +320,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:11.314257Z",
- "start_time": "2024-02-24T06:19:11.136170Z"
+ "end_time": "2024-02-24T06:34:39.957772Z",
+ "start_time": "2024-02-24T06:34:39.855743Z"
}
},
"id": "450665f2272bb3a2",
@@ -365,8 +365,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:11.453484Z",
- "start_time": "2024-02-24T06:19:11.316819Z"
+ "end_time": "2024-02-24T06:34:40.102959Z",
+ "start_time": "2024-02-24T06:34:39.964444Z"
}
},
"id": "1a704a4702ea3f9c",
@@ -411,8 +411,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:11.835916Z",
- "start_time": "2024-02-24T06:19:11.455489Z"
+ "end_time": "2024-02-24T06:34:40.466605Z",
+ "start_time": "2024-02-24T06:34:40.108432Z"
}
},
"id": "ae23070caa8a3c88",
@@ -467,8 +467,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:11.953795Z",
- "start_time": "2024-02-24T06:19:11.836719Z"
+ "end_time": "2024-02-24T06:34:40.577484Z",
+ "start_time": "2024-02-24T06:34:40.487032Z"
}
},
"id": "464b4dec962ea0ae",
@@ -516,8 +516,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:12.117410Z",
- "start_time": "2024-02-24T06:19:11.957279Z"
+ "end_time": "2024-02-24T06:34:40.735256Z",
+ "start_time": "2024-02-24T06:34:40.578565Z"
}
},
"id": "101f55892c052d46",
@@ -582,8 +582,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:12.131263Z",
- "start_time": "2024-02-24T06:19:12.118937Z"
+ "end_time": "2024-02-24T06:34:40.749833Z",
+ "start_time": "2024-02-24T06:34:40.736572Z"
}
},
"id": "24d1f01fdd4ca1d6",
@@ -618,8 +618,8 @@
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:12.135913Z",
- "start_time": "2024-02-24T06:19:12.132121Z"
+ "end_time": "2024-02-24T06:34:40.753936Z",
+ "start_time": "2024-02-24T06:34:40.750695Z"
}
},
"id": "fd3e73d9f461afd1",
@@ -639,18 +639,86 @@
"id": "32eff09a99bfb3c7"
},
{
+ "cell_type": "markdown",
+ "source": [
+ "### Hypothesis 3: People who live with more people will have a higher GPA on average."
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "56a4b6a6c1e05d81"
+ },
+ {
+ "cell_type": "code",
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "Average Household Size: 3.826923076923077\n",
+ "Average GPA: 3.6520247933884296\n",
+ "Pearson Correlation Coefficient: -0.2010052294084673\n"
+ ]
+ }
+ ],
+ "source": [
+ "hyp3_major_table = pd.crosstab(df.iloc[:, 5], df.iloc[:, 6], margins=True, margins_name='Total')\n",
+ "average_household_size = df.iloc[:, 5].mean(skipna=True)\n",
+ "average_gpa = df.iloc[:, 6].mean(skipna=True)\n",
+ "\n",
+ "print(\"Average Household Size:\", average_household_size)\n",
+ "print(\"Average GPA:\", average_gpa)\n",
+ "numerator = 0\n",
+ "denom_x = 0\n",
+ "denom_y = 0\n",
+ "for i in range(260):\n",
+ " x_i = df.iloc[i, 5]\n",
+ " y_i = df.iloc[i, 6]\n",
+ " if not pd.isna(x_i) and not pd.isna(y_i): # Check for NaN values\n",
+ " numerator += (x_i - average_household_size) * (y_i - average_gpa)\n",
+ " denom_x += (x_i - average_household_size)**2\n",
+ " denom_y += (y_i - average_gpa)**2\n",
+ "\n",
+ "# Calculate Pearson correlation coefficient\n",
+ "pearson_coefficient = (numerator / ((denom_x * denom_y)**0.5))\n",
+ "print(\"Pearson Correlation Coefficient:\", pearson_coefficient)"
+ ],
+ "metadata": {
+ "collapsed": false,
+ "ExecuteTime": {
+ "end_time": "2024-02-24T06:34:40.780079Z",
+ "start_time": "2024-02-24T06:34:40.755414Z"
+ }
+ },
+ "id": "b513f8e8241e86e5",
+ "execution_count": 14
+ },
+ {
+ "cell_type": "markdown",
+ "source": [
+ "With a Pearson Correlation Coefficient of -0.2, there is a slight negative correlation between household size and average GPA.\n",
+ "Students who live alone or with fewer people perform slightly better than those with more roommates.\n",
+ "\n",
+ "This goes against our hypothesis that people living with more people will have a higher GPA."
+ ],
+ "metadata": {
+ "collapsed": false
+ },
+ "id": "79b83b5ec3c1f9c5"
+ },
+ {
"cell_type": "code",
"outputs": [],
"source": [],
"metadata": {
"collapsed": false,
"ExecuteTime": {
- "end_time": "2024-02-24T06:19:12.138622Z",
- "start_time": "2024-02-24T06:19:12.136918Z"
+ "end_time": "2024-02-24T06:34:40.782502Z",
+ "start_time": "2024-02-24T06:34:40.780918Z"
}
},
- "id": "b513f8e8241e86e5",
- "execution_count": 13
+ "id": "55fb116c79c479a1",
+ "execution_count": 14
}
],
"metadata": {