|
89 | 89 | },
|
90 | 90 | {
|
91 | 91 | "cell_type": "code",
|
92 |
| - "execution_count": 5, |
| 92 | + "execution_count": 1, |
93 | 93 | "metadata": {},
|
94 | 94 | "outputs": [],
|
95 | 95 | "source": [
|
|
106 | 106 | },
|
107 | 107 | {
|
108 | 108 | "cell_type": "code",
|
109 |
| - "execution_count": 6, |
| 109 | + "execution_count": 2, |
110 | 110 | "metadata": {},
|
111 | 111 | "outputs": [],
|
112 | 112 | "source": [
|
|
139 | 139 | },
|
140 | 140 | {
|
141 | 141 | "cell_type": "code",
|
142 |
| - "execution_count": 32, |
| 142 | + "execution_count": 9, |
143 | 143 | "metadata": {},
|
144 | 144 | "outputs": [],
|
145 | 145 | "source": [
|
|
155 | 155 | "ui1 = widgets.VBox([mean,stdev],kwargs = {'justify_content':'center'})\n",
|
156 | 156 | "\n",
|
157 | 157 | "slope_under = widgets.FloatSlider(min=0.00, max = 1.0,value = 0.1,step=0.01,description = '$m_{under}$',orientation='horizontal',layout=Layout(width='230px', height='50px'),continuous_update=False)\n",
|
158 |
| - "slope_under.style.handle_color = 'blue'\n", |
| 158 | + "slope_under.style.handle_color = 'green'\n", |
159 | 159 | "\n",
|
160 | 160 | "power_under = widgets.FloatSlider(min=1.0, max = 5.0, value = 0.0, description = '$p_{under}$',orientation='horizontal',layout=Layout(width='230px', height='50px'),continuous_update=False)\n",
|
161 |
| - "power_under.style.handle_color = 'blue'\n", |
| 161 | + "power_under.style.handle_color = 'green'\n", |
162 | 162 | "\n",
|
163 | 163 | "ui2 = widgets.VBox([slope_under,power_under],kwargs = {'justify_content':'center'})\n",
|
164 | 164 | "\n",
|
|
209 | 209 | " plt.subplot(131) # plot uncertainty distribution\n",
|
210 | 210 | " plt.plot(X,pdf,'--',color='darkorange',alpha=0.7,zorder=10,lw=3)\n",
|
211 | 211 | " hist = plt.hist(y,bins=X,edgecolor='black',color='darkorange',alpha=0.7,density=True,stacked=True)\n",
|
212 |
| - " plt.plot([best_estimate,best_estimate],[0,np.max(hist[0])*1.2],color='black',linestyle='--')\n", |
213 |
| - " plt.annotate('Optimum Estimate = ' + str(np.round(best_estimate,2)),[best_estimate,np.max(hist[0])*0.6], rotation=270)\n", |
| 212 | + " if best_estimate >= 0 and best_estimate <= 1.0:\n", |
| 213 | + " plt.plot([best_estimate,best_estimate],[0,np.max(hist[0])*1.2],color='black',linestyle='--')\n", |
| 214 | + " plt.annotate('Optimum Estimate = ' + str(np.round(best_estimate,2)),[best_estimate,np.max(hist[0])*0.6], rotation=270)\n", |
| 215 | + " elif best_estimate < 0.0: \n", |
| 216 | + " plt.annotate('Optimum Estimate = ' + str('$-\\infty$'),[0,np.max(hist[0])*0.6], rotation=270)\n", |
| 217 | + " else:\n", |
| 218 | + " plt.annotate('Optimum Estimate = ' + str('$+\\infty$'),[0.96,np.max(hist[0])*0.6], rotation=270)\n", |
214 | 219 | " plt.xlim(0.0,1.0); plt.xlabel(\"Feature, $y_1$\"); plt.ylim([0,np.max(hist[0])*1.2])\n",
|
215 | 220 | " plt.title('Uncertainty Distribution'); plt.ylabel('Density')\n",
|
216 | 221 | " plt.grid(color='grey', ls = '-.', lw = 0.1)\n",
|
217 | 222 | "\n",
|
218 | 223 | " plt.subplot(132) # plot loss function, loss vs. estimate error\n",
|
219 |
| - " plt.plot(delta,loss,color='blue',alpha=0.8,lw=3)\n", |
| 224 | + " plt.plot(delta[delta>0],loss[delta>0],color='blue',alpha=0.8,lw=3)\n", |
| 225 | + " plt.plot(delta[delta<0],loss[delta<0],color='green',alpha=0.8,lw=3)\n", |
220 | 226 | "# plt.plot([0,0],[0,np.max(loss)],color='black',linestyle='--',alpha=0.3)\n",
|
221 | 227 | " plt.plot([0,0],[0,1.0],color='black',linestyle='--',alpha=0.8)\n",
|
222 | 228 | "# plt.annotate('Underestimation',[(xmax-xmin)*-0.1,np.max(loss)*0.8], rotation=0,horizontalalignment='right')\n",
|
|
229 | 235 | " plt.xlabel('Error In Estimate'); plt.title('Loss Function'); plt.ylabel('Loss') \n",
|
230 | 236 | " plt.grid(color='grey', ls = '-.', lw = 0.1)\n",
|
231 | 237 | " \n",
|
232 |
| - " \n", |
233 | 238 | " plt.subplot(133) # plot expected loss vs. estimate\n",
|
234 | 239 | " #plt.plot(X,pdf/1000*stdev,'--',color='black',alpha=0.7,zorder=1)\n",
|
235 | 240 | " plt.plot(x_exp_loss,exp_loss,color='red',alpha=0.8,lw=3)\n",
|
236 |
| - " plt.plot([best_estimate,best_estimate],[0,max_loss_plot],color='black',linestyle='--',lw=2)\n", |
| 241 | + " if best_estimate >= 0 and best_estimate <= 1.0:\n", |
| 242 | + " plt.plot([best_estimate,best_estimate],[0,max_loss_plot],color='black',linestyle='--',lw=2)\n", |
| 243 | + " plt.annotate('Optimum Estimate = ' + str(np.round(best_estimate,2)),[best_estimate,max_loss_plot*0.6], rotation=270)\n", |
| 244 | + " elif best_estimate < 0:\n", |
| 245 | + " plt.annotate('Optimum Estimate = ' + str('$-\\infty$'),[0,max_loss_plot*0.6], rotation=270)\n", |
| 246 | + " else:\n", |
| 247 | + " plt.annotate('Optimum Estimate = ' + str('$+\\infty$'),[0.96,max_loss_plot*0.6], rotation=270)\n", |
| 248 | + " \n", |
237 | 249 | " plt.xlim([0.0,1.0]); # plt.ylim([0,1.0])\n",
|
238 |
| - " plt.annotate('Optimum Estimate = ' + str(np.round(best_estimate,2)),[best_estimate,max_loss_plot*0.6], rotation=270)\n", |
239 | 250 | "# plt.plot([xmin,xmax],[min_loss,min_loss],color='black',linestyle='--',alpha=0.3)\n",
|
240 | 251 | " plt.plot([0,1],[min_loss,min_loss],color='black',linestyle='--',alpha=0.7,lw=2)\n",
|
241 | 252 | " plt.annotate('Minimum Expected Loss',[xmin+(xmax-xmin)*0.2,min_loss*1.1], rotation=0,horizontalalignment='left')\n",
|
|
270 | 281 | },
|
271 | 282 | {
|
272 | 283 | "cell_type": "code",
|
273 |
| - "execution_count": 33, |
| 284 | + "execution_count": 10, |
274 | 285 | "metadata": {},
|
275 | 286 | "outputs": [
|
276 | 287 | {
|
277 | 288 | "data": {
|
278 | 289 | "application/vnd.jupyter.widget-view+json": {
|
279 |
| - "model_id": "a46774a506fe4020851065741a7d3c58", |
| 290 | + "model_id": "40ebbaf980c74081ad812614ea114d10", |
280 | 291 | "version_major": 2,
|
281 | 292 | "version_minor": 0
|
282 | 293 | },
|
|
290 | 301 | {
|
291 | 302 | "data": {
|
292 | 303 | "application/vnd.jupyter.widget-view+json": {
|
293 |
| - "model_id": "f7defe23730049aea9b6a071d1aacbde", |
| 304 | + "model_id": "1ebaaaa00be143439c82be0649a1d3eb", |
294 | 305 | "version_major": 2,
|
295 | 306 | "version_minor": 0
|
296 | 307 | },
|
|
351 | 362 | "\n",
|
352 | 363 | "#### More Resources Available at: [Twitter](https://twitter.com/geostatsguy) | [GitHub](https://github.com/GeostatsGuy) | [Website](http://michaelpyrcz.com) | [GoogleScholar](https://scholar.google.com/citations?user=QVZ20eQAAAAJ&hl=en&oi=ao) | [Book](https://www.amazon.com/Geostatistical-Reservoir-Modeling-Michael-Pyrcz/dp/0199731446) | [YouTube](https://www.youtube.com/channel/UCLqEr-xV-ceHdXXXrTId5ig) | [LinkedIn](https://www.linkedin.com/in/michael-pyrcz-61a648a1)"
|
353 | 364 | ]
|
354 |
| - }, |
355 |
| - { |
356 |
| - "cell_type": "code", |
357 |
| - "execution_count": null, |
358 |
| - "metadata": {}, |
359 |
| - "outputs": [], |
360 |
| - "source": [] |
361 | 365 | }
|
362 | 366 | ],
|
363 | 367 | "metadata": {
|
|
0 commit comments