Skip to content

Commit 65fb581

Browse files
author
“kjmayer”
committed
misc figure edits
1 parent f15fcab commit 65fb581

File tree

3 files changed

+343
-92
lines changed

3 files changed

+343
-92
lines changed

interpret/interpret-confvsacc-plot.ipynb

Lines changed: 40 additions & 36 deletions
Large diffs are not rendered by default.

interpret/interpret-data.ipynb

Lines changed: 256 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@
2626
"execution_count": 1,
2727
"id": "4b66c4fa-5299-467a-809d-cb3fc8d30589",
2828
"metadata": {},
29-
"outputs": [
30-
{
31-
"name": "stderr",
32-
"output_type": "stream",
33-
"text": [
34-
"2023-12-06 16:03:51.283762: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: SSE4.1 SSE4.2 AVX AVX2 AVX512F AVX512_VNNI FMA\n",
35-
"To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.\n",
36-
"2023-12-06 16:03:52.716386: I tensorflow/core/util/port.cc:104] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.\n"
37-
]
38-
}
39-
],
29+
"outputs": [],
4030
"source": [
4131
"import numpy as np\n",
4232
"import xarray as xr\n",
@@ -102,7 +92,7 @@
10292
},
10393
{
10494
"cell_type": "code",
105-
"execution_count": null,
95+
"execution_count": 2,
10696
"id": "09f14733-e325-454d-9f75-245f84158ac5",
10797
"metadata": {},
10898
"outputs": [],
@@ -145,6 +135,260 @@
145135
"### Analyze Data"
146136
]
147137
},
138+
{
139+
"cell_type": "code",
140+
"execution_count": 7,
141+
"id": "d823bea1-4b20-4fc0-8a71-4784aad63040",
142+
"metadata": {},
143+
"outputs": [
144+
{
145+
"name": "stdout",
146+
"output_type": "stream",
147+
"text": [
148+
"LEAD: 5\n",
149+
"all samples:\n",
150+
"(11534,)\n",
151+
"361/361 [==============================] - 0s 785us/step\n",
152+
"confident shape:\n",
153+
"(2307,)\n",
154+
"LEAD: 6\n",
155+
"all samples:\n",
156+
"(11538,)\n",
157+
"361/361 [==============================] - 0s 883us/step\n",
158+
"confident shape:\n",
159+
"(2308,)\n",
160+
"LEAD: 7\n",
161+
"all samples:\n",
162+
"(11532,)\n",
163+
"361/361 [==============================] - 0s 878us/step\n",
164+
"confident shape:\n",
165+
"(2307,)\n",
166+
"LEAD: 8\n",
167+
"all samples:\n",
168+
"(11514,)\n",
169+
"360/360 [==============================] - 0s 950us/step\n",
170+
"confident shape:\n",
171+
"(2303,)\n",
172+
"LEAD: 9\n",
173+
"all samples:\n",
174+
"(11502,)\n",
175+
"360/360 [==============================] - 0s 1ms/step\n",
176+
"confident shape:\n",
177+
"(2301,)\n",
178+
"LEAD: 10\n",
179+
"all samples:\n",
180+
"(11502,)\n",
181+
"360/360 [==============================] - 0s 922us/step\n",
182+
"confident shape:\n",
183+
"(2301,)\n",
184+
"LEAD: 11\n",
185+
"all samples:\n",
186+
"(11500,)\n",
187+
"360/360 [==============================] - 0s 824us/step\n",
188+
"confident shape:\n",
189+
"(2300,)\n",
190+
"LEAD: 12\n",
191+
"all samples:\n",
192+
"(11500,)\n",
193+
"360/360 [==============================] - 0s 868us/step\n",
194+
"confident shape:\n",
195+
"(2300,)\n",
196+
"LEAD: 13\n",
197+
"all samples:\n",
198+
"(11502,)\n",
199+
"360/360 [==============================] - 0s 913us/step\n",
200+
"confident shape:\n",
201+
"(2301,)\n",
202+
"LEAD: 14\n",
203+
"all samples:\n",
204+
"(11520,)\n",
205+
"360/360 [==============================] - 1s 2ms/step\n",
206+
"confident shape:\n",
207+
"(2304,)\n",
208+
"LEAD: 15\n",
209+
"all samples:\n",
210+
"(11538,)\n",
211+
"361/361 [==============================] - 0s 998us/step\n",
212+
"confident shape:\n",
213+
"(2308,)\n",
214+
"LEAD: 16\n",
215+
"all samples:\n",
216+
"(11548,)\n",
217+
"361/361 [==============================] - 0s 823us/step\n",
218+
"confident shape:\n",
219+
"(2310,)\n",
220+
"LEAD: 17\n",
221+
"all samples:\n",
222+
"(11542,)\n",
223+
"361/361 [==============================] - 0s 866us/step\n",
224+
"confident shape:\n",
225+
"(2309,)\n",
226+
"LEAD: 18\n",
227+
"all samples:\n",
228+
"(11556,)\n",
229+
"362/362 [==============================] - 1s 1ms/step\n",
230+
"confident shape:\n",
231+
"(2311,)\n",
232+
"LEAD: 19\n",
233+
"all samples:\n",
234+
"(11564,)\n",
235+
"362/362 [==============================] - 0s 925us/step\n",
236+
"confident shape:\n",
237+
"(2313,)\n",
238+
"LEAD: 20\n",
239+
"all samples:\n",
240+
"(11570,)\n",
241+
"362/362 [==============================] - 0s 839us/step\n",
242+
"confident shape:\n",
243+
"(2314,)\n",
244+
"LEAD: 21\n",
245+
"all samples:\n",
246+
"(11580,)\n",
247+
"362/362 [==============================] - 0s 899us/step\n",
248+
"confident shape:\n",
249+
"(2316,)\n",
250+
"LEAD: 22\n",
251+
"all samples:\n",
252+
"(11588,)\n",
253+
"363/363 [==============================] - 0s 1ms/step\n",
254+
"confident shape:\n",
255+
"(2318,)\n",
256+
"LEAD: 23\n",
257+
"all samples:\n",
258+
"(11596,)\n",
259+
"363/363 [==============================] - 0s 829us/step\n",
260+
"confident shape:\n",
261+
"(2319,)\n",
262+
"LEAD: 24\n",
263+
"all samples:\n",
264+
"(11592,)\n",
265+
"363/363 [==============================] - 0s 859us/step\n",
266+
"confident shape:\n",
267+
"(2319,)\n",
268+
"LEAD: 25\n",
269+
"all samples:\n",
270+
"(11600,)\n",
271+
"363/363 [==============================] - 0s 798us/step\n",
272+
"confident shape:\n",
273+
"(2320,)\n",
274+
"LEAD: 26\n",
275+
"all samples:\n",
276+
"(11594,)\n",
277+
"363/363 [==============================] - 0s 832us/step\n",
278+
"confident shape:\n",
279+
"(2319,)\n",
280+
"LEAD: 27\n",
281+
"all samples:\n",
282+
"(11602,)\n",
283+
"363/363 [==============================] - 0s 1ms/step\n",
284+
"confident shape:\n",
285+
"(2321,)\n",
286+
"LEAD: 28\n",
287+
"all samples:\n",
288+
"(11604,)\n",
289+
"363/363 [==============================] - 0s 902us/step\n",
290+
"confident shape:\n",
291+
"(2321,)\n",
292+
"LEAD: 29\n",
293+
"all samples:\n",
294+
"(11616,)\n",
295+
"363/363 [==============================] - 0s 785us/step\n",
296+
"confident shape:\n",
297+
"(2323,)\n",
298+
"LEAD: 30\n",
299+
"all samples:\n",
300+
"(11618,)\n",
301+
"364/364 [==============================] - 0s 999us/step\n",
302+
"confident shape:\n",
303+
"(2324,)\n"
304+
]
305+
}
306+
],
307+
"source": [
308+
"# print sizes of testing data for all and 20%:\n",
309+
"for l in LEADS:\n",
310+
" print('LEAD: '+str(l)) #+'\\nAVG: '+str(a))\n",
311+
" for a in AVGS[:1]:\n",
312+
" X1test, X2test, Ytest = get_testing(N_z500runmean=a,\n",
313+
" LEAD=l)\n",
314+
" print('all samples:')\n",
315+
" print(np.shape(Ytest))\n",
316+
"\n",
317+
" INPUT_SHAPE1 = np.shape(X1test)[1:][0]\n",
318+
" INPUT_SHAPE2 = np.shape(X2test)[1:][0]\n",
319+
"\n",
320+
" for s in SEEDS[:1]:\n",
321+
" # ENSO MODEL\n",
322+
" model1, input1 = build_model(s,\n",
323+
" DROPOUT_RATE,\n",
324+
" RIDGE1,\n",
325+
" HIDDENS1,\n",
326+
" INPUT_SHAPE1,\n",
327+
" MODELNAME1)\n",
328+
" # MJO MODEL\n",
329+
" model2, input2 = build_model(s,\n",
330+
" DROPOUT_RATE,\n",
331+
" RIDGE2,\n",
332+
" HIDDENS2,\n",
333+
" INPUT_SHAPE2,\n",
334+
" MODELNAME2) \n",
335+
" # COMBINE ENSO & MJO MODEL\n",
336+
" model = fullmodel(model1, model2,\n",
337+
" input1, input2,\n",
338+
" s)\n",
339+
"\n",
340+
" MODEL_FINAME = 'DOY_LEAD_'+str(l)+'_AVG_'+str(a)+'__0000'+str(s)+'.h5'\n",
341+
" model.load_weights(MODEL_DIR+MODEL_FINAME)\n",
342+
"\n",
343+
" model_rawpreds = model.predict((X1test,X2test)) \n",
344+
" \n",
345+
" conf = np.max(model_rawpreds,axis=-1)\n",
346+
" predval = np.argmax(model_rawpreds,axis=-1)\n",
347+
" \n",
348+
" # ------- confident predictions --------------------------------------------------------\n",
349+
" per = 80\n",
350+
" conf_thresh = np.percentile(conf,q=per)\n",
351+
" # -------- confident [i_conf_predval] --------\n",
352+
" i_conf_predval = np.where(conf > conf_thresh)[0]\n",
353+
" print('confident shape:')\n",
354+
" print(np.shape(i_conf_predval))\n",
355+
" \n",
356+
"\n",
357+
" "
358+
]
359+
},
360+
{
361+
"cell_type": "code",
362+
"execution_count": null,
363+
"id": "4ea1d3dd-e07f-471d-95c6-cf51bde8b57a",
364+
"metadata": {},
365+
"outputs": [],
366+
"source": []
367+
},
368+
{
369+
"cell_type": "code",
370+
"execution_count": null,
371+
"id": "9b02cf81-e50c-43fc-b80e-0f3a70777a4a",
372+
"metadata": {},
373+
"outputs": [],
374+
"source": []
375+
},
376+
{
377+
"cell_type": "code",
378+
"execution_count": null,
379+
"id": "73b0f921-6e58-4ae7-b1a5-25dfe77da21e",
380+
"metadata": {},
381+
"outputs": [],
382+
"source": []
383+
},
384+
{
385+
"cell_type": "code",
386+
"execution_count": null,
387+
"id": "f8a92820-907d-4fb2-8b92-155f8105d6cb",
388+
"metadata": {},
389+
"outputs": [],
390+
"source": []
391+
},
148392
{
149393
"cell_type": "code",
150394
"execution_count": 3,

interpret/interpret-modelcont-plot.ipynb

Lines changed: 47 additions & 44 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)