Commit 9d606fe8 authored by Jonathan Poalses's avatar Jonathan Poalses

refactoring

parent df80236c
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 928, "execution_count": 973,
"outputs": [], "outputs": [],
"source": [ "source": [
"# Importing pyplot so we can visualize things\n", "# Importing pyplot so we can visualize things\n",
...@@ -78,8 +78,8 @@ ...@@ -78,8 +78,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.540587Z", "end_time": "2023-05-26T14:22:29.565097Z",
"start_time": "2023-05-26T14:17:35.461406Z" "start_time": "2023-05-26T14:22:29.468094Z"
} }
} }
}, },
...@@ -95,13 +95,13 @@ ...@@ -95,13 +95,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 929, "execution_count": 974,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "array([0, 1, 2, ..., 8, 9, 8])" "text/plain": "array([0, 1, 2, ..., 8, 9, 8])"
}, },
"execution_count": 929, "execution_count": 974,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -116,15 +116,15 @@ ...@@ -116,15 +116,15 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.542342Z", "end_time": "2023-05-26T14:22:29.588144Z",
"start_time": "2023-05-26T14:17:35.468601Z" "start_time": "2023-05-26T14:22:29.472846Z"
} }
} }
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"As can be seen, the digits dataset contains images labelled with the integers 0 through 9." "As can be seen, the digits dataset contains single dimensional arrays containing the integers 0 through 9, representing the class of the associated image."
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
...@@ -132,13 +132,13 @@ ...@@ -132,13 +132,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 930, "execution_count": 975,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "array([[[ 0., 0., 5., ..., 1., 0., 0.],\n [ 0., 0., 13., ..., 15., 5., 0.],\n [ 0., 3., 15., ..., 11., 8., 0.],\n ...,\n [ 0., 4., 11., ..., 12., 7., 0.],\n [ 0., 2., 14., ..., 12., 0., 0.],\n [ 0., 0., 6., ..., 0., 0., 0.]],\n\n [[ 0., 0., 0., ..., 5., 0., 0.],\n [ 0., 0., 0., ..., 9., 0., 0.],\n [ 0., 0., 3., ..., 6., 0., 0.],\n ...,\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 0., ..., 10., 0., 0.]],\n\n [[ 0., 0., 0., ..., 12., 0., 0.],\n [ 0., 0., 3., ..., 14., 0., 0.],\n [ 0., 0., 8., ..., 16., 0., 0.],\n ...,\n [ 0., 9., 16., ..., 0., 0., 0.],\n [ 0., 3., 13., ..., 11., 5., 0.],\n [ 0., 0., 0., ..., 16., 9., 0.]],\n\n ...,\n\n [[ 0., 0., 1., ..., 1., 0., 0.],\n [ 0., 0., 13., ..., 2., 1., 0.],\n [ 0., 0., 16., ..., 16., 5., 0.],\n ...,\n [ 0., 0., 16., ..., 15., 0., 0.],\n [ 0., 0., 15., ..., 16., 0., 0.],\n [ 0., 0., 2., ..., 6., 0., 0.]],\n\n [[ 0., 0., 2., ..., 0., 0., 0.],\n [ 0., 0., 14., ..., 15., 1., 0.],\n [ 0., 4., 16., ..., 16., 7., 0.],\n ...,\n [ 0., 0., 0., ..., 16., 2., 0.],\n [ 0., 0., 4., ..., 16., 2., 0.],\n [ 0., 0., 5., ..., 12., 0., 0.]],\n\n [[ 0., 0., 10., ..., 1., 0., 0.],\n [ 0., 2., 16., ..., 1., 0., 0.],\n [ 0., 0., 15., ..., 15., 0., 0.],\n ...,\n [ 0., 4., 16., ..., 16., 6., 0.],\n [ 0., 8., 16., ..., 16., 8., 0.],\n [ 0., 1., 8., ..., 12., 1., 0.]]])" "text/plain": "array([[[ 0., 0., 5., ..., 1., 0., 0.],\n [ 0., 0., 13., ..., 15., 5., 0.],\n [ 0., 3., 15., ..., 11., 8., 0.],\n ...,\n [ 0., 4., 11., ..., 12., 7., 0.],\n [ 0., 2., 14., ..., 12., 0., 0.],\n [ 0., 0., 6., ..., 0., 0., 0.]],\n\n [[ 0., 0., 0., ..., 5., 0., 0.],\n [ 0., 0., 0., ..., 9., 0., 0.],\n [ 0., 0., 3., ..., 6., 0., 0.],\n ...,\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 0., ..., 10., 0., 0.]],\n\n [[ 0., 0., 0., ..., 12., 0., 0.],\n [ 0., 0., 3., ..., 14., 0., 0.],\n [ 0., 0., 8., ..., 16., 0., 0.],\n ...,\n [ 0., 9., 16., ..., 0., 0., 0.],\n [ 0., 3., 13., ..., 11., 5., 0.],\n [ 0., 0., 0., ..., 16., 9., 0.]],\n\n ...,\n\n [[ 0., 0., 1., ..., 1., 0., 0.],\n [ 0., 0., 13., ..., 2., 1., 0.],\n [ 0., 0., 16., ..., 16., 5., 0.],\n ...,\n [ 0., 0., 16., ..., 15., 0., 0.],\n [ 0., 0., 15., ..., 16., 0., 0.],\n [ 0., 0., 2., ..., 6., 0., 0.]],\n\n [[ 0., 0., 2., ..., 0., 0., 0.],\n [ 0., 0., 14., ..., 15., 1., 0.],\n [ 0., 4., 16., ..., 16., 7., 0.],\n ...,\n [ 0., 0., 0., ..., 16., 2., 0.],\n [ 0., 0., 4., ..., 16., 2., 0.],\n [ 0., 0., 5., ..., 12., 0., 0.]],\n\n [[ 0., 0., 10., ..., 1., 0., 0.],\n [ 0., 2., 16., ..., 1., 0., 0.],\n [ 0., 0., 15., ..., 15., 0., 0.],\n ...,\n [ 0., 4., 16., ..., 16., 6., 0.],\n [ 0., 8., 16., ..., 16., 8., 0.],\n [ 0., 1., 8., ..., 12., 1., 0.]]])"
}, },
"execution_count": 930, "execution_count": 975,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -150,8 +150,8 @@ ...@@ -150,8 +150,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.543047Z", "end_time": "2023-05-26T14:22:29.588321Z",
"start_time": "2023-05-26T14:17:35.505976Z" "start_time": "2023-05-26T14:22:29.488735Z"
} }
} }
}, },
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 931, "execution_count": 976,
"outputs": [ "outputs": [
{ {
"data": { "data": {
...@@ -203,15 +203,15 @@ ...@@ -203,15 +203,15 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.781215Z", "end_time": "2023-05-26T14:22:29.706103Z",
"start_time": "2023-05-26T14:17:35.523679Z" "start_time": "2023-05-26T14:22:29.500556Z"
} }
} }
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"Unfortunately, this data cannot immediately be used with a classifier, for that we would need to flatten the images, turning it from an 8x8 two dimensional array, into a 64 long one dimensional array." "Unfortunately, this data cannot immediately be used with a classifier, as while it is an 8x8 2D array, the labels are one dimensional arrays; For that we would need to flatten the images, turning it from an 8x8 two-dimensional array, into a 64 long one dimensional array."
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
...@@ -219,13 +219,13 @@ ...@@ -219,13 +219,13 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 932, "execution_count": 977,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "array([[ 0., 0., 5., ..., 0., 0., 0.],\n [ 0., 0., 0., ..., 10., 0., 0.],\n [ 0., 0., 0., ..., 16., 9., 0.],\n ...,\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 2., ..., 12., 0., 0.],\n [ 0., 0., 10., ..., 12., 1., 0.]])" "text/plain": "array([[ 0., 0., 5., ..., 0., 0., 0.],\n [ 0., 0., 0., ..., 10., 0., 0.],\n [ 0., 0., 0., ..., 16., 9., 0.],\n ...,\n [ 0., 0., 1., ..., 6., 0., 0.],\n [ 0., 0., 2., ..., 12., 0., 0.],\n [ 0., 0., 10., ..., 12., 1., 0.]])"
}, },
"execution_count": 932, "execution_count": 977,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
...@@ -238,40 +238,40 @@ ...@@ -238,40 +238,40 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.788274Z", "end_time": "2023-05-26T14:22:29.711689Z",
"start_time": "2023-05-26T14:17:35.784119Z" "start_time": "2023-05-26T14:22:29.708695Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 933, "execution_count": 978,
"outputs": [ "outputs": [
{ {
"data": { "data": {
"text/plain": "True" "text/plain": "True"
}, },
"execution_count": 933, "execution_count": 978,
"metadata": {}, "metadata": {},
"output_type": "execute_result" "output_type": "execute_result"
} }
], ],
"source": [ "source": [
"# Check to see if the first dimension of the data tuples match\n", "# Check to see if the first dimension of the data shape tuples match\n",
"(flat_images.shape[0] == data.target.shape[0])" "(flat_images.shape[0] == data.target.shape[0])"
], ],
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.794289Z", "end_time": "2023-05-26T14:22:29.718913Z",
"start_time": "2023-05-26T14:17:35.789880Z" "start_time": "2023-05-26T14:22:29.712786Z"
} }
} }
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"As can be seen, the image data now matches the target data in size, both being a 1797 long set of arrays." "As can be seen, the image data now matches the target data in size, both being a 1797 long set of one dimensional arrays."
], ],
"metadata": { "metadata": {
"collapsed": false "collapsed": false
...@@ -317,7 +317,7 @@ ...@@ -317,7 +317,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 934, "execution_count": 979,
"outputs": [], "outputs": [],
"source": [ "source": [
"# We'll start by splitting the data into training and testing, going with a 75% train, 25% test split, a 50/50 split, and a 25% train 75% test split.\n", "# We'll start by splitting the data into training and testing, going with a 75% train, 25% test split, a 50/50 split, and a 25% train 75% test split.\n",
...@@ -329,8 +329,8 @@ ...@@ -329,8 +329,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:35.834391Z", "end_time": "2023-05-26T14:22:29.735985Z",
"start_time": "2023-05-26T14:17:35.801032Z" "start_time": "2023-05-26T14:22:29.718702Z"
} }
} }
}, },
...@@ -345,7 +345,7 @@ ...@@ -345,7 +345,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 935, "execution_count": 980,
"outputs": [], "outputs": [],
"source": [ "source": [
"# First the Gaussian Bayes\n", "# First the Gaussian Bayes\n",
...@@ -378,8 +378,8 @@ ...@@ -378,8 +378,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:38.890650Z", "end_time": "2023-05-26T14:22:32.938039Z",
"start_time": "2023-05-26T14:17:35.810495Z" "start_time": "2023-05-26T14:22:29.736114Z"
} }
} }
}, },
...@@ -394,7 +394,7 @@ ...@@ -394,7 +394,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 936, "execution_count": 981,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -423,14 +423,14 @@ ...@@ -423,14 +423,14 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:38.902252Z", "end_time": "2023-05-26T14:22:32.948030Z",
"start_time": "2023-05-26T14:17:38.891565Z" "start_time": "2023-05-26T14:22:32.939526Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 937, "execution_count": 982,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -459,14 +459,14 @@ ...@@ -459,14 +459,14 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:38.996083Z", "end_time": "2023-05-26T14:22:33.016620Z",
"start_time": "2023-05-26T14:17:38.913608Z" "start_time": "2023-05-26T14:22:32.950475Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 938, "execution_count": 983,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -495,22 +495,22 @@ ...@@ -495,22 +495,22 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:39.209822Z", "end_time": "2023-05-26T14:22:33.235186Z",
"start_time": "2023-05-26T14:17:38.996267Z" "start_time": "2023-05-26T14:22:33.018553Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 939, "execution_count": 984,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"0.8377777777777777\n", "0.8711111111111111\n",
"0.8487208008898777\n", "0.8286985539488321\n",
"0.7789317507418397\n" "0.7648367952522255\n"
] ]
} }
], ],
...@@ -531,22 +531,22 @@ ...@@ -531,22 +531,22 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:39.216072Z", "end_time": "2023-05-26T14:22:33.241329Z",
"start_time": "2023-05-26T14:17:39.212717Z" "start_time": "2023-05-26T14:22:33.236558Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 940, "execution_count": 985,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
"output_type": "stream", "output_type": "stream",
"text": [ "text": [
"0.9844444444444445\n", "0.98\n",
"0.9599555061179088\n", "0.9655172413793104\n",
"0.9473293768545994\n" "0.9443620178041543\n"
] ]
} }
], ],
...@@ -567,14 +567,14 @@ ...@@ -567,14 +567,14 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:39.259071Z", "end_time": "2023-05-26T14:22:33.286173Z",
"start_time": "2023-05-26T14:17:39.217697Z" "start_time": "2023-05-26T14:22:33.242848Z"
} }
} }
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 941, "execution_count": 986,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -603,8 +603,8 @@ ...@@ -603,8 +603,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:39.267734Z", "end_time": "2023-05-26T14:22:33.292378Z",
"start_time": "2023-05-26T14:17:39.263262Z" "start_time": "2023-05-26T14:22:33.287825Z"
} }
} }
}, },
...@@ -628,7 +628,7 @@ ...@@ -628,7 +628,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 942, "execution_count": 987,
"outputs": [ "outputs": [
{ {
"name": "stdout", "name": "stdout",
...@@ -750,8 +750,8 @@ ...@@ -750,8 +750,8 @@
"metadata": { "metadata": {
"collapsed": false, "collapsed": false,
"ExecuteTime": { "ExecuteTime": {
"end_time": "2023-05-26T14:17:39.516773Z", "end_time": "2023-05-26T14:22:33.532304Z",
"start_time": "2023-05-26T14:17:39.267995Z" "start_time": "2023-05-26T14:22:33.292768Z"
} }
} }
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment