{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "(ch5)=\n", "# Gradient Descent Variants\n", "\n", "Given the immense importance of the gradient descent algorithm, it has remained an active topic of exploration in order to increase it's speed. This chapter shows the evolution of gradient descent from vanilla batch gradient descent that we developed in the previous chapter to RMSProp. Similar to previous chapter, rather than using libraries, the focus is to implement these variants in python for better learning. \n", "\n", "In order to compare the performance of different versions of gradient descent, I construct a toy dataset, a 2D parabola and demonstrate how each iteration of the algorithm is able to reduce MSE in fewer iterations. \n", "\n", "In order to have a fair comparison, below script construct a toy dataset and the same starting point. Further, I try to keep most of the hyper parameters such as learning rate, stopping criteria, etc. to be static. The toy dataset is a 2D parabola generated using the following equation: $y=100 + 4x_1^2 + 2x_2^2$. The aim of the gradient descent algorithm and it's variant is to estimate the three coefficients: 100, 4 and 2. The three coefficients are represents by vector $\\theta$.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:18.359995Z", "start_time": "2020-05-19T23:32:17.362638Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
x0x1x2y
010.170-0.062100.123288
11-0.934-0.205103.573474
21-0.122-0.602100.784344
31-0.012-0.802101.286984
410.183-0.114100.159948
\n", "
" ], "text/plain": [ " x0 x1 x2 y\n", "0 1 0.170 -0.062 100.123288\n", "1 1 -0.934 -0.205 103.573474\n", "2 1 -0.122 -0.602 100.784344\n", "3 1 -0.012 -0.802 101.286984\n", "4 1 0.183 -0.114 100.159948" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ " \n", " " ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "linkText": "Export to plot.ly", "plotlyServerURL": "https://plot.ly", "showLink": false }, "data": [ { "mode": "markers", "opacity": 0.5, "type": "scatter3d", "x": [ 0.17, -0.934, -0.122, -0.012, 0.183, -0.97, -0.578, -0.053, 0.665, 0.006, 0.686, -0.432, 0.338, 0.66, -0.672, -0.93, 0.066, 0.003, -0.329, -0.845, -0.489, 0.95, 0.951, 0.526, -0.261, -0.909, -0.14, 0.761, -0.716, 0.235, -0.273, -0.219, -0.138, -0.42, 0.693, 0.382, -0.463, -0.065, -0.643, 0.404, -0.38, 0.355, -0.258, -0.728, -0.065, 0.572, 0.761, -0.51, 0.985, -0.1, 0.256, -0.232, -0.91, 0.193, -0.992, -0.518, -0.726, -0.601, 0.927, 0.862, -0.38, 0.098, -0.251, 0.581, 0.839, -0.509, -0.357, 0.365, 0.124, -0.078, -0.108, -0.038, -0.867, 0.337, 0.197, -0.336, 0.728, 0.027, -0.68, 0.724, -0.541, 0.986, -0.155, -0.512, -0.925, -0.935, 0.017, -0.384, 0.675, 0.242, 0.347, -0.853, 0.092, 0.892, 0.751, -0.835, -0.694, -0.213, 0.161, 0.936, -0.234, 0.869, 0.231, -0.694, -0.769, 0.973, 0.588, 0.583, -0.803, -0.096, -0.66, 0.653, -0.609, 0.94, -0.286, -0.113, 0.987, -0.152, -0.088, -0.498, 0.394, -0.438, -0.707, 0.264, 0.068, -0.635, 0.771, -0.756, -0.454, -0.067, -0.381, -0.663, 0.352, 0.328, 0.931, 0.681, -0.644, 0.592, -0.64, -0.017, 0.582, -0.289, -0.329, -0.11, -0.542, -0.99, 0.115, 0.459, -0.911, -0.321, 0.836, -0.346, -0.504, -0.837, -0.464, -0.083, -0.171, 0.193, -0.676, -0.201, 0.885, 0.78, 0.015, 0.379, 0.829, -0.506, 0.507, 0.075, 0.864, -0.444, 0.065, -0.012, 0.233, 0.023, -0.872, -0.66, 0.002, 0.38, -0.055, 0.839, -0.179, -0.722, -0.139, 0.108, 0.197, -0.285, 0.103, -0.206, 0.003, 0.437, -0.661, 0.144, -0.097, -0.798, 0.983, 0.994, -0.15, 0.697, -0.928, 0.785, -0.995, -0.102, 0.096, -0.868, -0.897, -0.284, -0.811, -0.689, -0.778, 0.245, -0.071, 0.706, 0.637, -0.007, -0.715, -0.061, 0.765, -0.107, 0.586, 0.026, 0.889, -0.085, -0.298, 0.487, -0.47, 0.838, 0.615, 0.429, -0.062, -0.134, -0.328, 0.33, 0.064, 0.862, 0.071, -0.686, 0.514, -0.514, -0.339, 0.267, -0.933, 0.407, -0.6, 0.316, 0.852, 0.205, 0.178, 0.698, 0.287, -0.02, -0.949, 0.653, -0.762, 0.97, -0.394, -0.109, 0.743, 0.758, -0.496, 0.47, -0.408, 0.82, -0.818, -0.906, 0.223, 0.87, 0.127, 0.57, 0.97, -0.784, 0.672, -0.416, -0.667, 0.372, -0.023, -0.711, -0.261, 0.218, -0.18, 0.883, 0.611, -0.607, -0.284, -0.627, -0.837, 0.211, -0.602, -0.127, -0.575, -0.804, 0.401, -0.369, 0.817, 0.97, -0.051, 0.767, 0.523, 0.538, 0.423, 0.694, 0.069, 0.479, -0.133, -0.084, 0.36, 0.522, 0.137, -0.573, -0.456, 0.223, -0.254, -0.763, 0.284, 0.603, 0.284, -0.985, -0.571, -0.132, 0.248, -0.164, 0.791, -0.218, 0.784, 0.663, 0.335, -0.591, -0.857, 0.581, -0.133, 0.632, -0.818, 0.687, -0.887, -0.288, -0.479, -0.263, -0.065, -0.132, 0.555, -0.604, 0.287, 0.534, -0.422, -0.045, 0.423, -0.398, 0.037, 0.022, 0.039, 0.859, -0.461, -0.172, -0.096, 0.309, -0.301, -0.286, 0.487, -0.433, -0.012, 0.855, -0.086, 0.747, -0.024, 0.202, -0.018, -0.829, 0.412, 0.105, 0.474, -0.249, 0.64, 0.478, -0.171, 0.865, 0.625, -0.655, 0.975, 0.234, -0.149, 0.475, 0.155, -0.866, 0.219, 0.735, 0.502, 0.713, -0.373, -0.967, 0.211, -0.329, 0.334, -0.341, -0.849, 0.516, -0.188, 0.249, -0.235, -0.422, 0.24, -0.619, -0.507, -0.655, -0.37, -0.805, 0.138, 0.619, 0.673, 0.916, -0.891, -0.55, 0.167, 0.525, -0.849, 0.947, -0.137, -0.608, 0.166, 0.171, -0.101, 0.873, 0.996, 0.647, 0.78, 0.215, -0.968, -0.197, -0.588, -0.306, 0.736, 0.818, 0.176, -0.61, 0.07, 0.91, 0.658, 0.155, 0.564, 0.578, 0.955, 0.711, -0.331, 0.782, -0.903, 0.346, 0.417, 0.184, -0.898, -0.926, 0.157, -0.251, 0.76, 0.915, -0.187, -0.336, 0.231, 0.307, -0.649, 0.582, -0.677, -0.76, 0.241, 0.616, 0.77, -0.293, -0.664, -0.937, 0.48, 0.886, 0.099, 0.046, 0.649, -0.285, -0.82, -0.187, -0.101, 0.183, 0.804, -0.288, -0.878, -0.702, 0.892, 0.772, -0.09, 0.446, -0.036, 0.248, -0.076, 0.479, -0.095, 0.237, -0.642, -0.276, 0.687, -0.133, 0.684, 0.689, -0.297, 0.957, 0.144, 0.05 ], "y": [ -0.062, -0.205, -0.602, -0.802, -0.114, 0.313, -0.688, -0.916, 0.909, 0.761, -0.617, 0.31, 0.298, -0.611, 0.167, -0.122, 0.996, 0.862, 0.625, 0.845, -0.263, 0.145, -0.23, 0.966, -0.898, 0.239, -0.894, -0.662, -0.364, 0.958, 0.945, -0.543, -0.899, 0.187, -0.639, -0.796, 0.302, 0.156, -0.262, 0.712, -0.62, -0.381, 0.94, 0.741, -0.913, -0.19, 0.224, 0.563, -0.122, -0.841, -0.293, 0.555, -0.601, 0.006, -0.667, -0.656, -0.17, 0.656, 0.54, 0.972, -0.042, 0.927, 0.591, -0.328, 0.799, -0.924, -0.646, 0.706, 0.801, -0.64, 0.19, 0.446, -0.139, -0.687, 0.051, 0.314, 0.822, 0.427, -0.198, 0.985, -0.807, -0.188, 0.965, 0.665, -0.758, -0.519, -0.782, -0.135, 0.478, 0.308, -0.364, 0.481, -0.407, 0.092, 0.33, 0.739, 0.825, -0.798, -0.293, 0.707, 0.857, 0.068, 0.269, -0.027, 0.244, -0.5, 0.09, -0.405, -0.975, 0.362, -0.677, 0.973, 0.386, -0.209, 0.42, -0.532, -0.802, 0.045, 0.304, 0.56, -0.029, -0.796, 0.181, 0.855, -0.183, 0.193, -0.554, -0.412, -0.273, -0.858, 0.984, 0.807, -0.614, 0.274, 0.765, 0.143, 0.087, -0.947, -0.847, -0.181, 0.661, -0.936, -0.965, 0.337, 0.714, -0.119, -0.307, 0.707, 0.881, -0.636, 0.488, -0.903, -0.266, -0.336, 0.28, -0.025, 0.612, -0.65, -0.962, -0.579, -0.74, -0.408, 0.964, 0.68, -0.588, -0.495, 0.855, -0.496, -0.209, 0.258, 0.116, 0.197, 0.219, -0.143, 0.789, 0.128, 0.558, -0.937, -0.744, -0.989, -0.748, -0.944, 0.717, -0.888, 0.404, 0.578, 0.571, -0.636, -0.745, 0.419, -0.211, -0.862, -0.971, 0.355, -0.112, 0.512, 0.355, -0.626, 0.278, -0.137, 0.846, -0.903, 0.129, -0.653, -0.892, 0.439, -0.23, 0.184, -0.06, -0.068, -0.313, -0.62, -0.93, -0.184, 0.285, -0.059, 0.001, 0.95, 0.452, 0.46, -0.254, 0.363, -0.856, -0.716, -0.457, -0.482, -0.64, -0.814, -0.057, -0.973, -0.686, -0.431, -0.84, 0.862, 0.074, -0.369, -0.712, 0.57, -0.786, 0.099, -0.754, -0.411, 0.444, 0.266, 0.652, -0.315, 0.658, -0.993, 0.179, -0.469, 0.3, 0.911, 0.543, 0.059, -0.125, 0.793, 0.043, -0.702, 0.46, -0.879, 0.298, -0.885, 0.246, -0.877, 0.323, -0.568, 0.096, -0.971, -0.562, -0.7, -0.374, 0.762, 0.415, 0.724, -0.143, -0.691, 0.758, -0.945, -0.234, 0.057, 0.37, 0.454, -0.764, -0.022, -0.387, -0.05, 0.743, -0.051, -0.641, 0.851, 0.281, -0.712, -0.944, -0.176, 0.247, -0.685, -0.076, 0.344, 0.841, 0.434, 0.69, 0.674, 0.583, -0.634, -0.307, 0.037, 0.37, -0.039, -0.684, -0.912, 0.003, 0.209, -0.203, -0.66, -0.039, 0.437, -0.439, -0.567, 0.013, 0.064, -0.277, 0.338, 0.967, 0.152, 0.574, 0.951, 0.75, 0.139, -0.223, -0.695, 0.824, 0.314, 0.951, -0.352, 0.512, 0.922, -0.351, -0.734, -0.887, -0.063, -0.891, 0.379, -0.315, 0.985, 0.081, 0.068, -0.901, -0.222, 0.249, 0.589, 0.883, 0.611, -0.834, 0.871, 0.429, 0.477, -0.927, -0.739, -0.932, -0.98, 0.906, -0.251, -0.109, -0.547, 0.35, -0.022, 0.708, 0.159, 0.877, 0.355, 0.48, 0.917, -0.815, -0.79, -0.862, 0.964, -0.25, 0.655, -0.067, -0.124, -0.363, -0.637, 0.534, -0.741, 0.564, 0.29, -0.182, 0.112, 0.429, 0.106, -0.606, 0.394, 0.948, 0.527, -0.506, 0.473, -0.681, 0.716, -0.218, -0.554, 0.767, 0.055, 0.225, 0.002, 0.405, 0.699, 0.675, 0.358, -0.21, 0.614, 0.965, -0.61, -0.861, 0.096, 0.493, 0.534, -0.683, 0.748, 0.241, 0.211, 0.102, -0.734, -0.854, 0.345, -0.189, -0.067, -0.819, 0.749, 0.942, -0.572, 0.92, -0.976, -0.07, -0.634, 0.36, -0.651, -0.249, -0.213, 0.294, -0.575, -0.493, -0.317, -0.388, 0.206, -0.47, -0.683, -0.879, -0.008, -0.147, -0.272, -0.301, -0.99, -0.334, 0.38, -0.4, 0.027, 0.838, 0.589, 0.43, 0.795, 0.205, -0.902, -0.168, 0.462, -0.419, -0.06, -0.651, 0.79, 0.688, -0.764, 0.825, 0.717, -0.144, -0.121, -0.811, -0.753, -0.054, -0.67, 0.796, 0.623, -0.85, 0.678, -0.225, 0.088, -0.836, 0.954, -0.986, 0.065, 0.693, 0.483, 0.127, -0.468, 0.168, -0.011, 0.841, 0.771, -0.826, -0.137, 0.934, -0.763 ], "z": [ 100.123288, 103.573474, 100.78434399999999, 101.28698399999999, 100.159948, 103.959538, 102.283024, 101.689348, 103.421462, 101.15838600000001, 102.643762, 100.938696, 100.634584, 102.489042, 101.862114, 103.489368, 102.001456, 101.48612399999999, 101.214214, 104.28415, 101.09482200000001, 103.65205, 103.723404, 102.97301599999999, 101.885292, 103.41936600000001, 101.676872, 103.192972, 102.315616, 102.056428, 102.084166, 100.781542, 101.692578, 100.775538, 102.737638, 101.85092800000001, 101.039884, 100.065572, 101.791084, 101.66675199999999, 101.3464, 100.794422, 102.033456, 103.218098, 101.684038, 101.38093599999999, 102.416836, 101.674338, 103.910668, 101.45456200000001, 100.43384200000001, 100.831346, 104.034802, 100.149068, 104.826034, 101.933968, 102.166104, 102.305476, 104.020516, 104.861744, 100.581128, 101.757074, 100.950566, 101.56541200000001, 104.09248600000001, 102.743876, 101.344428, 101.529772, 101.344706, 100.843536, 100.118856, 100.40360799999999, 103.04539799999999, 101.398214, 100.160438, 100.648776, 103.47130399999999, 100.367574, 101.92800799999999, 104.037154, 102.473222, 103.959472, 101.95855, 101.933026, 104.571628, 104.035622, 101.224204, 100.626274, 102.27946800000001, 100.423984, 100.746628, 103.373158, 100.365154, 103.19958399999999, 102.473804, 103.881142, 103.287794, 101.455084, 100.27538200000001, 104.504082, 101.687922, 103.029892, 100.358166, 101.928002, 102.484516, 104.286916, 101.399176, 101.687606, 104.480486, 100.298952, 102.659058, 103.599094, 101.781516, 103.621762, 100.679984, 100.61712399999999, 105.183084, 100.096466, 100.215808, 101.61921600000001, 100.622626, 102.034608, 102.064918, 101.740834, 100.085474, 101.687398, 102.991596, 102.62563200000001, 100.973522, 101.490284, 102.517156, 103.060774, 101.249608, 100.580488, 104.637494, 101.895942, 101.674082, 103.19547399999999, 103.073218, 100.066678, 102.22873799999999, 102.086276, 102.295414, 100.275538, 102.194648, 103.948722, 100.24139799999999, 101.842422, 104.872006, 101.22115600000001, 103.271872, 102.109682, 101.157576, 103.028068, 101.017984, 100.028806, 100.866052, 100.993996, 103.678792, 100.832086, 104.22810000000001, 102.766528, 101.859492, 101.499364, 103.44045200000001, 101.514194, 102.490246, 100.51453199999999, 103.073346, 100.921672, 100.043812, 100.078194, 100.313078, 100.043014, 104.28657799999999, 101.77516800000001, 100.622744, 102.333538, 101.119172, 104.77192600000001, 101.24717199999999, 103.86740800000001, 101.105462, 101.623744, 100.481668, 100.993068, 100.69451799999999, 100.978736, 101.110086, 101.114998, 101.83672600000001, 101.56903199999999, 101.92331800000001, 102.799266, 103.890244, 104.476432, 100.34205, 102.726988, 103.599304, 102.502438, 105.391532, 101.67243400000001, 100.070146, 103.866514, 104.809764, 100.708066, 102.736684, 101.966596, 102.428336, 100.249348, 100.21610199999999, 102.762544, 103.352876, 100.067908, 102.20735, 100.021846, 102.340902, 101.850796, 101.782192, 100.42590399999999, 103.29031599999999, 100.29243799999999, 101.820688, 101.973988, 101.301298, 103.273624, 102.3321, 102.061356, 100.021874, 101.965282, 101.371528, 100.80712199999999, 101.427584, 104.458264, 100.031116, 102.154706, 102.07067199999999, 101.70658399999999, 101.69527599999999, 100.304758, 104.618988, 101.00043799999999, 101.834272, 100.540936, 103.753824, 100.36654999999999, 100.99266399999999, 103.920914, 100.393558, 100.44152199999999, 103.782404, 103.365478, 102.912274, 103.770562, 100.652194, 101.305222, 102.211894, 103.283864, 101.407264, 102.428882, 100.84346400000001, 104.25605, 102.797528, 104.821602, 100.407574, 103.672848, 100.082948, 103.185282, 104.395288, 103.438624, 102.086088, 101.853512, 102.124006, 101.60188799999999, 100.043014, 102.977046, 101.42161200000001, 101.976146, 100.23911199999999, 103.125254, 101.767084, 101.886028, 101.49001600000001, 101.573484, 103.101814, 100.183084, 102.553714, 100.069718, 102.14426200000001, 104.034066, 100.801126, 101.558532, 104.452228, 103.825552, 100.13242199999999, 103.291606, 101.105668, 101.394448, 102.130278, 102.303256, 100.971244, 101.826316, 100.750534, 100.83213599999999, 100.706898, 101.09267399999999, 100.34887599999999, 101.316358, 101.767456, 101.862404, 100.258082, 102.416038, 100.40504200000001, 102.325636, 100.325666, 104.262838, 101.689606, 100.71267399999999, 100.246354, 100.115776, 102.656182, 100.418584, 104.328802, 101.80448399999999, 101.107852, 103.205926, 104.062796, 101.388886, 100.170214, 102.563746, 104.034448, 102.085068, 104.955878, 100.57958400000001, 101.442052, 101.976844, 100.26330200000001, 101.14720799999999, 102.805638, 101.467202, 101.917238, 101.42790600000001, 100.91078599999999, 101.94855, 100.728838, 100.642864, 101.629078, 100.100504, 100.130086, 103.64536600000001, 102.40946199999999, 100.864978, 101.427976, 101.89920599999999, 100.730486, 100.782242, 102.66733400000001, 101.842198, 101.73782399999999, 104.8449, 101.671256, 102.358038, 100.026066, 100.761634, 100.246296, 102.749932, 101.681504, 100.094662, 102.436962, 100.50005399999999, 102.09920000000001, 102.595714, 101.445414, 104.2411, 103.048588, 103.574692, 103.9275, 101.07707400000001, 100.097782, 100.93325200000001, 100.359638, 103.811362, 100.762156, 103.259062, 101.64420799999999, 102.20167599999999, 100.622764, 103.765444, 100.546166, 100.45543599999999, 101.180696, 100.77559600000001, 104.68061200000001, 101.620482, 100.653448, 100.69546199999999, 101.148422, 101.737648, 100.32544800000001, 102.146476, 102.204774, 101.72215, 100.64885, 102.592108, 100.40422600000001, 102.50984600000001, 102.722966, 103.612552, 103.263724, 101.96399199999999, 101.97400599999999, 101.84670000000001, 104.365846, 103.60566800000001, 100.561174, 102.048968, 101.04320200000001, 101.23597199999999, 100.156966, 103.13755800000001, 103.988872, 102.751948, 103.89223199999999, 100.42295, 103.81953800000001, 100.164214, 102.724498, 101.496546, 103.941512, 103.330864, 101.816704, 103.393552, 100.0294, 104.116312, 101.991056, 100.943702, 101.396386, 101.427074, 103.820972, 102.683334, 100.924342, 102.647074, 103.562724, 100.563736, 101.137356, 101.068402, 104.770898, 103.430032, 100.141814, 100.399972, 102.491602, 105.3091, 100.362988, 100.74038399999999, 100.53344399999999, 100.378454, 103.089292, 102.048738, 102.203116, 103.57445, 100.31637400000001, 103.145032, 102.428048, 100.770284, 102.114706, 103.519076, 101.76920199999999, 104.388184, 100.98589199999999, 101.17585600000001, 103.046054, 101.353078, 102.731072, 100.169158, 101.356246, 101.267974, 102.59149599999999, 101.22957600000001, 104.350768, 102.747474, 104.62765599999999, 103.30330400000001, 100.13364999999999, 100.811152, 101.402976, 102.066248, 101.967496, 100.926214, 100.996598, 100.691254, 101.680914, 100.742752, 101.94432400000001, 100.070998, 103.28598600000001, 103.087766, 101.717388, 103.700934, 101.827656, 101.174338 ] } ], "layout": { "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from numpy.random import normal\n", "import pandas as pd\n", "import random\n", "import numpy as np\n", "from tqdm import trange\n", "%matplotlib inline\n", "\n", "from plotly.offline import download_plotlyjs, init_notebook_mode, iplot\n", "import plotly.graph_objs as go\n", "import plotly.express as px\n", "from IPython.display import HTML\n", "# init_notebook_mode(connected=True)\n", "\n", "# set seed so that generated data is repetable\n", "random.seed(10)\n", "np.random.seed(10)\n", "\n", "# randomly generate 500 values for X1**2 and x2**2\n", "num_samples = 500\n", "dataDF = pd.DataFrame({\n", " 'x0': 1, # we add a dummy value so as to deal with intercept i.e 100\n", " 'x1': np.array([random.randint(-1000, 1000)/1000 for x in range(num_samples, )]),\n", " 'x2': np.array([random.randint(-1000, 1000)/1000 for x in range(num_samples)]) ,\n", "})\n", "\n", "# compute y for given set of X1 and X2\n", "dataDF['y'] = 100 + 4 * dataDF['x1'] ** 2 + 2 * dataDF['x2'] ** 2\n", "display(dataDF.head(5))\n", "\n", "# Extract features and target into separate numpy arrays\n", "# Note we are already taking square of X1 and X2 \n", "X = dataDF[['x0', 'x1', 'x2']].values ** 2\n", "y = dataDF['y'].values \n", "# create a random starting point that will be used for exploration\n", "starting_point = np.array([random.random() for i in range(X.shape[1])])\n", "\n", "# Plot the data \n", "iplot([go.Scatter3d(x=dataDF['x1'], y=dataDF['x2'], z=dataDF['y'], opacity=0.5, mode='markers')], show_link=False)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Batch Gradient Descent \n", "\n", "In the previous chapter, we developed a vanilla gradient descent algorithm that consumed the whole dataset in each iteration. This is known as batch gradient descent algorithm. We will use this algorithm to establish the baseline for evaluating different variants of the gradient descent algorithm. The evaluation of various algorithms will be based on how quickly the MSE reduces. The faster it reduces, the better is the algorithm. We compute MSE after each pass through the whole dataset, also known as epoch, and keep track of the iteration number, associated parameters and MSE in Traceback object. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:21.560653Z", "start_time": "2020-05-19T23:32:20.541317Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1000/1000 [00:00<00:00, 15651.15it/s]\n" ] }, { "data": { "text/html": [ "Optimized Parameters: [90.01084671 17.06077613 16.86676657]" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "name=BatchGradientDescent
iter=%{x}
cost=%{y}", "legendgroup": "BatchGradientDescent", "line": { "color": "#636efa", "dash": "solid" }, "mode": "lines", "name": "BatchGradientDescent", "showlegend": true, "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 5065244.639730797, 4954439.717997802, 4846085.834706164, 4740128.736825364, 4636515.372245749, 4535193.863195436, 4436113.480245626, 4339224.616891347, 4244478.764694851, 4151828.488979239, 4061227.405060114, 3972630.155003366, 3885992.384897434, 3801270.722628667, 3718422.756148627, 3637407.0122224754, 3558182.935647765, 3480710.8689332395, 3404952.032427457, 3330868.504887278, 3258423.20447648, 3187579.870184978, 3118303.0436593485, 3050558.0514355386, 2984310.9875648674, 2919528.6966246124, 2856178.7571046664, 2794229.46516194, 2733649.818734372, 2674409.50200658, 2616478.8702193853, 2559828.9348155726, 2504431.348914472, 2450258.3931080597, 2397282.9615714746, 2345478.5484809885, 2294819.2347326158, 2245279.674954729, 2196835.084808138, 2149461.22856731, 2103134.4069764703, 2057831.4453745263, 2013529.6820828486, 1970206.9570500974, 1927841.6007484007, 1886412.423315324, 1845898.70393619, 1806280.180461424, 1767537.039253727, 1729649.9052599913, 1692599.832302972, 1656368.293587867, 1620937.1724190358, 1586288.7531222084, 1552405.7121676365, 1519271.1094897434, 1486868.379998913, 1455181.325281174, 1424194.1054816158, 1393891.2313674693, 1364257.5565668775, 1335278.2699794644, 1306938.8883549003, 1279225.2490357473, 1252123.5028609438, 1225620.107226375, 1199701.8192990534, 1174355.6893815063, 1149569.054423048, 1125329.5316746803, 1101625.0124844508, 1078443.6562301507, 1055773.884386317, 1033604.3747225669, 1011924.055630353, 990722.1005753009, 969987.9226723474, 949711.1693809606, 929881.7173177863, 910489.6671841163, 891525.338805644, 872979.2662820157, 854842.1932437497, 837105.0682141479, 819759.0400738718, 802795.4536259155, 786205.8452587484, 769981.9387054588, 754115.6408967699, 738599.0379058529, 723424.3909829033, 708584.132677495, 694070.863046767, 679877.3459475467, 665996.5054105467, 652421.4220948227, 639145.3298207133, 626161.612179525, 613463.7992182649, 601045.5641977582, 588900.7204225269, 577023.2181408404, 565407.1415133862, 554046.7056490409, 542936.2537062556, 532070.2540586048, 521443.29752307583, 511050.09464971407, 500885.4730712619, 490944.3749114653, 481221.85425074963, 471713.0746479938, 462413.30671716155, 453317.92575757595, 444422.40943664743, 435722.33552389895, 427213.37967514724, 418891.31326573394, 410752.00127171876, 402791.4001979744, 395005.5560521439, 387390.6023634459, 379942.7582453343, 372658.3265010427, 365533.6917710638, 358565.3187216351, 351749.75027332356, 345083.60586882173, 338563.5797790877, 332186.43944697874, 325949.0238675504, 319848.24200420827, 313881.07123991934, 308044.5558627064, 302335.80558466795, 296751.99409377895, 291290.35763774964, 285948.1936392306, 280722.8593416719, 275611.7704851561, 270612.40001154353, 265722.2767982794, 260938.98442022759, 256260.15993891502, 251683.4927185733, 247206.72326839124, 242827.6421103928, 238544.0886723751, 234353.95020535323, 230255.16072496754, 226245.69997632288, 222323.59242174274, 218486.90625092905, 214733.75241303362, 211062.28367015475, 207470.69367178535, 203957.21604974865, 200520.1235331681, 197157.72708302853, 193868.37504589272, 190650.45232635277, 187502.37957779894, 184422.61241110117, 181409.64062080707, 178461.98742846865, 175578.20874271833, 172756.8924357234, 169996.65763565683, 167296.15403483028, 164654.0612131402, 162069.08797649224, 159539.97170986768, 157065.47774471244, 154644.3987403268, 152275.5540789509, 149957.78927423854, 147689.97539282608, 145471.00848870393, 143299.8090501096, 141175.32145866397, 139096.5134604798, 137062.37564897694, 135071.92095914652, 133124.18417301023, 131218.221436025, 129353.10978419418, 127527.94668164517, 125741.8495684434, 123993.95541841618, 122283.42030676326, 120609.41898724015, 118971.14447869893, 117367.80766078293, 115798.63687856992, 114262.8775559671, 112759.7918176633, 111288.65811945085, 109848.77088672858, 108439.4401610087, 107059.99125424691, 105709.76441082504, 104388.1144770156, 103094.4105777627, 101828.0358006184, 100588.38688667396, 99374.87392833432, 98186.92007378067, 97023.96123797653, 95885.44582006929, 94770.83442704886, 93679.59960352209, 92611.22556746934, 91565.20795184994, 90541.05355192791, 89538.28007819015, 88556.41591473401, 87594.99988300377, 86653.58101075588, 85731.7183061394, 84828.98053677642, 83944.94601373322, 83079.2023802728, 82231.34640528426, 81400.98378128394, 80587.72892688883, 79791.20479366131, 79011.04267723017, 78246.88203259266, 77498.37029350435, 76765.16269586736, 76046.92210502818, 75343.31884689747, 74654.03054280923, 73978.74194803472, 73317.14479387122, 72668.93763322615, 72033.82568961945, 71411.52070952824, 70801.74081799976, 70204.21037746091, 69618.65984965264, 69044.82566062063, 68482.45006869457, 67931.28103538958, 67391.0720991657, 66861.58225198145, 66342.57581857996, 65833.82233844744, 65335.096450384095, 64846.1777796308, 64366.85082749347, 63896.904863411524, 63436.13381941478, 62984.33618691696, 62541.31491579361, 62106.87731569401, 61680.834959537555, 61263.003589146625, 60853.203022967806, 60451.25706583612, 60056.99342073636, 59670.24360251807, 59290.842853520255, 58918.63006106369, 58553.4476767696, 58195.14163766454, 57843.56128903145, 57498.559308968346, 57159.99163461712, 56827.71739002541, 56501.598815604826, 56181.501199151215, 55867.292808391445, 55558.844825023625, 55256.03128021705, 54958.728991539974, 54666.817501283644, 54380.17901615169, 54098.69834828397, 53822.26285758666, 53550.76239533818, 53284.0892490439, 53022.13808851128, 52764.80591311888, 52511.99200025224, 52263.59785488165, 52019.527160255646, 51779.68572968608, 51543.981459400355, 51312.32428243758, 51084.62612356489, 50860.800855192036, 50640.76425426157, 50424.43396009335, 50211.7294331625, 50002.571914789274, 49796.884387721664, 49594.591537590386, 49395.619715216984, 49199.89689975641, 49007.35266265531, 48817.918132408355, 48631.52596009442, 48448.11028567583, 48267.60670504356, 48089.95223779185, 47915.08529570613, 47742.94565194855, 47573.47441092563, 47406.61397882285, 47242.30803479135, 47080.50150277266, 46921.14052394698, 46764.172429791404, 46609.545715734246, 46457.21001539304, 46307.11607538222, 46159.215730678916, 46013.4618805338, 45869.808464915186, 45728.2104414746, 45588.62376302213, 45451.005355500565, 45315.31309644682, 45181.505793930395, 45049.5431659578, 44919.38582033305, 44790.99523496395, 44664.33373860412, 44539.3644920215, 44416.051469583705, 44294.35944125072, 44174.253954966705, 44055.701319440996, 43938.66858731063, 43823.12353867547, 43709.03466499769, 43596.371153357904, 43485.1028710595, 43375.20035057393, 43266.634774819184, 43159.37796276424, 43053.40235535198, 42948.681001733814, 42845.187545809036, 42742.89621306215, 42641.781797691314, 42541.819650022146, 42442.985664199645, 42345.256266152945, 42248.60840182617, 42153.01952567014, 42058.467589388456, 41964.93103093289, 41872.38876374242, 41780.82016622026, 41690.205071444085, 41600.523757103714, 41511.75693566182, 41423.88574473226, 41336.89173767141, 41250.756874377774, 41165.46351229532, 41080.99439761578, 40997.33265667592, 40914.46178754508, 40832.36565179887, 40751.02846647521, 40670.434796208094, 40590.56954553582, 40511.417951379146, 40432.96557568619, 40355.19829824004, 40278.10230962554, 40201.66410435182, 40125.87047412705, 40050.708501282, 39976.165552339284, 39902.22927172475, 39828.88757561837, 39756.128645940895, 39683.94092447395, 39612.31310710998, 39541.23413822971, 39470.69320520393, 39400.67973301706, 39331.18337900959, 39262.1940277371, 39193.70178594287, 39125.69697764193, 39058.17013931379, 38991.11201520178, 38924.51355271613, 38858.36589793913, 38792.6603912296, 38727.38856292457, 38662.542129136375, 38598.112987642584, 38534.09321386686, 38470.475056949064, 38407.250935901946, 38344.41343585321, 38281.95530437065, 38219.86944786871, 38158.148928094415, 38096.78695869126, 38035.776901839025, 37975.1122649681, 37914.78669754639, 37854.79398793747, 37795.12806032822, 37735.782971724424, 37676.752909013005, 37618.03218608914, 37559.615241047024, 37501.49663343288, 37443.67104155867, 37386.13325987528, 37328.87819640391, 37271.900870224315, 37215.19640901852, 37158.76004666909, 37102.58712091042, 37046.67307103207, 36991.01343563292, 36935.60385042503, 36880.44004608609, 36825.517846159564, 36770.83316500103, 36716.38200577018, 36662.16045846728, 36608.1646980129, 36554.390982370394, 36500.83565070975, 36447.49512161216, 36394.36589131433, 36341.44453199158, 36288.72769007915, 36236.21208463034, 36183.89450571127, 36131.77181283105, 36079.84093340671, 36028.09886126214, 35976.54265516014, 35925.16943736714, 35873.97639224953, 35822.960764901174, 35772.11985980123, 35721.45103950169, 35670.951723343955, 35620.61938620389, 35570.45155726459, 35520.44581881627, 35470.59980508285, 35420.911201074385, 35371.37774146497, 35321.99720949541, 35272.767435900256, 35223.686297858556, 35174.75171796777, 35125.96166324054, 35077.31414412346, 35028.80721353785, 34980.43896594138, 34932.20753641083, 34884.11109974496, 34836.14786958718, 34788.31609756786, 34740.61407246541, 34693.04011938601, 34645.592598961506, 34598.26990656504, 34551.07047154404, 34503.99275647021, 34457.03525640607, 34410.19649818775, 34363.47503972374, 34316.869469308964, 34270.378404954274, 34224.00049373055, 34177.734411127545, 34131.578860426736, 34085.53257208811, 34039.59430315059, 33993.76283664567, 33948.03698102398, 33902.41556959461, 33856.89745997693, 33811.481533564256, 33766.166694999716, 33720.95187166353, 33675.83601317162, 33630.81809088544, 33585.89709743256, 33541.072046237845, 33496.34197106509, 33451.7059255688, 33407.162982855705, 33362.71223505631, 33318.352792905534, 33274.083785333, 33229.904359062086, 33185.813678218125, 33141.81092394503, 33097.8952940305, 33054.06600253961, 33010.322279456355, 32966.66337033325, 32923.0885359486, 32879.597051971396, 32836.18820863359, 32792.86131040969, 32749.615675703375, 32706.450636541085, 32663.365538272374, 32620.359739276886, 32577.432610677854, 32534.583536061895, 32491.811911204986, 32449.117143804608, 32406.49865321771, 32363.95587020447, 32321.488236677862, 32279.09520545855, 32236.776240035393, 32194.530814331163, 32152.358412473437, 32110.258528570597, 32068.230666492826, 32026.274339657735, 31984.389070821086, 31942.5743918718, 31900.82984363172, 31859.154975659738, 31817.549346060212, 31776.01252129567, 31734.544076003687, 31693.143592817716, 31651.81066219201, 31610.544882230264, 31569.34585851821, 31528.213203959793, 31487.14653861701, 31446.14548955331, 31405.209690680465, 31364.338782608793, 31323.53241250067, 31282.79023392738, 31242.111906729013, 31201.497096877596, 31160.945476343113, 31120.456722962575, 31080.030520311964, 31039.666557580997, 30999.364529450675, 30959.124135973558, 30918.945082456623, 30878.827079346796, 30838.76984211894, 30798.773091166404, 30758.836551693857, 30718.959953612677, 30679.143031438478, 30639.385524191046, 30599.68717529635, 30560.04773249084, 30520.466947727826, 30480.9445770858, 30441.480380679095, 30402.074122570106, 30362.72557068383, 30323.43449672407, 30284.200676091517, 30245.023887803764, 30205.903914416973, 30166.840541949237, 30127.83355980582, 30088.882760705837, 30049.987940610717, 30011.148898654144, 29972.36543707362, 29933.63736114344, 29894.964479109294, 29856.34660212419, 29817.783544185837, 29779.275122075407, 29740.82115529769, 29702.42146602252, 29664.075879027456, 29625.784221641887, 29587.546323692186, 29549.3620174482, 29511.23113757088, 29473.153521061064, 29435.129007209376, 29397.157437547317, 29359.238655799298, 29321.372507835866, 29283.55884162787, 29245.79750720167, 29208.08835659537, 29170.43124381596, 29132.82602479746, 29095.272557359913, 29057.770701169415, 29020.320317698806, 28982.921270189512, 28945.573423613976, 28908.276644639085, 28871.030801590332, 28833.835764416748, 28796.691404656696, 28759.59759540433, 28722.554211276853, 28685.56112838242, 28648.618224288897, 28611.72537799314, 28574.882469891043, 28538.089381748283, 28501.34599667156, 28464.652199080665, 28428.00787468104, 28391.412910436946, 28354.867194545277, 28318.37061640992, 28281.92306661672, 28245.52443690885, 28209.174620162976, 28172.873510365735, 28136.62100259078, 28100.416992976414, 28064.26137870363, 28028.154057974658, 27992.09492999199, 27956.08389493787, 27920.12085395427, 27884.205709123187, 27848.338363447518, 27812.518720832297, 27776.746686066326, 27741.02216480421, 27705.345063548848, 27669.715289634223, 27634.132751208635, 27598.597357218307, 27563.109017391267, 27527.667642221728, 27492.27314295461, 27456.925431570653, 27421.624420771655, 27386.37002396609, 27351.16215525511, 27316.000729418745, 27280.88566190254, 27245.81686880432, 27210.79426686139, 27175.81777343797, 27140.887306512865, 27106.002784667446, 27071.164127073902, 27036.371253483725, 27001.624084216455, 26966.922540148695, 26932.266542703306, 26897.656013838925, 26863.09087603967, 26828.571052305037, 26794.09646614004, 26759.667041545654, 26725.282703009278, 26690.943375495648, 26656.64898443773, 26622.399455727922, 26588.19471570946, 26554.03469116796, 26519.919309323173, 26485.848497820924, 26451.822184725213, 26417.840298510484, 26383.902768054097, 26350.009522628927, 26316.16049189616, 26282.3556058982, 26248.59479505175, 26214.877990141096, 26181.205122311483, 26147.576123062587, 26113.99092424225, 26080.4494580403, 26046.951656982426, 26013.497453924323, 25980.086782045873, 25946.719574845483, 25913.395766134527, 25880.115290031943, 25846.8780809589, 25813.684073633674, 25780.533203066472, 25747.42540455456, 25714.360613677345, 25681.33876629165, 25648.359798527057, 25615.42364678135, 25582.530247716088, 25549.67953825224, 25516.871455565913, 25484.105937084212, 25451.382920481134, 25418.702343673613, 25386.064144817603, 25353.468262304254, 25320.914634756176, 25288.403201023822, 25255.93390018185, 25223.506671525683, 25191.12145456807, 25158.778189035715, 25126.476814866037, 25094.217272203918, 25061.99950139864, 25029.823443000743, 24997.689037759053, 24965.596226617767, 24933.54495071352, 24901.53515137261, 24869.56677010828, 24837.639748617938, 24805.754028780582, 24773.909552654222, 24742.10626247331, 24710.344100646336, 24678.623009753363, 24646.942932543643, 24615.30381193336, 24583.70559100333, 24552.14821299679, 24520.631621317218, 24489.15575952622, 24457.720571341444, 24426.326000634563, 24394.971991429247, 24363.658487899236, 24332.385434366464, 24301.1527752991, 24269.96045530984, 24238.808419153993, 24207.69661172785, 24176.624978066873, 24145.593463344056, 24114.602012868283, 24083.650572082726, 24052.73908656324, 24021.867502016845, 23991.035764280212, 23960.24381931818, 23929.491613222315, 23898.779092209486, 23868.10620262049, 23837.472890918667, 23806.879103688603, 23776.3247876348, 23745.809889580407, 23715.334356466003, 23684.898135348318, 23654.50117339906, 23624.143417903753, 23593.824816260603, 23563.545315979303, 23533.304864679994, 23503.10341009219, 23472.94090005366, 23442.81728250946, 23412.732505510867, 23382.686517214413, 23352.679265880903, 23322.71069987445, 23292.78076766157, 23262.889417810242, 23233.036598988994, 23203.222259966067, 23173.44634960853, 23143.70881688143, 23114.009610846988, 23084.348680663752, 23054.725975585814, 23025.141444962082, 22995.595038235424, 22966.086704942012, 22936.61639471053, 22907.18405726146, 22877.789642406406, 22848.433100047383, 22819.114380176143, 22789.83343287352, 22760.590208308753, 22731.384656738875, 22702.216728508072, 22673.086374047096, 22643.993543872624, 22614.938188586682, 22585.92025887608, 22556.93970551182, 22527.996479348578, 22499.090531324102, 22470.22181245874, 22441.39027385485, 22412.595866696334, 22383.838542248115, 22355.11825185563, 22326.434946944337, 22297.78857901929, 22269.17909966458, 22240.606460542967, 22212.07061339537, 22183.571510040438, 22155.109102374117, 22126.68334236921, 22098.294182075, 22069.941573616758, 22041.625469195445, 22013.34582108719, 21985.10258164302, 21956.895703288377, 21928.72513852283, 21900.59083991963, 21872.49276012538, 21844.430851859684, 21816.405067914795, 21788.41536115524, 21760.461684517526, 21732.543991009785, 21704.66223371143, 21676.816365772866, 21649.00634041516, 21621.232110929726, 21593.493630678015, 21565.790853091232, 21538.123731670028, 21510.49221998423, 21482.89627167251, 21455.33584044216, 21427.810880068773, 21400.321344395972, 21372.867187335196, 21345.44836286537, 21318.064825032692, 21290.71652795035, 21263.403425798264, 21236.1254728229, 21208.88262333695, 21181.67483171914, 21154.502052413984, 21127.36423993155, 21100.26134884722, 21073.19333380149, 21046.160149499723, 21019.16175071197, 20992.19809227268, 20965.269129080585, 20938.374816098425, 20911.515108352745, 20884.689960933727, 20857.89932899497, 20831.143167753282, 20804.42143248851, 20777.73407854332, 20751.08106132304, 20724.462336295466, 20697.877858990658, 20671.327585000767, 20644.811469979875, 20618.3294696438, 20591.881539769915, 20565.467636196998, 20539.08771482507, 20512.74173161519, 20486.429642589326, 20460.151403830147, 20433.906971480938, 20407.696301745353, 20381.519350887338, 20355.376075230917, 20329.266431160067, 20303.190375118542, 20277.14786360979, 20251.13885319671, 20225.163300501572, 20199.221162205868, 20173.312395050118, 20147.436955833815, 20121.59480141521, 20095.78588871121, 20070.01017469723, 20044.267616407073, 20018.558170932756, 19992.881795424473, 19967.238447090327, 19941.628083196316, 19916.050661066172, 19890.506138081197, 19864.994471680184, 19839.515619359274, 19814.069538671833, 19788.656187228342, 19763.27552269626, 19737.927502799925, 19712.61208532042, 19687.32922809546, 19662.078889019274, 19636.861026042498, 19611.67559717206, 19586.52256047108, 19561.401874058694, 19536.313496110066, 19511.25738485615, 19486.23349858367, 19461.24179563496, 19436.28223440789, 19411.354773355728, 19386.45937098709, 19361.595985865773, 19336.7645766107, 19311.965101895767, 19287.1975204498, 19262.461791056427, 19237.757872553946, 19213.085723835306, 19188.44530384791, 19163.83657159361, 19139.25948612852, 19114.714006563016, 19090.200092061546, 19065.717701842615, 19041.266795178646, 19016.847331395875, 18992.45926987431, 18968.102570047577, 18943.777191402885, 18919.483093480903, 18895.220235875666, 18870.988578234494, 18846.788080257928, 18822.61870169958, 18798.480402366094, 18774.37314211704, 18750.296880864862, 18726.25157857472, 18702.23719526447, 18678.25369100453, 18654.301025917855, 18630.379160179786, 18606.488054017987, 18582.627667712404, 18558.79796159511, 18534.998896050274, 18511.230431514065, 18487.492528474562, 18463.785147471688, 18440.108249097113, 18416.461793994175, 18392.84574285782, 18369.260056434483, 18345.704695522047, 18322.179620969742, 18298.684793678076, 18275.22017459875, 18251.785724734582, 18228.381405139437, 18205.00717691813, 18181.663001226363, 18158.348839270664, 18135.06465230827, 18111.810401647093, 18088.586048645608, 18065.391554712816, 18042.22688130811, 18019.091989941277, 17995.986842172373, 17972.91139961165, 17949.865623919504, 17926.84947680638, 17903.86292003271, 17880.905915408846, 17857.97842479497, 17835.080410101018, 17812.21183328665, 17789.372656361127, 17766.56284138326, 17743.782350461355, 17721.0311457531, 17698.309189465537, 17675.61644385497, 17652.952871226895, 17630.318433935947, 17607.713094385792, 17585.136815029084, 17562.589558367406, 17540.07128695118, 17517.581963379595, 17495.12155030056 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "name" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "iter" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "cost" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from plotnine import *\n", " \n", "\n", "class Traceback(object):\n", " \"\"\"\n", " A utility class to keep track of parameters and cost at each step of a gradient descent \n", " \"\"\"\n", " def __init__(self, name, parameter_size):\n", " self.name = name\n", " self.parameter_size = parameter_size\n", " self._data = []\n", " \n", " def add(self, iteration, parameters, cost):\n", " assert parameters.shape[0] == self.parameter_size, \"Expecting {} parameters but found {}\".format(self.parameter_size, parameters.shape[0])\n", " self._data.append((iteration, parameters, cost))\n", " \n", " def to_pandas(self):\n", " data = [[self.name, t[0], t[2]] + t[1].tolist() for t in self._data]\n", " columns = ['name', 'iter', 'cost'] + ['P{}'.format(i) for i in range(self.parameter_size)]\n", " return pd.DataFrame(data, columns=columns)\n", " \n", "\n", "def mse(X, y, theta):\n", " \"Returns MSE\"\n", " \n", " predictions = np.sum(np.transpose(theta)*X, axis=1)\n", " error = y - predictions\n", " return np.sum(error ** 2)\n", "\n", "\n", "\n", "def gradient(X, y, theta):\n", " \"Returns gradient\"\n", "\n", " num_samples = X.shape[0]\n", " \n", " # assuming function to be linear combination of parameeters \n", " # hence np.transpose(theta) * X\n", " predictions = np.sum(np.transpose(theta)*X, axis=1)\n", " \n", " # compute error in predictions\n", " error = y - predictions\n", " \n", " # calculate gradient\n", " gradient = -1. / num_samples * np.sum(error.reshape((num_samples, 1)) * X, axis=0) \n", " \n", " return gradient\n", "\n", "\n", "def plotCost(tracebacks, min_iter = None, max_iter = None, exclude=None):\n", " df = pd.concat([x.to_pandas() for x in tracebacks], axis=0)\n", " min_iter = min_iter or df['iter'].min()\n", " max_iter = max_iter or df['iter'].max()\n", " exclude = exclude or []\n", " df = df[\n", " (df['iter'] >= min_iter) \n", " & (df['iter'] <= max_iter)\n", " & (~df['name'].isin(exclude))\n", " ]\n", "\n", " fig = px.line(df, x=\"iter\", y=\"cost\", color='name')\n", " fig.show()\n", " \n", "\n", "def batch_gradient_descent(X, y, learning_rate = 0.03, max_epoch = 1000, traceback = None, stopping_threshold = 1.0e-6, starting_point = None):\n", " \"\"\"\n", " Implements batch gradient descent algorithm\n", " X -- Input Features\n", " y -- Target Value that we are trying to predict\n", " learning rate -- learning rate\n", " max_epoch -- maximum number of times we should pass through the data\n", " traceback -- array in which we should put intermediate parameters and associated MSE\n", " stopping_threshold -- slope of the gradient descent at which we should stop\n", " starting_point -- starting point from where we start our exploration\n", " \"\"\"\n", " \n", " # number of samples\n", " m = X.shape[0]\n", " \n", " # number of parameters\n", " n = X.shape[1]\n", " \n", " # starting point -- use the given point or randomly generate\n", " theta1 = np.array([random() for i in range(n)]) if starting_point is None else starting_point\n", " \n", " for iter in trange(max_epoch):\n", " \n", " if traceback is not None:\n", " traceback.add(iter, theta1, mse(X, y, theta1))\n", "\n", " # compute average gradient for all data points\n", " # and move in the opposite direction\n", " grad = gradient(X, y, theta1)\n", " theta2 = theta1 - learning_rate * grad\n", " \n", " # check if we reached stopping criteria threshold\n", " \n", " if np.linalg.norm(grad) < stopping_threshold:\n", " print(\"Early Stopping at Iteration Number: \", iter)\n", " return theta2\n", " elif np.all(np.isnan(theta2)):\n", " raise Exception(\"All nan\")\n", " \n", " theta1 = theta2\n", " \n", " # if we reached max iterations then return current point\n", " return theta1\n", "\n", "tracebacks = {'Batch': Traceback(\"BatchGradientDescent\", 3)}\n", "theta = batch_gradient_descent(X, y, learning_rate=0.009, max_epoch=1000, traceback=tracebacks['Batch'], stopping_threshold=1e-6, starting_point=starting_point)\n", "display(HTML(\"Optimized Parameters: {}\".format(theta)))\n", "\n", "plotCost(tracebacks.values())" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-11-20T03:21:06.180043Z", "start_time": "2019-11-20T03:21:05.976113Z" } }, "source": [ "## Mini Batch Gradient Descent\n", "\n", "One of the challenges with batch gradient descent is that it has to go through the whole dataset before it can update the parameters. While this has the advantage where our gradient doesn't randomly switches direction, it tends to converge to the local minimum slowly. Mini batch gradient descent address this by splitting the data into smaller chunks and updating the parameter for each chunk. Assuming we divide the data into 10 chunks then in a single pass through our data, or single epoch, our parameters will get updated 10 times. Below is the implementation of mini batch gradient descent. The only difference between this version and the previous version is that we had an additional parameter `num_batches`. In each epoch, we randomly split the data into mini chunks and update the parameters as we go through each of them. " ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:22.301544Z", "start_time": "2020-05-19T23:32:21.688421Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1000/1000 [00:00<00:00, 1895.10it/s]\n" ] }, { "data": { "text/html": [ "Optimized Parameters: [99.96801301 4.04760266 2.04245593]" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "name=BatchGradientDescent
iter=%{x}
cost=%{y}", "legendgroup": "BatchGradientDescent", "line": { "color": "#636efa", "dash": "solid" }, "mode": "lines", "name": "BatchGradientDescent", "showlegend": true, "type": "scattergl", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 5065244.639730797, 4954439.717997802, 4846085.834706164, 4740128.736825364, 4636515.372245749, 4535193.863195436, 4436113.480245626, 4339224.616891347, 4244478.764694851, 4151828.488979239, 4061227.405060114, 3972630.155003366, 3885992.384897434, 3801270.722628667, 3718422.756148627, 3637407.0122224754, 3558182.935647765, 3480710.8689332395, 3404952.032427457, 3330868.504887278, 3258423.20447648, 3187579.870184978, 3118303.0436593485, 3050558.0514355386, 2984310.9875648674, 2919528.6966246124, 2856178.7571046664, 2794229.46516194, 2733649.818734372, 2674409.50200658, 2616478.8702193853, 2559828.9348155726, 2504431.348914472, 2450258.3931080597, 2397282.9615714746, 2345478.5484809885, 2294819.2347326158, 2245279.674954729, 2196835.084808138, 2149461.22856731, 2103134.4069764703, 2057831.4453745263, 2013529.6820828486, 1970206.9570500974, 1927841.6007484007, 1886412.423315324, 1845898.70393619, 1806280.180461424, 1767537.039253727, 1729649.9052599913, 1692599.832302972, 1656368.293587867, 1620937.1724190358, 1586288.7531222084, 1552405.7121676365, 1519271.1094897434, 1486868.379998913, 1455181.325281174, 1424194.1054816158, 1393891.2313674693, 1364257.5565668775, 1335278.2699794644, 1306938.8883549003, 1279225.2490357473, 1252123.5028609438, 1225620.107226375, 1199701.8192990534, 1174355.6893815063, 1149569.054423048, 1125329.5316746803, 1101625.0124844508, 1078443.6562301507, 1055773.884386317, 1033604.3747225669, 1011924.055630353, 990722.1005753009, 969987.9226723474, 949711.1693809606, 929881.7173177863, 910489.6671841163, 891525.338805644, 872979.2662820157, 854842.1932437497, 837105.0682141479, 819759.0400738718, 802795.4536259155, 786205.8452587484, 769981.9387054588, 754115.6408967699, 738599.0379058529, 723424.3909829033, 708584.132677495, 694070.863046767, 679877.3459475467, 665996.5054105467, 652421.4220948227, 639145.3298207133, 626161.612179525, 613463.7992182649, 601045.5641977582, 588900.7204225269, 577023.2181408404, 565407.1415133862, 554046.7056490409, 542936.2537062556, 532070.2540586048, 521443.29752307583, 511050.09464971407, 500885.4730712619, 490944.3749114653, 481221.85425074963, 471713.0746479938, 462413.30671716155, 453317.92575757595, 444422.40943664743, 435722.33552389895, 427213.37967514724, 418891.31326573394, 410752.00127171876, 402791.4001979744, 395005.5560521439, 387390.6023634459, 379942.7582453343, 372658.3265010427, 365533.6917710638, 358565.3187216351, 351749.75027332356, 345083.60586882173, 338563.5797790877, 332186.43944697874, 325949.0238675504, 319848.24200420827, 313881.07123991934, 308044.5558627064, 302335.80558466795, 296751.99409377895, 291290.35763774964, 285948.1936392306, 280722.8593416719, 275611.7704851561, 270612.40001154353, 265722.2767982794, 260938.98442022759, 256260.15993891502, 251683.4927185733, 247206.72326839124, 242827.6421103928, 238544.0886723751, 234353.95020535323, 230255.16072496754, 226245.69997632288, 222323.59242174274, 218486.90625092905, 214733.75241303362, 211062.28367015475, 207470.69367178535, 203957.21604974865, 200520.1235331681, 197157.72708302853, 193868.37504589272, 190650.45232635277, 187502.37957779894, 184422.61241110117, 181409.64062080707, 178461.98742846865, 175578.20874271833, 172756.8924357234, 169996.65763565683, 167296.15403483028, 164654.0612131402, 162069.08797649224, 159539.97170986768, 157065.47774471244, 154644.3987403268, 152275.5540789509, 149957.78927423854, 147689.97539282608, 145471.00848870393, 143299.8090501096, 141175.32145866397, 139096.5134604798, 137062.37564897694, 135071.92095914652, 133124.18417301023, 131218.221436025, 129353.10978419418, 127527.94668164517, 125741.8495684434, 123993.95541841618, 122283.42030676326, 120609.41898724015, 118971.14447869893, 117367.80766078293, 115798.63687856992, 114262.8775559671, 112759.7918176633, 111288.65811945085, 109848.77088672858, 108439.4401610087, 107059.99125424691, 105709.76441082504, 104388.1144770156, 103094.4105777627, 101828.0358006184, 100588.38688667396, 99374.87392833432, 98186.92007378067, 97023.96123797653, 95885.44582006929, 94770.83442704886, 93679.59960352209, 92611.22556746934, 91565.20795184994, 90541.05355192791, 89538.28007819015, 88556.41591473401, 87594.99988300377, 86653.58101075588, 85731.7183061394, 84828.98053677642, 83944.94601373322, 83079.2023802728, 82231.34640528426, 81400.98378128394, 80587.72892688883, 79791.20479366131, 79011.04267723017, 78246.88203259266, 77498.37029350435, 76765.16269586736, 76046.92210502818, 75343.31884689747, 74654.03054280923, 73978.74194803472, 73317.14479387122, 72668.93763322615, 72033.82568961945, 71411.52070952824, 70801.74081799976, 70204.21037746091, 69618.65984965264, 69044.82566062063, 68482.45006869457, 67931.28103538958, 67391.0720991657, 66861.58225198145, 66342.57581857996, 65833.82233844744, 65335.096450384095, 64846.1777796308, 64366.85082749347, 63896.904863411524, 63436.13381941478, 62984.33618691696, 62541.31491579361, 62106.87731569401, 61680.834959537555, 61263.003589146625, 60853.203022967806, 60451.25706583612, 60056.99342073636, 59670.24360251807, 59290.842853520255, 58918.63006106369, 58553.4476767696, 58195.14163766454, 57843.56128903145, 57498.559308968346, 57159.99163461712, 56827.71739002541, 56501.598815604826, 56181.501199151215, 55867.292808391445, 55558.844825023625, 55256.03128021705, 54958.728991539974, 54666.817501283644, 54380.17901615169, 54098.69834828397, 53822.26285758666, 53550.76239533818, 53284.0892490439, 53022.13808851128, 52764.80591311888, 52511.99200025224, 52263.59785488165, 52019.527160255646, 51779.68572968608, 51543.981459400355, 51312.32428243758, 51084.62612356489, 50860.800855192036, 50640.76425426157, 50424.43396009335, 50211.7294331625, 50002.571914789274, 49796.884387721664, 49594.591537590386, 49395.619715216984, 49199.89689975641, 49007.35266265531, 48817.918132408355, 48631.52596009442, 48448.11028567583, 48267.60670504356, 48089.95223779185, 47915.08529570613, 47742.94565194855, 47573.47441092563, 47406.61397882285, 47242.30803479135, 47080.50150277266, 46921.14052394698, 46764.172429791404, 46609.545715734246, 46457.21001539304, 46307.11607538222, 46159.215730678916, 46013.4618805338, 45869.808464915186, 45728.2104414746, 45588.62376302213, 45451.005355500565, 45315.31309644682, 45181.505793930395, 45049.5431659578, 44919.38582033305, 44790.99523496395, 44664.33373860412, 44539.3644920215, 44416.051469583705, 44294.35944125072, 44174.253954966705, 44055.701319440996, 43938.66858731063, 43823.12353867547, 43709.03466499769, 43596.371153357904, 43485.1028710595, 43375.20035057393, 43266.634774819184, 43159.37796276424, 43053.40235535198, 42948.681001733814, 42845.187545809036, 42742.89621306215, 42641.781797691314, 42541.819650022146, 42442.985664199645, 42345.256266152945, 42248.60840182617, 42153.01952567014, 42058.467589388456, 41964.93103093289, 41872.38876374242, 41780.82016622026, 41690.205071444085, 41600.523757103714, 41511.75693566182, 41423.88574473226, 41336.89173767141, 41250.756874377774, 41165.46351229532, 41080.99439761578, 40997.33265667592, 40914.46178754508, 40832.36565179887, 40751.02846647521, 40670.434796208094, 40590.56954553582, 40511.417951379146, 40432.96557568619, 40355.19829824004, 40278.10230962554, 40201.66410435182, 40125.87047412705, 40050.708501282, 39976.165552339284, 39902.22927172475, 39828.88757561837, 39756.128645940895, 39683.94092447395, 39612.31310710998, 39541.23413822971, 39470.69320520393, 39400.67973301706, 39331.18337900959, 39262.1940277371, 39193.70178594287, 39125.69697764193, 39058.17013931379, 38991.11201520178, 38924.51355271613, 38858.36589793913, 38792.6603912296, 38727.38856292457, 38662.542129136375, 38598.112987642584, 38534.09321386686, 38470.475056949064, 38407.250935901946, 38344.41343585321, 38281.95530437065, 38219.86944786871, 38158.148928094415, 38096.78695869126, 38035.776901839025, 37975.1122649681, 37914.78669754639, 37854.79398793747, 37795.12806032822, 37735.782971724424, 37676.752909013005, 37618.03218608914, 37559.615241047024, 37501.49663343288, 37443.67104155867, 37386.13325987528, 37328.87819640391, 37271.900870224315, 37215.19640901852, 37158.76004666909, 37102.58712091042, 37046.67307103207, 36991.01343563292, 36935.60385042503, 36880.44004608609, 36825.517846159564, 36770.83316500103, 36716.38200577018, 36662.16045846728, 36608.1646980129, 36554.390982370394, 36500.83565070975, 36447.49512161216, 36394.36589131433, 36341.44453199158, 36288.72769007915, 36236.21208463034, 36183.89450571127, 36131.77181283105, 36079.84093340671, 36028.09886126214, 35976.54265516014, 35925.16943736714, 35873.97639224953, 35822.960764901174, 35772.11985980123, 35721.45103950169, 35670.951723343955, 35620.61938620389, 35570.45155726459, 35520.44581881627, 35470.59980508285, 35420.911201074385, 35371.37774146497, 35321.99720949541, 35272.767435900256, 35223.686297858556, 35174.75171796777, 35125.96166324054, 35077.31414412346, 35028.80721353785, 34980.43896594138, 34932.20753641083, 34884.11109974496, 34836.14786958718, 34788.31609756786, 34740.61407246541, 34693.04011938601, 34645.592598961506, 34598.26990656504, 34551.07047154404, 34503.99275647021, 34457.03525640607, 34410.19649818775, 34363.47503972374, 34316.869469308964, 34270.378404954274, 34224.00049373055, 34177.734411127545, 34131.578860426736, 34085.53257208811, 34039.59430315059, 33993.76283664567, 33948.03698102398, 33902.41556959461, 33856.89745997693, 33811.481533564256, 33766.166694999716, 33720.95187166353, 33675.83601317162, 33630.81809088544, 33585.89709743256, 33541.072046237845, 33496.34197106509, 33451.7059255688, 33407.162982855705, 33362.71223505631, 33318.352792905534, 33274.083785333, 33229.904359062086, 33185.813678218125, 33141.81092394503, 33097.8952940305, 33054.06600253961, 33010.322279456355, 32966.66337033325, 32923.0885359486, 32879.597051971396, 32836.18820863359, 32792.86131040969, 32749.615675703375, 32706.450636541085, 32663.365538272374, 32620.359739276886, 32577.432610677854, 32534.583536061895, 32491.811911204986, 32449.117143804608, 32406.49865321771, 32363.95587020447, 32321.488236677862, 32279.09520545855, 32236.776240035393, 32194.530814331163, 32152.358412473437, 32110.258528570597, 32068.230666492826, 32026.274339657735, 31984.389070821086, 31942.5743918718, 31900.82984363172, 31859.154975659738, 31817.549346060212, 31776.01252129567, 31734.544076003687, 31693.143592817716, 31651.81066219201, 31610.544882230264, 31569.34585851821, 31528.213203959793, 31487.14653861701, 31446.14548955331, 31405.209690680465, 31364.338782608793, 31323.53241250067, 31282.79023392738, 31242.111906729013, 31201.497096877596, 31160.945476343113, 31120.456722962575, 31080.030520311964, 31039.666557580997, 30999.364529450675, 30959.124135973558, 30918.945082456623, 30878.827079346796, 30838.76984211894, 30798.773091166404, 30758.836551693857, 30718.959953612677, 30679.143031438478, 30639.385524191046, 30599.68717529635, 30560.04773249084, 30520.466947727826, 30480.9445770858, 30441.480380679095, 30402.074122570106, 30362.72557068383, 30323.43449672407, 30284.200676091517, 30245.023887803764, 30205.903914416973, 30166.840541949237, 30127.83355980582, 30088.882760705837, 30049.987940610717, 30011.148898654144, 29972.36543707362, 29933.63736114344, 29894.964479109294, 29856.34660212419, 29817.783544185837, 29779.275122075407, 29740.82115529769, 29702.42146602252, 29664.075879027456, 29625.784221641887, 29587.546323692186, 29549.3620174482, 29511.23113757088, 29473.153521061064, 29435.129007209376, 29397.157437547317, 29359.238655799298, 29321.372507835866, 29283.55884162787, 29245.79750720167, 29208.08835659537, 29170.43124381596, 29132.82602479746, 29095.272557359913, 29057.770701169415, 29020.320317698806, 28982.921270189512, 28945.573423613976, 28908.276644639085, 28871.030801590332, 28833.835764416748, 28796.691404656696, 28759.59759540433, 28722.554211276853, 28685.56112838242, 28648.618224288897, 28611.72537799314, 28574.882469891043, 28538.089381748283, 28501.34599667156, 28464.652199080665, 28428.00787468104, 28391.412910436946, 28354.867194545277, 28318.37061640992, 28281.92306661672, 28245.52443690885, 28209.174620162976, 28172.873510365735, 28136.62100259078, 28100.416992976414, 28064.26137870363, 28028.154057974658, 27992.09492999199, 27956.08389493787, 27920.12085395427, 27884.205709123187, 27848.338363447518, 27812.518720832297, 27776.746686066326, 27741.02216480421, 27705.345063548848, 27669.715289634223, 27634.132751208635, 27598.597357218307, 27563.109017391267, 27527.667642221728, 27492.27314295461, 27456.925431570653, 27421.624420771655, 27386.37002396609, 27351.16215525511, 27316.000729418745, 27280.88566190254, 27245.81686880432, 27210.79426686139, 27175.81777343797, 27140.887306512865, 27106.002784667446, 27071.164127073902, 27036.371253483725, 27001.624084216455, 26966.922540148695, 26932.266542703306, 26897.656013838925, 26863.09087603967, 26828.571052305037, 26794.09646614004, 26759.667041545654, 26725.282703009278, 26690.943375495648, 26656.64898443773, 26622.399455727922, 26588.19471570946, 26554.03469116796, 26519.919309323173, 26485.848497820924, 26451.822184725213, 26417.840298510484, 26383.902768054097, 26350.009522628927, 26316.16049189616, 26282.3556058982, 26248.59479505175, 26214.877990141096, 26181.205122311483, 26147.576123062587, 26113.99092424225, 26080.4494580403, 26046.951656982426, 26013.497453924323, 25980.086782045873, 25946.719574845483, 25913.395766134527, 25880.115290031943, 25846.8780809589, 25813.684073633674, 25780.533203066472, 25747.42540455456, 25714.360613677345, 25681.33876629165, 25648.359798527057, 25615.42364678135, 25582.530247716088, 25549.67953825224, 25516.871455565913, 25484.105937084212, 25451.382920481134, 25418.702343673613, 25386.064144817603, 25353.468262304254, 25320.914634756176, 25288.403201023822, 25255.93390018185, 25223.506671525683, 25191.12145456807, 25158.778189035715, 25126.476814866037, 25094.217272203918, 25061.99950139864, 25029.823443000743, 24997.689037759053, 24965.596226617767, 24933.54495071352, 24901.53515137261, 24869.56677010828, 24837.639748617938, 24805.754028780582, 24773.909552654222, 24742.10626247331, 24710.344100646336, 24678.623009753363, 24646.942932543643, 24615.30381193336, 24583.70559100333, 24552.14821299679, 24520.631621317218, 24489.15575952622, 24457.720571341444, 24426.326000634563, 24394.971991429247, 24363.658487899236, 24332.385434366464, 24301.1527752991, 24269.96045530984, 24238.808419153993, 24207.69661172785, 24176.624978066873, 24145.593463344056, 24114.602012868283, 24083.650572082726, 24052.73908656324, 24021.867502016845, 23991.035764280212, 23960.24381931818, 23929.491613222315, 23898.779092209486, 23868.10620262049, 23837.472890918667, 23806.879103688603, 23776.3247876348, 23745.809889580407, 23715.334356466003, 23684.898135348318, 23654.50117339906, 23624.143417903753, 23593.824816260603, 23563.545315979303, 23533.304864679994, 23503.10341009219, 23472.94090005366, 23442.81728250946, 23412.732505510867, 23382.686517214413, 23352.679265880903, 23322.71069987445, 23292.78076766157, 23262.889417810242, 23233.036598988994, 23203.222259966067, 23173.44634960853, 23143.70881688143, 23114.009610846988, 23084.348680663752, 23054.725975585814, 23025.141444962082, 22995.595038235424, 22966.086704942012, 22936.61639471053, 22907.18405726146, 22877.789642406406, 22848.433100047383, 22819.114380176143, 22789.83343287352, 22760.590208308753, 22731.384656738875, 22702.216728508072, 22673.086374047096, 22643.993543872624, 22614.938188586682, 22585.92025887608, 22556.93970551182, 22527.996479348578, 22499.090531324102, 22470.22181245874, 22441.39027385485, 22412.595866696334, 22383.838542248115, 22355.11825185563, 22326.434946944337, 22297.78857901929, 22269.17909966458, 22240.606460542967, 22212.07061339537, 22183.571510040438, 22155.109102374117, 22126.68334236921, 22098.294182075, 22069.941573616758, 22041.625469195445, 22013.34582108719, 21985.10258164302, 21956.895703288377, 21928.72513852283, 21900.59083991963, 21872.49276012538, 21844.430851859684, 21816.405067914795, 21788.41536115524, 21760.461684517526, 21732.543991009785, 21704.66223371143, 21676.816365772866, 21649.00634041516, 21621.232110929726, 21593.493630678015, 21565.790853091232, 21538.123731670028, 21510.49221998423, 21482.89627167251, 21455.33584044216, 21427.810880068773, 21400.321344395972, 21372.867187335196, 21345.44836286537, 21318.064825032692, 21290.71652795035, 21263.403425798264, 21236.1254728229, 21208.88262333695, 21181.67483171914, 21154.502052413984, 21127.36423993155, 21100.26134884722, 21073.19333380149, 21046.160149499723, 21019.16175071197, 20992.19809227268, 20965.269129080585, 20938.374816098425, 20911.515108352745, 20884.689960933727, 20857.89932899497, 20831.143167753282, 20804.42143248851, 20777.73407854332, 20751.08106132304, 20724.462336295466, 20697.877858990658, 20671.327585000767, 20644.811469979875, 20618.3294696438, 20591.881539769915, 20565.467636196998, 20539.08771482507, 20512.74173161519, 20486.429642589326, 20460.151403830147, 20433.906971480938, 20407.696301745353, 20381.519350887338, 20355.376075230917, 20329.266431160067, 20303.190375118542, 20277.14786360979, 20251.13885319671, 20225.163300501572, 20199.221162205868, 20173.312395050118, 20147.436955833815, 20121.59480141521, 20095.78588871121, 20070.01017469723, 20044.267616407073, 20018.558170932756, 19992.881795424473, 19967.238447090327, 19941.628083196316, 19916.050661066172, 19890.506138081197, 19864.994471680184, 19839.515619359274, 19814.069538671833, 19788.656187228342, 19763.27552269626, 19737.927502799925, 19712.61208532042, 19687.32922809546, 19662.078889019274, 19636.861026042498, 19611.67559717206, 19586.52256047108, 19561.401874058694, 19536.313496110066, 19511.25738485615, 19486.23349858367, 19461.24179563496, 19436.28223440789, 19411.354773355728, 19386.45937098709, 19361.595985865773, 19336.7645766107, 19311.965101895767, 19287.1975204498, 19262.461791056427, 19237.757872553946, 19213.085723835306, 19188.44530384791, 19163.83657159361, 19139.25948612852, 19114.714006563016, 19090.200092061546, 19065.717701842615, 19041.266795178646, 19016.847331395875, 18992.45926987431, 18968.102570047577, 18943.777191402885, 18919.483093480903, 18895.220235875666, 18870.988578234494, 18846.788080257928, 18822.61870169958, 18798.480402366094, 18774.37314211704, 18750.296880864862, 18726.25157857472, 18702.23719526447, 18678.25369100453, 18654.301025917855, 18630.379160179786, 18606.488054017987, 18582.627667712404, 18558.79796159511, 18534.998896050274, 18511.230431514065, 18487.492528474562, 18463.785147471688, 18440.108249097113, 18416.461793994175, 18392.84574285782, 18369.260056434483, 18345.704695522047, 18322.179620969742, 18298.684793678076, 18275.22017459875, 18251.785724734582, 18228.381405139437, 18205.00717691813, 18181.663001226363, 18158.348839270664, 18135.06465230827, 18111.810401647093, 18088.586048645608, 18065.391554712816, 18042.22688130811, 18019.091989941277, 17995.986842172373, 17972.91139961165, 17949.865623919504, 17926.84947680638, 17903.86292003271, 17880.905915408846, 17857.97842479497, 17835.080410101018, 17812.21183328665, 17789.372656361127, 17766.56284138326, 17743.782350461355, 17721.0311457531, 17698.309189465537, 17675.61644385497, 17652.952871226895, 17630.318433935947, 17607.713094385792, 17585.136815029084, 17562.589558367406, 17540.07128695118, 17517.581963379595, 17495.12155030056 ], "yaxis": "y" }, { "hovertemplate": "name=MiniBatch
iter=%{x}
cost=%{y}", "legendgroup": "MiniBatch", "line": { "color": "#EF553B", "dash": "solid" }, "mode": "lines", "name": "MiniBatch", "showlegend": true, "type": "scattergl", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 474, 475, 476, 477, 478, 479, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 598, 599, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 689, 690, 691, 692, 693, 694, 695, 696, 697, 698, 699, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 742, 743, 744, 745, 746, 747, 748, 749, 750, 751, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, 836, 837, 838, 839, 840, 841, 842, 843, 844, 845, 846, 847, 848, 849, 850, 851, 852, 853, 854, 855, 856, 857, 858, 859, 860, 861, 862, 863, 864, 865, 866, 867, 868, 869, 870, 871, 872, 873, 874, 875, 876, 877, 878, 879, 880, 881, 882, 883, 884, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898, 899, 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 5065244.639730797, 4061222.9610785646, 3258355.5157336686, 2616591.1806207327, 2103191.923809959, 1692687.5869665532, 1364239.6060584434, 1101621.0339929592, 891540.8967494613, 723477.2754722112, 588887.2908637375, 481204.1474146515, 394995.577261228, 325887.7629149927, 270524.4384226007, 226166.19238787092, 190587.08912935783, 161986.15560165062, 139053.24830534373, 120577.63964600832, 105691.18566881996, 93655.13442470186, 83925.50698486331, 76031.40963324744, 69612.35492305702, 64352.10300554928, 60033.90617153689, 56478.247125839145, 53526.51943206945, 51066.861015611554, 48984.31366384988, 47224.132276634875, 45714.62519967971, 44404.6693666994, 43261.29739108589, 42244.95250982238, 41334.32975956231, 40507.88428011306, 39754.74434678293, 39057.61013746979, 38406.93806307833, 37794.94185690246, 37213.714595667705, 36661.619790015415, 36129.599965103625, 35619.112090749986, 35125.14578793858, 34645.70501225057, 34177.51823371247, 33721.13352311675, 33275.033834662216, 32837.36186598206, 32407.1146359097, 31984.701385056494, 31569.28999522978, 31161.186312086254, 30759.300030508966, 30363.33466865436, 29972.878732524423, 29587.774263557734, 29208.094499916737, 28833.878673347084, 28464.867260375624, 28100.60351978511, 27741.212790739337, 27386.435457731954, 27036.490577138793, 26691.054623775963, 26350.235140982855, 26013.598318454264, 25681.394420625504, 25353.520720870627, 25029.858502502968, 24710.321406654388, 24394.90762550699, 24083.579247081667, 23776.165356080048, 23472.767258205815, 23173.252808433863, 22877.592503598098, 22585.68836333888, 22297.512914955907, 22013.063823284625, 21732.219013525715, 21455.004814092496, 21181.317107024184, 20911.147250376867, 20644.430733488196, 20381.134575997712, 20121.205943350564, 19864.579430085367, 19611.244212989743, 19361.146259889552, 19114.257729926278, 18870.51710795833, 18629.88156723206, 18392.323531881164, 18157.809606886687, 17926.307462626173, 17697.740264109758, 17472.103727861013, 17249.34137091363, 17029.44936279052, 16812.34469588842, 16598.024099078495, 16386.455122195708, 16177.570450784464, 15971.36929218224, 15767.803653120936, 15566.820961154252, 15368.412636805333, 15172.528180383795, 14979.163975512074, 14788.260370753012, 14599.804829138233, 14413.755369833678, 14230.068020482595, 14048.747415111471, 13869.743379788164, 13693.026314919684, 13518.566524466012, 13346.31410794208, 13176.26211056315, 13008.39595465882, 12842.661076316823, 12679.053220501424, 12517.533361538255, 12358.080813939878, 12200.658320173046, 12045.229679487735, 11891.81081286779, 11740.345269989626, 11590.810646106147, 11443.185237069705, 11297.432181730124, 11153.558955038574, 11011.521104269726, 10871.296069024309, 10732.85797814846, 10596.183973452102, 10461.249150651218, 10328.039999655684, 10196.536950459922, 10066.697710071805, 9938.533110383278, 9811.995073854641, 9687.076097241606, 9563.728185589165, 9441.977576779715, 9321.752694656525, 9203.083147419435, 9085.93025853406, 8970.27879385354, 8856.092968817708, 8743.370979655874, 8632.080510223168, 8522.203412667279, 8413.736726353, 8306.652162078732, 8200.926892598098, 8096.552943421141, 7993.512869744163, 7891.787845689834, 7791.355903296961, 7692.202943726004, 7594.322539076802, 7497.687382722653, 7402.274315504244, 7308.082927189432, 7215.092587943383, 7123.285696191382, 7032.647689562566, 6943.169573891221, 6854.831084833164, 6767.625669935866, 6681.519951784935, 6596.511028285779, 6512.598432999501, 6429.746019476711, 6347.954487321316, 6267.203880460177, 6187.479021238533, 6108.776733235894, 6031.0758659872245, 5954.36398743193, 5878.623545272303, 5803.847414552948, 5730.023893978606, 5657.138292526943, 5585.192748733189, 5514.164669726639, 5444.033287397182, 5374.801234045469, 5306.451157759624, 5238.973308967703, 5172.354971820689, 5106.578818112068, 5041.646401855944, 4977.537977506936, 4914.245866084557, 4851.76014310869, 4790.069029312101, 4729.160566924806, 4669.031246021417, 4609.668805486062, 4551.063511770157, 4493.203709421609, 4436.079002827473, 4379.682738875999, 4324.004987391663, 4269.035226699612, 4214.762194763374, 4161.181756217032, 4108.285501094598, 4056.0637165396465, 4004.5062649561687, 3953.605376676965, 3903.3509934713747, 3853.738906983266, 3804.7572234357685, 3756.4004678254364, 3708.6581810841485, 3661.5215534651365, 3614.983866040065, 3569.041678441662, 3523.6832184834007, 3478.9040746441615, 3434.693110997371, 3391.043000389338, 3347.9464982530603, 3305.403529166948, 3263.4021999598313, 3221.9326265375444, 3180.9951644581506, 3140.5755013087805, 3100.6708674816755, 3061.2718939147135, 3022.37650677903, 2983.976749409737, 2946.066116587147, 2908.635100915575, 2871.6791745901164, 2835.196247151337, 2799.177213494948, 2763.6144696818556, 2728.5055593233583, 2693.843313678603, 2659.622447005443, 2625.836504061548, 2592.48032305988, 2559.549044412419, 2527.0326837440507, 2494.930281586642, 2463.2382893917475, 2431.9488008685767, 2401.05858058916, 2370.5624821027823, 2340.454216762415, 2310.728361699077, 2281.380950695732, 2252.4068976663157, 2223.801708032317, 2195.5535866256714, 2167.670850640533, 2140.1421452122468, 2112.9624217581936, 2086.1304773733236, 2059.6379631868094, 2033.4808319899769, 2007.6576722718746, 1982.1628222560935, 1956.9932487140636, 1932.1417229314666, 1907.6076140213413, 1883.3862261395607, 1859.4716931747419, 1835.8607098139992, 1812.549100923485, 1789.535714336354, 1766.8155364747201, 1744.382358442498, 1722.2324556597196, 1700.366871083228, 1678.7779089724725, 1657.4641921727766, 1636.4209830652205, 1615.6463868237615, 1595.1350197412185, 1574.8845370023396, 1554.891286483354, 1535.153367753945, 1515.6661844599798, 1496.425652149856, 1477.428934221833, 1458.6741806191114, 1440.155867270059, 1421.873852058612, 1403.8251960047187, 1386.0045792931396, 1368.4124094370009, 1351.0429493445436, 1333.8947273072013, 1316.964531545008, 1300.2482521733323, 1283.7446533897044, 1267.4504408132589, 1251.3631935824224, 1235.4806379397614, 1219.7996116178913, 1204.318714107589, 1189.03460379187, 1173.9438293030948, 1159.0458485346576, 1144.3366460756054, 1129.8146015055488, 1115.4763376952346, 1101.3204903215753, 1087.3450858967021, 1073.546829161155, 1059.9234090026594, 1046.4736510272005, 1033.193870352863, 1020.0829606490687, 1007.1388142206472, 994.3595203823186, 981.7417466601194, 969.2845361597251, 956.9852656514173, 944.8424965901056, 932.8543250764043, 921.0175493853644, 909.3318445690658, 897.7932049194949, 886.4022454621528, 875.15656063455, 864.0522592896401, 853.0896285152872, 842.2667064662304, 831.5810420980829, 821.0313834846652, 810.6152909743112, 800.3316497471036, 790.1779359798877, 780.1534830173682, 770.256792635751, 760.4852953671518, 750.8375474667721, 741.3126626879093, 731.9086066026921, 722.6243646446067, 713.4579331615959, 704.4078356254786, 695.4713039824074, 686.6490812019134, 677.9391847526792, 669.3399025268327, 660.8497378267366, 652.4671359603806, 644.1901426313186, 636.0188481211835, 627.9515320828929, 619.9869620207598, 612.1228942659549, 604.3587939424594, 596.6933875825277, 589.1251197500627, 581.653383489483, 574.2765081579956, 566.9932560657298, 559.8022452548879, 552.7026301554947, 545.6931032563677, 538.7722952919617, 531.9392460096478, 525.1931488562038, 518.5328178725944, 511.95694851765774, 505.46436302523153, 499.05362833364757, 492.72429102947825, 486.47579130989413, 480.3064289948936, 474.2156519038533, 468.2023068595023, 462.26531946916623, 456.40358953811983, 450.6160375846558, 444.9019837681866, 439.2602222137439, 433.6903966057739, 428.19087882724114, 422.76150220653506, 417.40057236151404, 412.10782194416424, 406.882123347165, 401.7231345728377, 396.6293688226966, 391.60040355828164, 386.6350849117589, 381.73287492110023, 376.8927989889802, 372.1137542974959, 367.3960603156112, 362.738114948475, 358.1392461693272, 353.59822471259554, 349.11546409374887, 344.68938091754865, 340.3195780606586, 336.00512643717764, 331.74543923083024, 327.5393787740128, 323.38690454051914, 319.2874006124995, 315.2397929000907, 311.2433690100436, 307.2976146917456, 303.40196725883027, 299.5557560030704, 295.7582915859361, 292.0088082909788, 288.30696753018333, 284.6522993812489, 281.04355677742296, 277.4809983851824, 273.9634679930789, 270.49062757776153, 267.0618869414858, 263.67658326276285, 260.33426559435736, 257.03419340153374, 253.77610941063844, 250.55940091569857, 247.38322412783037, 244.24760500476097, 241.15176354620576, 238.09508096096357, 235.07699614676835, 232.0971717545548, 229.1551317660488, 226.25065749209557, 223.3830370501169, 220.55165985492235, 217.75626151448634, 214.99634616011755, 212.2715378287944, 209.58104913352415, 206.92472920510264, 204.30194414426592, 201.7123155962529, 199.15569563973045, 196.63168306669445, 194.13957492207703, 191.67898287571575, 189.24973916287027, 186.8511486782582, 184.48313668395195, 182.14509338946056, 179.8367113798659, 177.55761228170087, 175.3073300909748, 173.0854596189772, 170.89172323402178, 168.7260795096164, 166.58796240866042, 164.47673944367992, 162.3923969319934, 160.3343846400563, 158.3025778961608, 156.2963606658447, 154.31578231289257, 152.3603248644907, 150.4293921638487, 148.52321018727244, 146.64116609517185, 144.78293726296346, 142.94824248029585, 141.13683316917263, 139.3482902873792, 137.58239662863372, 135.83903195892825, 134.1178025721002, 132.4183606923441, 130.74036098656455, 129.0836843919434, 127.44810737134934, 125.83320468204934, 124.23882895394773, 122.66451866873442, 121.1102488734985, 119.57563789332787, 118.06055014619506, 116.56469035077573, 115.08779204297326, 113.62961157697158, 112.18968546062567, 110.76810573207794, 109.36463049870449, 107.97894798812904, 106.61088087405182, 105.26014648191128, 103.92639415161759, 102.60957714042667, 101.30955423057361, 100.02602856688453, 98.75877569293138, 97.50758368536589, 96.27222183933971, 95.05250241084838, 93.848200131357, 92.65915180573785, 91.48517400279343, 90.32609533044032, 89.18178502104772, 88.0518786291247, 86.93637576799338, 85.83499593141866, 84.7476161899518, 83.67398880565908, 82.61385642458663, 81.56722489180076, 80.53384282372924, 79.51358493190384, 78.50626257598772, 77.51163701560546, 76.52965881996113, 75.5601341075326, 74.60282808315807, 73.65766669670688, 72.72452129631381, 71.80320259636999, 70.89357226592797, 69.99553270452098, 69.1088375182127, 68.23336996121608, 67.3689855328386, 66.5156124616017, 65.673000262257, 64.84103158348086, 64.01968396701281, 63.20872557096571, 62.408056888927064, 61.61750045896066, 60.83699188412978, 60.06638666713157, 59.30550587848204, 58.55424553909182, 57.81250375962371, 57.0802090196904, 56.35714744829278, 55.64325254709743, 54.93844463231385, 54.242557427825716, 53.55545088310102, 52.87701536338001, 52.20726512664453, 51.54599403417284, 50.893092453253914, 50.24848464774952, 49.61203192308059, 48.98365443718379, 48.36321581499535, 47.750646288461674, 47.14576879809812, 46.54858481030905, 45.95899923320579, 45.37683383075107, 44.80210401595677, 44.23460973605971, 43.674368905886695, 43.12118546977439, 42.57493883804398, 42.035669699153246, 41.50327602469979, 40.977623881679506, 40.458639884548376, 39.94620283287649, 39.440233740072884, 38.94068369434209, 38.44749119228048, 37.96052328948413, 37.47976018978503, 37.00504471748179, 36.536365531806595, 36.073643246742876, 35.61675901712009, 35.16567668937439, 34.72028371080608, 34.28049568373133, 33.84629504682843, 33.41761952137908, 32.99439838013222, 32.57652995220478, 32.163903631259345, 31.756579433857915, 31.35441069006731, 30.957291060047584, 30.56522716449222, 30.1781033102941, 29.79592820456861, 29.418585831376987, 29.04600097746185, 28.67813144018951, 28.314941270563015, 27.956345006122483, 27.602280925075334, 27.252691128236798, 26.907516191912634, 26.566758116585383, 26.23030885714995, 25.89809236797983, 25.57012764169778, 25.246301402674, 24.926575935873352, 24.61092193719563, 24.29922885204682, 23.99152071938783, 23.68768456372955, 23.387715961896784, 23.091551060510636, 22.799108245049204, 22.510379871785663, 22.225319365592693, 21.943865053217493, 21.665983167986777, 21.39160460551599, 21.12070610396077, 20.853238533411854, 20.589162510719756, 20.328419198645328, 20.070999356971676, 19.816819150046005, 19.565876682893034, 19.318131337861068, 19.073496604509174, 18.83197977789044, 18.59350928855467, 18.358068049167223, 18.125568860731292, 17.896055842243914, 17.669436677915826, 17.44569717171008, 17.22479125132407, 17.006678482461748, 16.791325160191274, 16.57871217886627, 16.36877818965747, 16.161503467419948, 15.956859195443293, 15.75480512012873, 15.555298795290794, 15.35832332428765, 15.163855101411594, 14.971842495265737, 14.782258058759416, 14.5950814987213, 14.410272887067098, 14.22780222125634, 14.047631707148778, 13.869767661257683, 13.694145450414604, 13.520754819281734, 13.349555418867936, 13.18052940706605, 13.013636799148427, 12.848856475981702, 12.686155805570177, 12.525525844268394, 12.366930440498528, 12.210352734447449, 12.055744176872896, 11.903104737240689, 11.75238873064929, 11.603579309891732, 11.456663460528922, 11.311606240941884, 11.16838135586427, 11.026961962592612, 10.887349868199792, 10.749499736713389, 10.61340232367396, 10.479014279622035, 10.34632613356416, 10.215325685311498, 10.08598504041819, 9.958280586942927, 9.832190714829554, 9.707701847489334, 9.584786024766002, 9.463435065934341, 9.343621473867735, 9.225319778359708, 9.108519644809306, 8.993194676944617, 8.879333890623778, 8.766916187166148, 8.655908178889947, 8.546314564168805, 8.43811000761603, 8.331280302718444, 8.225792512664157, 8.121636577502795, 8.018795518711595, 7.9172627661729225, 7.817025433162994, 7.718058233016619, 7.620342236921443, 7.523862771248353, 7.428606149823189, 7.334546280505673, 7.241691175865085, 7.150000729821194, 7.059480181603023, 6.970103590165721, 6.881848415845729, 6.794717916201165, 6.708698534894728, 6.623763891693853, 6.539904060717222, 6.457109446917055, 6.375360963978425, 6.294649811707561, 6.2149629293854405, 6.13627468006379, 6.058584594848207, 5.981882255048136, 5.9061518977252305, 5.831380478880954, 5.7575554162257845, 5.684665654218019, 5.612697076324263, 5.541642467281004, 5.47148493045555, 5.402219374696529, 5.333829194959662, 5.266298432290555, 5.199624364195175, 5.133794205254917, 5.0688017989675895, 5.00463324180771, 4.941277515587271, 4.878719168929473, 4.816955510640689, 4.755972868381919, 4.69575957033538, 4.636312212470718, 4.577619986542097, 4.51966915893324, 4.46245015706719, 4.405957409445572, 4.350181125222825, 4.2951054134426, 4.24073254693166, 4.18704607338109, 4.134042663072299, 4.081707331645461, 4.030036181979203, 3.9790178916645322, 3.9286421989437224, 3.878905373697267, 3.8297998225766756, 3.7813174889790684, 3.7334467837553276, 3.6861863427385853, 3.639522335146065, 3.5934496354937253, 3.547956186460614, 3.503045353533201, 3.4586996798991505, 3.414915860946671, 3.371687184395027, 3.3290062130488574, 3.286862588173124, 3.2452554590107594, 3.20417496492559, 3.163611026290937, 3.123563425117383, 3.084019762227471, 3.0449803998271294, 3.0064330518994087, 2.968375712184987, 2.9307990892151867, 2.8936957343649956, 2.85706545894315, 2.820896794236633, 2.7851833804427466, 2.7499265168445852, 2.7151171463617514, 2.680745409983012, 2.6468072734601065, 2.613299832088115, 2.5802188845878766, 2.5475554348278475, 2.5153072494846227, 2.483467365482975, 2.4520308704498675, 2.420988614988475, 2.3903421615880034, 2.360081562134996, 2.3302060757379333, 2.3007084705010614, 2.2715841562276626, 2.242828112155175, 2.2144369656898895, 2.186405952336414, 2.1587284496473518, 2.1314029086402524, 2.1044234501206307, 2.077784139183912, 2.0514807495599854, 2.025513290717348, 1.9998745856919702, 1.974560203205386, 1.9495659429812404, 1.9248880691858195, 1.900520195588765, 1.8764614230884504, 1.8527097296503485, 1.8292571961278028, 1.8061021517849563, 1.7832401551905903, 1.7606676301369673, 1.738380303677134, 1.7163742728506646, 1.6946487874663285, 1.6731978226181097, 1.6520184973233558, 1.6311065616199674, 1.6104595614815205, 1.5900742472843619, 1.5699474116402459, 1.5500744027068059, 1.5304534259321896, 1.5110816898605806, 1.4919527679278346, 1.4730668102645244, 1.4544199648483178, 1.436009227746339, 1.41783213680492, 1.39988583981568, 1.3821674725669029, 1.3646717501901557, 1.3473978110537417, 1.330341962108903, 1.3135033004193022, 1.29687644927334, 1.280460657301084, 1.2642527788996678, 1.2482491047474165, 1.2324485225304684, 1.2168485543941105, 1.201445874208896, 1.1862383049969887, 1.1712229465049413, 1.1563972878126376, 1.1417597616151682, 1.127307476751413, 1.113038654183903, 1.0989495633520712, 1.0850386864779642, 1.071304434124084, 1.0577442198268963, 1.0443555066115031, 1.031136677837143, 1.0180842439468338, 1.0051980453639784, 0.9924737766148336, 0.9799117634191756, 0.9675082238860728, 0.9552612537440095, 0.9431687983425142, 0.9312311681530983, 0.9194442532838277, 0.9078062128517493, 0.8963154886320688, 0.8849699515895963, 0.8737680145354012, 0.8627085445374126, 0.8517886220550013, 0.8410073789983884, 0.8303617879158072, 0.8198518871121393, 0.8094744448660104, 0.799227923975004, 0.7891117547766395, 0.7791239808574298, 0.7692613366386147, 0.7595245025781007, 0.7499112675108233, 0.7404195435265781, 0.7310478749664804, 0.7217951768960025, 0.7126589703859421, 0.7036388496472824, 0.6947326081960783, 0.6859385721382097, 0.6772567209131198, 0.6686847594433567, 0.6602214851645714, 0.6518647845944443, 0.6436141919219082, 0.6354680357647537, 0.6274250144430444, 0.6194837983051651, 0.611640789496596, 0.6038992513255663, 0.5962548327283738, 0.5887080257219707, 0.5812567242569053, 0.5738990589479527, 0.5666352735082507, 0.5594628307584038, 0.5523814579575446, 0.5453899189148226, 0.5384868047305802, 0.5316713849771977, 0.524941819720594, 0.5182971988966222, 0.5117368532268639, 0.5052596730021132, 0.49886411522963625, 0.49254995045423156, 0.48631598914370655, 0.48016075375500167, 0.4740834799063116, 0.46808301553841086, 0.46215853303888305, 0.45630917915700997, 0.4505337779359162, 0.4448315780330908, 0.4392008777675451, 0.4336422446538328, 0.42815288243167793, 0.42273358490037294, 0.4173828514519049, 0.41209944374117996, 0.40688394104346876, 0.4017337945162659, 0.3966492293004991, 0.39162920895862263, 0.3866725587458665, 0.3817787530084066, 0.3769466286251569, 0.37217593504809193, 0.36746542402077087, 0.3628144477046511, 0.3582222904426865, 0.3536882011188218, 0.3492116637358518, 0.3447917740688988, 0.340427713954743, 0.33611899596403916, 0.331864497849082, 0.3276639760119312, 0.32351690340963674, 0.31942235369776417, 0.3153796305210932, 0.3113874859835171, 0.30744632824576207, 0.303555270472017, 0.2997130978539106, 0.2959192971029999, 0.29217401487373995, 0.28847602108750325, 0.28482509063853645, 0.28122022680882275, 0.2776607060961427, 0.2741462502954257, 0.2706767317329077, 0.26725098116664237, 0.2638681216762432, 0.2605282738435996, 0.2572306763902571, 0.25397479054927136, 0.2507600099444221, 0.24758611561967983, 0.24445253887794555, 0.24135847296142898, 0.23830344115937327, 0.23528741951133375, 0.23230949104414145, 0.22936926932555474, 0.22646629048832895, 0.22360004279692652, 0.22076975897379503, 0.2179755935322638, 0.21521684142109387, 0.2124929024180948, 0.20980352019149323, 0.20714811261928184, 0.20452625460044288, 0.2019376777072579, 0.199381889244796, 0.19685827738342265, 0.1943665363506618, 0.19190648890162554, 0.1894777564575314, 0.18707973817537799, 0.18471215328380014, 0.1823743327598077 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "name" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "iter" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "cost" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from copy import copy\n", "from random import random\n", "from IPython.display import HTML\n", "from tqdm import tqdm, trange\n", "\n", "\n", "def mini_batch(X, y, \n", " max_epoch = 1000, traceback = None, stopping_threshold = 1.0e-6\n", " , starting_point = None\n", " , learning_rate = 0.03, num_batches=10):\n", " \n", " # number of samples\n", " m = X.shape[0]\n", " \n", " # number of parameters\n", " n = X.shape[1]\n", " \n", " # idx -- instead of creating copy of data\n", " # we will lookup chunks based on indexes\n", " indexes = list(range(m))\n", " \n", " # starting point -- randomly select\n", " theta1 = np.array([random() for i in range(n)]) if starting_point is None else starting_point\n", " \n", " for iter in trange(max_epoch):\n", " \n", " if traceback is not None:\n", " traceback.add(iter, theta1, mse(X, y, theta1))\n", " \n", " # \n", " # now we create multiple batches of data \n", " # and iterate through each batch and update the parameter\n", " #\n", " np.random.shuffle(indexes)\n", " for batchIdx in np.array_split(indexes, num_batches):\n", " \n", " bX = X[batchIdx]\n", " by = y[batchIdx]\n", "\n", " # compute average gradient for all data points\n", " # and move in the opposite direction\n", " grad = gradient(bX, by, theta1)\n", " theta2 = theta1 - learning_rate * grad\n", "\n", " # check if we reached stopping criteria threshold\n", " if np.linalg.norm(grad) < stopping_threshold:\n", " print(\"Early Stopping at Iteration Number: \", iter)\n", " return theta2\n", " elif np.all(np.isnan(theta2)):\n", " raise Exception(\"All nan\")\n", " \n", "\n", " theta1 = theta2\n", " \n", " # if we reached max iterations then return current point\n", " return theta1\n", "\n", "\n", "tracebacks['MiniBatch'] = Traceback(\"MiniBatch\", 3)\n", "theta = mini_batch(X, y, learning_rate=0.009, max_epoch=1000, traceback=tracebacks['MiniBatch'], stopping_threshold=1e-6, starting_point=starting_point, num_batches=10)\n", "\n", "display(HTML(\"Optimized Parameters: {}\".format(theta)))\n", "\n", "plotCost(tracebacks.values())\n" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-11-21T16:59:59.233326Z", "start_time": "2019-11-21T16:59:59.228838Z" } }, "source": [ "As we can see from the above plot, the MSE drops much faster when using minibatch gradient descent. Also, for the same learning rate and max number of epoch, the coefficients are more closer to the real optimal value. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Momentum" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-11-21T17:04:58.241227Z", "start_time": "2019-11-21T17:04:58.236846Z" } }, "source": [ "As compared to Batch Gradient Descent, Mini Batch is much faster. But it still leaves room for improvment. Think of a ball rolling down the hill. As long as the ball is rolling in one direction, it gains velocity but as soon as it changes direction, it's velocity reduces. Another way to think about this is looking at component vectors of the gradient as shown in the image below. Let's assume we computed the gradient at pt A and then pt B. If we look at the component vectors of the gradient at the two points, the two are in the same direction and thus it indicates that we are going in the right direction and ideally should move even more faster. But as we move from point B to C, the horizontal component vector are in the opposite direction and therefore indicates that we should now slow down. \n", "\n", "![momentum](images/momentum.png)\n", "\n", "Thus, one idea is to adjust the vector scomponents of the gradient based on the previously observed values of the gradient. In Momentum gradient descent, we use exponentially average. Essentially, the last observed gradient descent has the weight of $\\beta$. The one before that has the weight of $\\beta^2$ and so on. In other words, the effective gradient is computed in the following manner:\n", "\n", "$$g = \\beta g + (1-\\beta)\\frac{\\delta{X}}{\\delta{\\theta}}$$\n", "\n", "Below is the python implementation of the momentum gradient descent algorithm. Note that most of the logic is same except that we have an additional parameter, momentum, and an additional step to take exponential average of gradient. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:34.459582Z", "start_time": "2020-05-19T23:32:33.880889Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1000/1000 [00:00<00:00, 1935.80it/s]\n" ] }, { "data": { "text/html": [ "Optimized Parameters: [99.96896252 4.04618255 2.04114264]" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "name=MiniBatch
iter=%{x}
cost=%{y}", "legendgroup": "MiniBatch", "line": { "color": "#636efa", "dash": "solid" }, "mode": "lines", "name": "MiniBatch", "showlegend": true, "type": "scatter", "x": [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 ], "xaxis": "x", "y": [ 588887.2908637375, 481204.1474146515, 394995.577261228, 325887.7629149927, 270524.4384226007, 226166.19238787092, 190587.08912935783, 161986.15560165062, 139053.24830534373, 120577.63964600832, 105691.18566881996, 93655.13442470186, 83925.50698486331, 76031.40963324744, 69612.35492305702, 64352.10300554928, 60033.90617153689, 56478.247125839145, 53526.51943206945, 51066.861015611554, 48984.31366384988, 47224.132276634875, 45714.62519967971, 44404.6693666994, 43261.29739108589, 42244.95250982238, 41334.32975956231, 40507.88428011306, 39754.74434678293, 39057.61013746979, 38406.93806307833 ], "yaxis": "y" }, { "hovertemplate": "name=Momentum
iter=%{x}
cost=%{y}", "legendgroup": "Momentum", "line": { "color": "#EF553B", "dash": "solid" }, "mode": "lines", "name": "Momentum", "showlegend": true, "type": "scatter", "x": [ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 ], "xaxis": "x", "y": [ 583771.7239374709, 465090.4048498711, 372935.08288483147, 301080.4281308403, 245373.59900046457, 201650.07614836254, 167748.79736781836, 141021.45872618433, 120287.41552136929, 104145.30090036083, 91310.14380055107, 81234.00754556902, 73455.41293087407, 67205.8433771112, 62131.84578595614, 58048.95814474978, 54812.91387590371, 52198.415921903914, 50053.963192984724, 48242.90248425254, 46728.016795224765, 45389.57148559094, 44273.60722340114, 43297.957741777165, 42376.09236121424, 41575.36981243179, 40845.85837193482, 40183.89539922823, 39548.855219344565, 38941.78702153959, 38367.35885705414 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "name" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "iter" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "cost" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from copy import copy\n", "from random import random\n", "from IPython.display import HTML\n", "from tqdm import tqdm, trange\n", "\n", "\n", "def momentum(X, y, learning_rate = 0.09, momentum = 0.9, \n", " max_epoch = 1000, traceback = None, stopping_threshold = 1.0e-6\n", " , starting_point = None\n", " , num_batches = 10):\n", " \"\"\"Minimizes \n", " momenutum -- how much weight historical gradient should carry. A good default value is 0.9\n", " \"\"\"\n", " if 1 < momentum < 0:\n", " raise ValueError(\"Momentum should between 0 and 1\")\n", " \n", " # number of samples\n", " m = X.shape[0]\n", " \n", " # number of parameters\n", " n = X.shape[1]\n", " \n", " # idx\n", " indexes = list(range(m))\n", " \n", " # starting point -- randomly select\n", " theta1 = np.array([random() for i in range(n)]) if starting_point is None else starting_point\n", " grad = np.zeros(n)\n", " \n", " for iter in trange(max_epoch):\n", " \n", " if traceback is not None:\n", " traceback.add(iter, theta1, mse(X, y, theta1))\n", " \n", " # create batches\n", " np.random.shuffle(indexes)\n", " for batchIdx in np.array_split(indexes, num_batches):\n", " \n", " bX = X[batchIdx]\n", " by = y[batchIdx]\n", " \n", " #========================================\n", " # Instead of taking the gradient, we compute\n", " # exponetial average gradient\n", " #========================================\n", " grad = (momentum * grad) + (1 - momentum) * gradient(bX, by, theta1) \n", " theta2 = theta1 - learning_rate * grad\n", "\n", " # check if we reached stopping criteria threshold\n", " \n", " if np.linalg.norm(grad) < stopping_threshold:\n", " print(\"Early Stopping at Iteration Number: \", iter)\n", " return theta2\n", "\n", " theta1 = theta2\n", " \n", " # if we reached max iterations then return current point\n", " return theta1\n", "\n", "\n", "tracebacks['Momentum'] = Traceback('Momentum', 3)\n", "theta = momentum(X, y, learning_rate=0.009, \n", " momentum=0.9, max_epoch=1000, traceback=tracebacks['Momentum'], \n", " stopping_threshold=1e-6, starting_point=starting_point)\n", "\n", "display(HTML(\"Optimized Parameters: {}\".format(theta)))\n", "\n", "\n", "plotCost(tracebacks.values(), min_iter=10, max_iter = 40, exclude=['BatchGradientDescent'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## RMSPROP\n", "\n", "RMSProp was one of the major development and fueled the growth of deep learning. While momentum leveraged historical gradients to speed up the gradient descent algorithm, one still has to provide right learning rate. RMSProp addresses this problem by automatically adjusting learning rate along each component of the gradient descent. You can find a good introduction of the methodology over [here](https://blog.paperspace.com/intro-to-optimization-momentum-rmsprop-adam/). The key equations are:\n", "\n", "$$ g = \\beta(g) + (1-\\beta)(\\frac{\\delta{X}}{\\delta{\\theta}})^2 $$\n", "\n", "and \n", "\n", "$$ \\hat{\\eta} = \\frac{\\eta}{\\sqrt{g} + 1e^{-10}} \\frac{\\delta{X}}{\\delta{\\theta}}$$\n", "\n", "where $\\eta$ is the provided learning rate and $\\hat{\\eta}$ is adjusted learning rate" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:36.384164Z", "start_time": "2020-05-19T23:32:35.787629Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 1000/1000 [00:00<00:00, 1897.80it/s]\n" ] }, { "data": { "text/html": [ "Optimized Parameters: [99.65615487 3.59225968 1.5033052 ]" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "name=MiniBatch
iter=%{x}
cost=%{y}", "legendgroup": "MiniBatch", "line": { "color": "#636efa", "dash": "solid" }, "mode": "lines", "name": "MiniBatch", "showlegend": true, "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 ], "xaxis": "x", "y": [ 5065244.639730797, 4061222.9610785646, 3258355.5157336686, 2616591.1806207327, 2103191.923809959, 1692687.5869665532, 1364239.6060584434, 1101621.0339929592, 891540.8967494613, 723477.2754722112, 588887.2908637375, 481204.1474146515, 394995.577261228, 325887.7629149927, 270524.4384226007, 226166.19238787092, 190587.08912935783, 161986.15560165062, 139053.24830534373, 120577.63964600832, 105691.18566881996, 93655.13442470186, 83925.50698486331, 76031.40963324744, 69612.35492305702, 64352.10300554928, 60033.90617153689, 56478.247125839145, 53526.51943206945, 51066.861015611554, 48984.31366384988, 47224.132276634875, 45714.62519967971, 44404.6693666994, 43261.29739108589, 42244.95250982238, 41334.32975956231, 40507.88428011306, 39754.74434678293, 39057.61013746979, 38406.93806307833, 37794.94185690246, 37213.714595667705, 36661.619790015415, 36129.599965103625, 35619.112090749986, 35125.14578793858, 34645.70501225057, 34177.51823371247, 33721.13352311675, 33275.033834662216 ], "yaxis": "y" }, { "hovertemplate": "name=Momentum
iter=%{x}
cost=%{y}", "legendgroup": "Momentum", "line": { "color": "#EF553B", "dash": "solid" }, "mode": "lines", "name": "Momentum", "showlegend": true, "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 ], "xaxis": "x", "y": [ 5065244.639730797, 4620605.15003263, 3848441.9819915476, 3089542.954856953, 2442961.857404097, 1920596.7162602618, 1507462.7247881317, 1184365.1829872134, 932449.573171077, 736269.8624882791, 583771.7239374709, 465090.4048498711, 372935.08288483147, 301080.4281308403, 245373.59900046457, 201650.07614836254, 167748.79736781836, 141021.45872618433, 120287.41552136929, 104145.30090036083, 91310.14380055107, 81234.00754556902, 73455.41293087407, 67205.8433771112, 62131.84578595614, 58048.95814474978, 54812.91387590371, 52198.415921903914, 50053.963192984724, 48242.90248425254, 46728.016795224765, 45389.57148559094, 44273.60722340114, 43297.957741777165, 42376.09236121424, 41575.36981243179, 40845.85837193482, 40183.89539922823, 39548.855219344565, 38941.78702153959, 38367.35885705414, 37808.60750563158, 37287.38640371237, 36772.199847370575, 36280.02941329773, 35797.662011162334, 35319.29233971222, 34848.70943835979, 34392.98462101896, 33940.91811301765, 33498.50083319165 ], "yaxis": "y" }, { "hovertemplate": "name=RMSProp
iter=%{x}
cost=%{y}", "legendgroup": "RMSProp", "line": { "color": "#00cc96", "dash": "solid" }, "mode": "lines", "name": "RMSProp", "showlegend": true, "type": "scatter", "x": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50 ], "xaxis": "x", "y": [ 5065244.639730797, 2914307.9349795124, 1932667.9367880723, 1264690.2570680422, 801849.7807773962, 505559.6254926142, 337678.89245594223, 254054.38057477592, 201386.5995660029, 151274.83911611524, 105273.5441077629, 67897.98373656848, 38471.792573796614, 18611.749694586244, 6913.340198001304, 1624.6851585817462, 169.79862032656104, 714.2324527887833, 302.7025843611166, 496.4599269158853, 565.1655138618597, 129.2506577786059, 302.68857901138426, 367.72843511681987, 508.682187797169, 90.03952911763326, 376.3503491496908, 562.0826302530768, 306.2100440314381, 252.4316827148668, 793.5674475148246, 241.42548567780807, 263.110972152386, 304.1878312025898, 97.38605066472584, 287.1674139122006, 254.23412274109344, 152.81667365893702, 186.29133438515908, 167.60289160025306, 229.6101336656462, 618.1613852119049, 261.40070493864374, 331.9742455510785, 320.81844315935075, 184.29214877138952, 127.57759928575318, 483.0076332897137, 161.40281543079902, 274.50547359513536, 475.9936963676538 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "name" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "iter" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "cost" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "from copy import copy\n", "from random import random\n", "from IPython.display import HTML\n", "from tqdm import tqdm, trange\n", "\n", "\n", "def rmsprop(X, y, learning_rate = 0.9, momentum = 0.9, \n", " max_epoch = 1000, traceback = None, stopping_threshold = 1.0e-6\n", " , starting_point = None\n", " , num_batches = 10):\n", " \"\"\"Minimizes \n", " X -- data frame containing X1 and X2 \n", " y -- actual output values \n", " learning rate \n", " max_iterations\n", " traceback -- keep track of parameters\n", " stopping_threshold -- max distance between previous and new parameters at which it the algorithm should stop. \n", " \"\"\"\n", " if 1 < momentum < 0:\n", " raise ValueError(\"Momentum should between 0 and 1\")\n", " \n", " # number of samples\n", " m = X.shape[0]\n", " \n", " # number of parameters\n", " n = X.shape[1]\n", " \n", " # idx\n", " indexes = list(range(m))\n", " \n", " # starting point -- randomly select\n", " theta1 = np.array([random() for i in range(n)]) if starting_point is None else starting_point\n", " grad = np.zeros(n)\n", " grad2 = np.zeros(n)\n", " \n", " \n", " for iter in trange(max_epoch):\n", " \n", " if traceback is not None:\n", " traceback.add(iter, theta1, mse(X, y, theta1))\n", " \n", " # create batches\n", " np.random.shuffle(indexes)\n", " for batchIdx in np.array_split(indexes, num_batches):\n", " \n", " bX = X[batchIdx]\n", " by = y[batchIdx]\n", "\n", "\n", " # compute average gradient for all data points\n", " # and move in the opposite direction\n", " grad = gradient(bX, by, theta1)\n", " grad2 = (momentum * grad2) + (1 - momentum) * grad * grad\n", " weight = (learning_rate / (np.sqrt(grad2) + 1e-10)) * grad\n", " theta2 = theta1 - weight\n", " \n", "\n", " # check if we reached stopping criteria threshold\n", " \n", " if np.linalg.norm(grad) < stopping_threshold:\n", " print(\"Early Stopping at Iteration Number: \", iter)\n", " return theta2\n", "\n", " theta1 = theta2\n", " \n", " # if we reached max iterations then return current point\n", " return theta1\n", "\n", "\n", "tracebacks['RMSProp'] = Traceback('RMSProp', 3)\n", "theta = rmsprop(X, y, learning_rate=0.9, momentum=0.9, \n", " max_epoch=1000, traceback=tracebacks['RMSProp'], \n", " stopping_threshold=1e-6, starting_point=starting_point, \n", " num_batches=10)\n", "\n", "display(HTML(\"Optimized Parameters: {}\".format(theta)))\n", "\n", "plotCost(tracebacks.values(), min_iter=0, max_iter = 50, exclude=['BatchGradientDescent'])" ] }, { "cell_type": "markdown", "metadata": { "ExecuteTime": { "end_time": "2019-11-25T16:54:49.677340Z", "start_time": "2019-11-25T16:54:49.458189Z" } }, "source": [ "## Conclusion\n", "\n", "In this chapter, I touched few of the variants of gradient descent algorithm. While RMSProp tends to often perform better, certain situations might require a different variants such as NAD, Adam, etc. A good summary of different variants of gradient descent is available over [here](https://towardsdatascience.com/gradient-descent-algorithm-and-its-variants-10f652806a3). Below table summarizes key consideration points for different variants.\n", "\n", "\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
AlgorithmParametersAdvantagesIssues
Stochastic Gradient Descent (SGD)learning rate, max epoch\n", "
    \n", "
  • For large dataset, it can converge faster as parameters are updated more frequently.
  • \n", "
  • Low Memory requirement as only one example is evaluated at a time.
  • \n", "
\n", "
\n", "
    \n", "
  • Gradient direction is very noisy and thereby might take longer to converge.
  • \n", "
  • Frequent updates are computational expensive.
  • \n", "
  • loses the advantages of vectorized computation.
  • \n", "
\n", "
Batch Gradient Descentlearning rate, max epoch\n", "
    \n", "
  • Less oscillations and, thereby, more stable gradient descent convergence
  • \n", "
  • Vectorization increases the speed of processing
  • \n", "
\n", "
\n", "
    \n", "
  • More chances of getting stuck in local minima
  • \n", "
  • Memory intensive as the full training dataset needs to keep in memory
  • \n", "
\n", "
Min Batch Gradient Descentlearning rate, max epoch, either number of batches or batch size\n", "
    \n", "
  • Less memory intensive
  • \n", "
  • Computationally efficient as it takes advantages of vectorization
  • \n", "
  • Stable convergence as compared to SGD
  • \n", "
\n", "
\n", "
    \n", "
  • Convergence is noiser than Batch Gradient Descent
  • \n", "
\n", "
Momenutm Gradient Descentlearning rate, max epoch, either number of batches or batch size, momentum (=0.9 by default)\n", "
    \n", "
  • has all the advantages of mini-batch but is usually faster to converge
  • \n", "
\n", "
\n", "
    \n", "
\n", "
RMSProplearning rate, max epoch, either number of batches or batch size, momentum (=0.9 by default), \\epsilon(=1.0e-6 by default)\n", "
    \n", "
  • has all the advantages of momentum gradient descent but is usually faster to converge
  • \n", "
\n", "
\n", "
    \n", "
\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# TODO\n", "\n", "RMSProp shows significant improvement over all the previous versions of the gradient descent. But doesn't converge as compared to other variants. Below plot shows MSE for the different algorithms." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2020-05-19T23:32:43.838237Z", "start_time": "2020-05-19T23:32:43.760542Z" } }, "outputs": [ { "data": { "application/vnd.plotly.v1+json": { "config": { "plotlyServerURL": "https://plot.ly" }, "data": [ { "hovertemplate": "name=BatchGradientDescent
iter=%{x}
cost=%{y}", "legendgroup": "BatchGradientDescent", "line": { "color": "#636efa", "dash": "solid" }, "mode": "lines", "name": "BatchGradientDescent", "showlegend": true, "type": "scatter", "x": [ 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 19864.994471680184, 19839.515619359274, 19814.069538671833, 19788.656187228342, 19763.27552269626, 19737.927502799925, 19712.61208532042, 19687.32922809546, 19662.078889019274, 19636.861026042498, 19611.67559717206, 19586.52256047108, 19561.401874058694, 19536.313496110066, 19511.25738485615, 19486.23349858367, 19461.24179563496, 19436.28223440789, 19411.354773355728, 19386.45937098709, 19361.595985865773, 19336.7645766107, 19311.965101895767, 19287.1975204498, 19262.461791056427, 19237.757872553946, 19213.085723835306, 19188.44530384791, 19163.83657159361, 19139.25948612852, 19114.714006563016, 19090.200092061546, 19065.717701842615, 19041.266795178646, 19016.847331395875, 18992.45926987431, 18968.102570047577, 18943.777191402885, 18919.483093480903, 18895.220235875666, 18870.988578234494, 18846.788080257928, 18822.61870169958, 18798.480402366094, 18774.37314211704, 18750.296880864862, 18726.25157857472, 18702.23719526447, 18678.25369100453, 18654.301025917855, 18630.379160179786, 18606.488054017987, 18582.627667712404, 18558.79796159511, 18534.998896050274, 18511.230431514065, 18487.492528474562, 18463.785147471688, 18440.108249097113, 18416.461793994175, 18392.84574285782, 18369.260056434483, 18345.704695522047, 18322.179620969742, 18298.684793678076, 18275.22017459875, 18251.785724734582, 18228.381405139437, 18205.00717691813, 18181.663001226363, 18158.348839270664, 18135.06465230827, 18111.810401647093, 18088.586048645608, 18065.391554712816, 18042.22688130811, 18019.091989941277, 17995.986842172373, 17972.91139961165, 17949.865623919504, 17926.84947680638, 17903.86292003271, 17880.905915408846, 17857.97842479497, 17835.080410101018, 17812.21183328665, 17789.372656361127, 17766.56284138326, 17743.782350461355, 17721.0311457531, 17698.309189465537, 17675.61644385497, 17652.952871226895, 17630.318433935947, 17607.713094385792, 17585.136815029084, 17562.589558367406, 17540.07128695118, 17517.581963379595, 17495.12155030056 ], "yaxis": "y" }, { "hovertemplate": "name=MiniBatch
iter=%{x}
cost=%{y}", "legendgroup": "MiniBatch", "line": { "color": "#EF553B", "dash": "solid" }, "mode": "lines", "name": "MiniBatch", "showlegend": true, "type": "scatter", "x": [ 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 0.6436141919219082, 0.6354680357647537, 0.6274250144430444, 0.6194837983051651, 0.611640789496596, 0.6038992513255663, 0.5962548327283738, 0.5887080257219707, 0.5812567242569053, 0.5738990589479527, 0.5666352735082507, 0.5594628307584038, 0.5523814579575446, 0.5453899189148226, 0.5384868047305802, 0.5316713849771977, 0.524941819720594, 0.5182971988966222, 0.5117368532268639, 0.5052596730021132, 0.49886411522963625, 0.49254995045423156, 0.48631598914370655, 0.48016075375500167, 0.4740834799063116, 0.46808301553841086, 0.46215853303888305, 0.45630917915700997, 0.4505337779359162, 0.4448315780330908, 0.4392008777675451, 0.4336422446538328, 0.42815288243167793, 0.42273358490037294, 0.4173828514519049, 0.41209944374117996, 0.40688394104346876, 0.4017337945162659, 0.3966492293004991, 0.39162920895862263, 0.3866725587458665, 0.3817787530084066, 0.3769466286251569, 0.37217593504809193, 0.36746542402077087, 0.3628144477046511, 0.3582222904426865, 0.3536882011188218, 0.3492116637358518, 0.3447917740688988, 0.340427713954743, 0.33611899596403916, 0.331864497849082, 0.3276639760119312, 0.32351690340963674, 0.31942235369776417, 0.3153796305210932, 0.3113874859835171, 0.30744632824576207, 0.303555270472017, 0.2997130978539106, 0.2959192971029999, 0.29217401487373995, 0.28847602108750325, 0.28482509063853645, 0.28122022680882275, 0.2776607060961427, 0.2741462502954257, 0.2706767317329077, 0.26725098116664237, 0.2638681216762432, 0.2605282738435996, 0.2572306763902571, 0.25397479054927136, 0.2507600099444221, 0.24758611561967983, 0.24445253887794555, 0.24135847296142898, 0.23830344115937327, 0.23528741951133375, 0.23230949104414145, 0.22936926932555474, 0.22646629048832895, 0.22360004279692652, 0.22076975897379503, 0.2179755935322638, 0.21521684142109387, 0.2124929024180948, 0.20980352019149323, 0.20714811261928184, 0.20452625460044288, 0.2019376777072579, 0.199381889244796, 0.19685827738342265, 0.1943665363506618, 0.19190648890162554, 0.1894777564575314, 0.18707973817537799, 0.18471215328380014, 0.1823743327598077 ], "yaxis": "y" }, { "hovertemplate": "name=Momentum
iter=%{x}
cost=%{y}", "legendgroup": "Momentum", "line": { "color": "#00cc96", "dash": "solid" }, "mode": "lines", "name": "Momentum", "showlegend": true, "type": "scatter", "x": [ 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 0.6098040991037291, 0.6020387667679405, 0.5944151135206897, 0.586778795542666, 0.5793331053300421, 0.5718686118752736, 0.5647030605120954, 0.5575578064756299, 0.550378348485276, 0.5434531229871719, 0.5364824943653783, 0.5297258605377644, 0.522949619212754, 0.5163468885130121, 0.5097641492712226, 0.5031961452789009, 0.4967598415909002, 0.4905307114994021, 0.484313989110167, 0.47811143726832483, 0.4719951220920881, 0.46603003154038325, 0.4600996445824722, 0.4540771962119438, 0.4483707325695832, 0.4426329816149238, 0.4370551678407777, 0.43153443128610447, 0.42595266525583386, 0.4205920874301213, 0.4152671178888477, 0.40998205889156564, 0.40471109191327703, 0.399556840394443, 0.39445650399326704, 0.3894519154934072, 0.3845334986974413, 0.3796175429997819, 0.3747284672068207, 0.36993409911317954, 0.36535429703547107, 0.36065868493029535, 0.35614799768780214, 0.3515200565284635, 0.3470707959152336, 0.34262109086419706, 0.3382826851188784, 0.33401087503622173, 0.32974563122077505, 0.3255111982318477, 0.3213523748964364, 0.31721547170024844, 0.3132065268635119, 0.30930913749010774, 0.3053482563363235, 0.30151706124698485, 0.297685617366456, 0.293887248045343, 0.2900743824321096, 0.2863581171234941, 0.28272671289186846, 0.27913816930441865, 0.2756198458599507, 0.2720855042384159, 0.26861133803538023, 0.26520071745881335, 0.2618400497710347, 0.25856329328864125, 0.2552189691330238, 0.2519430443084011, 0.24874891571846788, 0.24553948766313452, 0.2424833954254023, 0.23937739188757945, 0.23628816472221192, 0.23328875989554304, 0.23033147716280689, 0.2274217319383606, 0.22452610353794827, 0.22164859526369807, 0.2188260276700072, 0.2160328261632799, 0.21334487754621229, 0.2106030957402708, 0.20789459568592633, 0.2052418296138486, 0.20266823474073573, 0.20006188352661414, 0.19749305557637087, 0.19500151743391309, 0.19252181071514415, 0.19008181855899042, 0.18766153930199037, 0.1852492394920492, 0.1829257973466677, 0.1805852343415741, 0.17830699177562231, 0.17606321507399972, 0.17378681102276727, 0.17155215499690307 ], "yaxis": "y" }, { "hovertemplate": "name=RMSProp
iter=%{x}
cost=%{y}", "legendgroup": "RMSProp", "line": { "color": "#ab63fa", "dash": "solid" }, "mode": "lines", "name": "RMSProp", "showlegend": true, "type": "scatter", "x": [ 900, 901, 902, 903, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, 921, 922, 923, 924, 925, 926, 927, 928, 929, 930, 931, 932, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, 960, 961, 962, 963, 964, 965, 966, 967, 968, 969, 970, 971, 972, 973, 974, 975, 976, 977, 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999 ], "xaxis": "x", "y": [ 670.3976824694432, 192.5542914607692, 64.78898637363812, 161.70713036795001, 173.1087744847497, 547.9614883380293, 699.7523377912036, 250.04256637242685, 222.1213868037304, 561.8228143654032, 290.70321168074156, 456.7658480287945, 329.4023473124329, 125.56968501673092, 385.26766683650715, 403.66632511036835, 224.33932481107468, 47.299486625323496, 237.36945394949214, 450.6681161418393, 337.94180306547224, 377.2828956486251, 161.6957068134929, 155.98400431639863, 372.8059739704644, 176.5674830305611, 202.50189670177673, 255.93182316761644, 514.9488174807509, 236.87019002744296, 132.9195372193572, 219.45658069450226, 434.7252845345134, 271.96165590045155, 266.9695866251155, 315.73548525002275, 163.6078883165908, 135.64020180531935, 430.96295387239667, 139.01519502737597, 205.0167152337854, 397.2659840411165, 383.6355603293238, 511.9625269269326, 64.94247288338453, 309.85208454923367, 433.67456462677177, 219.8165839571207, 470.091754211684, 414.9955214499903, 254.7175447023551, 141.88612511520438, 417.51323442555304, 350.8402027148545, 272.56333202959166, 165.25193911592115, 97.0545040096251, 325.2080603063823, 535.152096630252, 297.5091447294094, 86.30973485274504, 143.78449338254146, 869.374157885854, 89.33495192602861, 119.74688488269814, 540.5502366832018, 222.22431443138078, 549.5241755242522, 300.19862801482793, 227.0885758364098, 120.7851008089279, 633.3316174004638, 96.66806904268203, 105.31770739466137, 659.1593040910042, 286.3991030305084, 180.64709582236725, 364.04363779171695, 124.6736739174979, 229.33242565851407, 297.3757625782511, 327.8535482771971, 117.80578383437619, 419.72714879949683, 146.71617047011574, 273.4050972343616, 476.68260733899297, 104.18510745360912, 112.02364400247438, 675.0860306066252, 203.42510242340543, 176.2038584181526, 373.5183275587989, 157.90566924038464, 560.4943973047478, 58.879146628660514, 203.4452484795461, 245.29448257957915, 749.3332438397779, 193.5060735826529 ], "yaxis": "y" } ], "layout": { "legend": { "title": { "text": "name" }, "tracegroupgap": 0 }, "margin": { "t": 60 }, "template": { "data": { "bar": [ { "error_x": { "color": "#2a3f5f" }, "error_y": { "color": "#2a3f5f" }, "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "bar" } ], "barpolar": [ { "marker": { "line": { "color": "#E5ECF6", "width": 0.5 } }, "type": "barpolar" } ], "carpet": [ { "aaxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "baxis": { "endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f" }, "type": "carpet" } ], "choropleth": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "choropleth" } ], "contour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "contour" } ], "contourcarpet": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "contourcarpet" } ], "heatmap": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmap" } ], "heatmapgl": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "heatmapgl" } ], "histogram": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "histogram" } ], "histogram2d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2d" } ], "histogram2dcontour": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "histogram2dcontour" } ], "mesh3d": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "type": "mesh3d" } ], "parcoords": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "parcoords" } ], "pie": [ { "automargin": true, "type": "pie" } ], "scatter": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter" } ], "scatter3d": [ { "line": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatter3d" } ], "scattercarpet": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattercarpet" } ], "scattergeo": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergeo" } ], "scattergl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattergl" } ], "scattermapbox": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scattermapbox" } ], "scatterpolar": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolar" } ], "scatterpolargl": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterpolargl" } ], "scatterternary": [ { "marker": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "type": "scatterternary" } ], "surface": [ { "colorbar": { "outlinewidth": 0, "ticks": "" }, "colorscale": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "type": "surface" } ], "table": [ { "cells": { "fill": { "color": "#EBF0F8" }, "line": { "color": "white" } }, "header": { "fill": { "color": "#C8D4E3" }, "line": { "color": "white" } }, "type": "table" } ] }, "layout": { "annotationdefaults": { "arrowcolor": "#2a3f5f", "arrowhead": 0, "arrowwidth": 1 }, "coloraxis": { "colorbar": { "outlinewidth": 0, "ticks": "" } }, "colorscale": { "diverging": [ [ 0, "#8e0152" ], [ 0.1, "#c51b7d" ], [ 0.2, "#de77ae" ], [ 0.3, "#f1b6da" ], [ 0.4, "#fde0ef" ], [ 0.5, "#f7f7f7" ], [ 0.6, "#e6f5d0" ], [ 0.7, "#b8e186" ], [ 0.8, "#7fbc41" ], [ 0.9, "#4d9221" ], [ 1, "#276419" ] ], "sequential": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ], "sequentialminus": [ [ 0, "#0d0887" ], [ 0.1111111111111111, "#46039f" ], [ 0.2222222222222222, "#7201a8" ], [ 0.3333333333333333, "#9c179e" ], [ 0.4444444444444444, "#bd3786" ], [ 0.5555555555555556, "#d8576b" ], [ 0.6666666666666666, "#ed7953" ], [ 0.7777777777777778, "#fb9f3a" ], [ 0.8888888888888888, "#fdca26" ], [ 1, "#f0f921" ] ] }, "colorway": [ "#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52" ], "font": { "color": "#2a3f5f" }, "geo": { "bgcolor": "white", "lakecolor": "white", "landcolor": "#E5ECF6", "showlakes": true, "showland": true, "subunitcolor": "white" }, "hoverlabel": { "align": "left" }, "hovermode": "closest", "mapbox": { "style": "light" }, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": { "angularaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "radialaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "scene": { "xaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "yaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" }, "zaxis": { "backgroundcolor": "#E5ECF6", "gridcolor": "white", "gridwidth": 2, "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white" } }, "shapedefaults": { "line": { "color": "#2a3f5f" } }, "ternary": { "aaxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "baxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" }, "bgcolor": "#E5ECF6", "caxis": { "gridcolor": "white", "linecolor": "white", "ticks": "" } }, "title": { "x": 0.05 }, "xaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 }, "yaxis": { "automargin": true, "gridcolor": "white", "linecolor": "white", "ticks": "", "title": { "standoff": 15 }, "zerolinecolor": "white", "zerolinewidth": 2 } } }, "xaxis": { "anchor": "y", "domain": [ 0, 1 ], "title": { "text": "iter" } }, "yaxis": { "anchor": "x", "domain": [ 0, 1 ], "title": { "text": "cost" } } } }, "text/html": [ "
\n", " \n", " \n", "
\n", " \n", "
" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "plotCost(tracebacks.values(), min_iter=900, max_iter = 1000)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.6" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": { "height": "calc(100% - 180px)", "left": "10px", "top": "150px", "width": "288px" }, "toc_section_display": true, "toc_window_display": true }, "varInspector": { "cols": { "lenName": 16, "lenType": 16, "lenVar": 40 }, "kernels_config": { "python": { "delete_cmd_postfix": "", "delete_cmd_prefix": "del ", "library": "var_list.py", "varRefreshCmd": "print(var_dic_list())" }, "r": { "delete_cmd_postfix": ") ", "delete_cmd_prefix": "rm(", "library": "var_list.r", "varRefreshCmd": "cat(var_dic_list()) " } }, "types_to_exclude": [ "module", "function", "builtin_function_or_method", "instance", "_Feature" ], "window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }