|
202 | 202 | " ax.fill_between(t, mu+sigma, mu-sigma, color='b', alpha=0.2)\n",
|
203 | 203 | " ax.set_ylim(0, 1.01)\n",
|
204 | 204 | " ax.plot([0, 1], [1, 0], 'r', label='Best possible path')\n",
|
205 |
| - " ax.set_xlabel('Distance travelled relative to turning point distance',\n", |
| 205 | + " ax.set_xlabel('distance travelled relative to turning point distance',\n", |
206 | 206 | " fontsize=label_font_size)\n",
|
207 |
| - " ax.set_ylabel('Distance from home', fontsize=label_font_size)\n", |
| 207 | + " ax.set_ylabel('distance from home', fontsize=label_font_size)\n", |
208 | 208 | " ax.set_title('(f)')#Tortuosity of homebound route', y=1.05, fontsize=label_font_size)\n",
|
209 | 209 | "\n",
|
210 | 210 | " vals = ax.get_xticks()\n",
|
|
263 | 263 | " ax.plot(timesteps, mean_errors, color=color, label=noise)\n",
|
264 | 264 | " ax.fill_between(timesteps,mean_errors-std_errors, mean_errors, color=color, alpha=0.2)\n",
|
265 | 265 | " \n",
|
266 |
| - " ax.set_xlabel(\"Time (steps)\")\n", |
267 |
| - " ax.set_ylabel(\"Memory error\")\n", |
| 266 | + " ax.set_xlabel(\"timesteps\")\n", |
| 267 | + " ax.set_ylabel(\"memory error (steps)\")\n", |
268 | 268 | " ax.set_title(\"(d)\")\n",
|
269 | 269 | " \n",
|
270 | 270 | " ax.legend(title=\"Noise\", loc='upper left')\n",
|
|
285 | 285 | " ax.plot(timesteps, mean_errors, color=color, label=noise)\n",
|
286 | 286 | " ax.fill_between(timesteps,mean_errors-std_errors, mean_errors, color=color, alpha=0.2)\n",
|
287 | 287 | " \n",
|
288 |
| - " ax.set_xlabel(\"Timesteps\")\n", |
289 |
| - " ax.set_ylabel(\"Angular memory error\")\n", |
| 288 | + " ax.set_xlabel(\"timesteps\")\n", |
| 289 | + " ax.set_ylabel(\"angular memory error\")\n", |
290 | 290 | " ax.set_yticks([-180,-90,0,90,180])\n",
|
291 | 291 | " \n",
|
292 | 292 | " ax.legend(title=\"Noise\", loc='upper left')\n",
|
|
309 | 309 | " ax.plot(timesteps, mean_errors, color=color, label=noise)\n",
|
310 | 310 | " ax.fill_between(timesteps,mean_errors-std_errors, mean_errors, color=color, alpha=0.2)\n",
|
311 | 311 | " \n",
|
312 |
| - " ax.set_xlabel(\"Inbound time (steps)\")\n", |
313 |
| - " ax.set_ylabel(\"Heading error\")\n", |
| 312 | + " ax.set_xlabel(\"inbound timesteps\")\n", |
| 313 | + " ax.set_ylabel(\"heading error (steps)\")\n", |
314 | 314 | " ax.set_title(\"(e)\")\n",
|
315 | 315 | " \n",
|
316 | 316 | " ax.legend(title=\"Noise\", loc='upper right')\n",
|
|
347 | 347 | " ax.plot(T, mean_optimal, label=\"mean optimal distance\", color=\"orange\")\n",
|
348 | 348 | "# ax.fill_between(T,mean_optimal, min_optimal, color=\"orange\", alpha=0.2)\n",
|
349 | 349 | "# ax.fill_between(T,mean_optimal, max_optimal, color=\"orange\", alpha=0.2)\n",
|
350 |
| - " ax.set_xlabel(\"Timesteps homing\")\n", |
| 350 | + " ax.set_xlabel(\"timesteps homing\")\n", |
351 | 351 | " ax.set_ylabel(\"% of homing distance remaining\")\n",
|
352 | 352 | " ax.set_xlim(0, T_outbound)\n",
|
353 | 353 | " ax.legend()\n",
|
|
368 | 368 | " \n",
|
369 | 369 | " if ax is not None:\n",
|
370 | 370 | " ax.yaxis.set_major_locator(MaxNLocator(integer=True))\n",
|
371 |
| - " ax.set_xlabel(\"Closest distance\")\n", |
372 |
| - " ax.set_ylabel(\"Frequency\")\n", |
| 371 | + " ax.set_xlabel(\"closest distance (steps)\")\n", |
| 372 | + " ax.set_ylabel(\"frequency\")\n", |
373 | 373 | " ax.set_title(\"(b)\")\n",
|
374 | 374 | " ax.hist(min_dists, bins=np.arange(min(min_dists), max(min_dists) + binwidth, binwidth))\n",
|
375 | 375 | " ax.axvline(interval[1],color=\"k\",linestyle=\"--\")\n",
|
|
393 | 393 | " legend_title=\"Parameter noise\"\n",
|
394 | 394 | " title = \"\"\n",
|
395 | 395 | " \n",
|
396 |
| - " utbounds = get_outbounds(model)\n", |
| 396 | + " outbounds = get_outbounds(model)\n", |
397 | 397 | " grouped = group_by_outbound(model)\n",
|
398 | 398 | " \n",
|
399 | 399 | " distances = np.array([get_min_dists(group,noise,get_outbounds(group)[0]) for group in grouped])\n",
|
|
403 | 403 | " std_dists = distances.std(axis=1)\n",
|
404 | 404 | " \n",
|
405 | 405 | " if ax is not None:\n",
|
406 |
| - " ax.set_xlabel(\"Outbound time (steps)\")\n", |
407 |
| - " ax.set_ylabel(\"Closest distance\")\n", |
| 406 | + " ax.set_xlabel(\"outbound timesteps\")\n", |
| 407 | + " ax.set_ylabel(\"closest distance (steps)\")\n", |
408 | 408 | " ax.set_title(title)\n",
|
409 | 409 | "\n",
|
410 | 410 | " ax.plot(outbounds, mean_dists, color=color, label=noise)\n",
|
|
425 | 425 | " std_dists = distances.std(axis=1)\n",
|
426 | 426 | " \n",
|
427 | 427 | " if ax is not None:\n",
|
428 |
| - " ax.set_xlabel(\"Outbound time (steps)\")\n", |
429 |
| - " ax.set_ylabel(\"Closest distance\")\n", |
| 428 | + " ax.set_xlabel(\"outbound timesteps\")\n", |
| 429 | + " ax.set_ylabel(\"closest distance (steps)\")\n", |
430 | 430 | "# ax.set_title(title)\n",
|
431 | 431 | "\n",
|
432 | 432 | " ax.plot(outbounds, mean_dists, color=color, label=model[0]['name'].split(\".\")[0])\n",
|
|
457 | 457 | " return [list(v) for l,v in groupby(sorted(data, key=lambda x:x[\"T_outbound\"]), lambda x: x[\"T_outbound\"])]\n",
|
458 | 458 | "\n",
|
459 | 459 | "def group_by_name(data):\n",
|
460 |
| - " lookup = {'dye basic':0, 'dye var beta':1, 'dye pontine':2, 'dye var beta + pontine':3, 'weights':4, 'stone':5}\n", |
| 460 | + " lookup = {'dye basic':0, 'dye var beta':1, 'dye amp':2, 'dye var beta + amp':3, 'weights':4, 'stone':5}\n", |
461 | 461 | " a = lambda x : lookup[x[\"name\"].split('.')[0]]\n",
|
462 | 462 | " return [list(v) for l,v in groupby(sorted(data.values(), key=a), a)]\n",
|
463 | 463 | "\n",
|
|
479 | 479 | "outputs": [],
|
480 | 480 | "source": [
|
481 | 481 | "paths = []\n",
|
482 |
| - "# paths.append(\"../../results/dye-eval_20221009-145512\")\n", |
483 |
| - "# paths.append(\"../../results/beta-dye-eval_20221009-145808\")\n", |
484 |
| - "# paths.append(\"../../results/cheat-dye-eval_20221009-145601\")\n", |
485 |
| - "# paths.append(\"../../results/beta-cheat-dye_20221009-150619\")\n", |
486 |
| - "# paths.append(\"../../results/model-v-model_20221010-173329\")\n", |
| 482 | + "# paths.append(\"../../results/dye-eval_20221013-221455\")\n", |
| 483 | + "# paths.append(\"../../results/beta-dye-eval_20221014-164746\")\n", |
| 484 | + "# paths.append(\"../../results/cheat-dye-eval_20221013-221723\")\n", |
| 485 | + "# paths.append(\"../../results/beta-cheat-dye_20221014-164657\")\n", |
| 486 | + "# paths.append(\"../../results/model-v-model_20221017-104736\")\n", |
| 487 | + "paths.append(\"../../results/model-v-model_20221017-113819\")\n", |
487 | 488 | "# paths.append(\"../../results/stone-eval_20221010-153927\")\n",
|
488 | 489 | "# paths.append(\"../../results/weights-eval_20221011-202459\")\n",
|
489 | 490 | "\n",
|
490 | 491 | "# paths.append(\"../../results/model-v-model-outbound_20221013-110812\")\n",
|
491 | 492 | "# paths.append(\"../../results/model-v-model-outbound_20221013-114021\")\n",
|
492 |
| - "paths.append(\"../../results/model-v-model_20221013-114739\")\n", |
| 493 | + "# paths.append(\"../../results/model-v-model_20221013-114739\")\n", |
493 | 494 | "\n",
|
494 | 495 | "results = load_results(enumerate_results(paths))"
|
495 | 496 | ]
|
496 | 497 | },
|
497 | 498 | {
|
498 | 499 | "cell_type": "code",
|
499 | 500 | "execution_count": null,
|
500 |
| - "id": "652ff8e8", |
501 |
| - "metadata": { |
502 |
| - "scrolled": true |
503 |
| - }, |
| 501 | + "id": "c60160d0", |
| 502 | + "metadata": {}, |
504 | 503 | "outputs": [],
|
505 | 504 | "source": [
|
506 | 505 | "noise = 0.1\n",
|
507 | 506 | "T_outbound = 1500\n",
|
508 | 507 | "\n",
|
509 | 508 | "data = {}\n",
|
510 |
| - "examples = []\n", |
511 |
| - "\n", |
| 509 | + "examples = []" |
| 510 | + ] |
| 511 | + }, |
| 512 | + { |
| 513 | + "cell_type": "code", |
| 514 | + "execution_count": null, |
| 515 | + "id": "652ff8e8", |
| 516 | + "metadata": { |
| 517 | + "scrolled": true |
| 518 | + }, |
| 519 | + "outputs": [], |
| 520 | + "source": [ |
512 | 521 | "for result in tqdm(results):\n",
|
513 | 522 | " if result.parameters['cx']['params']['noise'] == noise and result.parameters['T_outbound'] == T_outbound and len(examples) < 10 and result.parameters['cx']['params'].get('parameter_noise',None) == None:\n",
|
514 | 523 | " examples.append(result)\n",
|
|
521 | 530 | "cell_type": "code",
|
522 | 531 | "execution_count": null,
|
523 | 532 | "id": "92b9fc80",
|
524 |
| - "metadata": { |
525 |
| - "scrolled": false |
526 |
| - }, |
| 533 | + "metadata": {}, |
527 | 534 | "outputs": [],
|
528 | 535 | "source": [
|
529 | 536 | "def single_model_eval(data, noise_levels=[0.1,0.2,0.3,0.4]):\n",
|
|
586 | 593 | " min_dist_v_route_length(model_2,noise,ax=ax,color=color,param=True)\n",
|
587 | 594 | " ax.set_title(\"Minimum distance plot with noise on dye parameters\")\n",
|
588 | 595 | "\n",
|
589 |
| - "single_model_eval(data)\n" |
| 596 | + "# single_model_eval(data)\n", |
| 597 | + "print(data)" |
590 | 598 | ]
|
591 | 599 | },
|
592 | 600 | {
|
|
607 | 615 | " showmedians=False\n",
|
608 | 616 | " \n",
|
609 | 617 | " ax = plt.subplot(221)\n",
|
610 |
| - " data = [get_min_dists(model) for model in models]\n", |
| 618 | + " min_dists = [get_min_dists(model) for model in models]\n", |
611 | 619 | "# ax.boxplot(data,notch=True,labels=labels)\n",
|
612 |
| - " ax.violinplot(data,showmeans=showmeans,showmedians=showmedians)\n", |
| 620 | + " ax.violinplot(min_dists,showmeans=showmeans,showmedians=showmedians)\n", |
613 | 621 | " ax.set_xticks([1,2,3,4,5,6])\n",
|
614 | 622 | " ax.set_xticklabels(labels)\n",
|
615 | 623 | " ax.set_title(\"(a)\")\n",
|
616 |
| - " ax.set_ylabel(\"Closest distance\")\n", |
| 624 | + " ax.set_ylabel(\"closest distance (steps)\")\n", |
617 | 625 | " plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')\n",
|
618 | 626 | " \n",
|
619 | 627 | " ax = plt.subplot(222)\n",
|
620 |
| - " data = [mem_errors(model).mean(axis=1) for model in models]\n", |
| 628 | + " mem_err = [mem_errors(model).mean(axis=1) for model in models]\n", |
621 | 629 | "# ax.boxplot(data,notch=True,labels=labels)\n",
|
622 |
| - " ax.violinplot(data,showmeans=showmeans,showmedians=showmedians)\n", |
| 630 | + " ax.violinplot(mem_err,showmeans=showmeans,showmedians=showmedians)\n", |
623 | 631 | " ax.set_xticks([1,2,3,4,5,6])\n",
|
624 | 632 | " ax.set_xticklabels(labels)\n",
|
625 | 633 | " ax.set_title(\"(b)\")\n",
|
626 |
| - " ax.set_ylabel(\"Memory error\")\n", |
| 634 | + " ax.set_ylabel(\"memory error (steps)\")\n", |
627 | 635 | " plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')\n",
|
628 | 636 | " \n",
|
629 | 637 | " ax = plt.subplot(223)\n",
|
630 |
| - " data = [heading_errors(model)[1].mean(axis=1) for model in models]\n", |
| 638 | + " heading_err = [heading_errors(model)[1].mean(axis=1) for model in models]\n", |
631 | 639 | "# ax.boxplot(data,notch=True,labels=labels)\n",
|
632 |
| - " ax.violinplot(data,showmeans=showmeans,showmedians=showmedians)\n", |
| 640 | + " ax.violinplot(heading_err,showmeans=showmeans,showmedians=showmedians)\n", |
633 | 641 | " ax.set_xticks([1,2,3,4,5,6])\n",
|
634 | 642 | " ax.set_xticklabels(labels)\n",
|
635 | 643 | " ax.set_title(\"(c)\")\n",
|
636 |
| - " ax.set_ylabel(\"Heading error during homing\")\n", |
| 644 | + " ax.set_ylabel(\"heading error during homing (steps)\")\n", |
637 | 645 | " plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')\n",
|
638 | 646 | " \n",
|
639 | 647 | "# ax = plt.subplot(224)\n",
|
|
667 | 675 | "# plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')\n",
|
668 | 676 | " \n",
|
669 | 677 | " \n",
|
670 |
| - " data = []\n", |
| 678 | + " torts = []\n", |
671 | 679 | " for model in models:\n",
|
672 | 680 | " V = []\n",
|
673 | 681 | " for result in model:\n",
|
674 | 682 | " V.append(result['velocities'])\n",
|
675 | 683 | " V = np.array(V)\n",
|
676 | 684 | " cum_min_dist = compute_path_straightness(V,1500)\n",
|
677 | 685 | " tort = compute_tortuosity(cum_min_dist)\n",
|
678 |
| - " data.append(tort)\n", |
| 686 | + " torts.append(tort)\n", |
679 | 687 | " \n",
|
680 | 688 | " ax = plt.subplot(224)\n",
|
681 |
| - " bars = ax.bar([1,2,3,4,5,6],data,alpha=0.5)\n", |
| 689 | + " bars = ax.bar([1,2,3,4,5,6],torts,alpha=0.5)\n", |
682 | 690 | " ax.set_xticks([1,2,3,4,5,6])\n",
|
683 | 691 | " ax.set_xticklabels(labels)\n",
|
684 | 692 | " ax.set_title(\"(d)\")\n",
|
685 |
| - " ax.set_ylabel(\"Tortuosity of mean path\")\n", |
| 693 | + " ax.set_ylabel(\"tortuosity of mean path\")\n", |
686 | 694 | " plt.setp(ax.get_xticklabels(), rotation=30, horizontalalignment='right')\n",
|
687 | 695 | " \n",
|
688 | 696 | " ax.bar_label(bars)\n",
|
689 |
| - " \n", |
690 | 697 | " # print(model[0]['name'],' tortuosity is ',tort)\n",
|
691 | 698 | " \n",
|
692 |
| - " fig.tight_layout() \n", |
| 699 | + " fig.tight_layout()\n", |
| 700 | + " \n", |
| 701 | + " return min_dists, mem_err, heading_err, torts\n", |
| 702 | + "\n", |
693 | 703 | "\n",
|
694 | 704 | "models = group_by_name(data)\n",
|
695 |
| - "model_to_model(models)" |
| 705 | + "min_dists, mem_err, heading_err, torts = model_to_model(models)\n", |
| 706 | + "\n", |
| 707 | + "from scipy import stats as st\n", |
| 708 | + "test1 = st.ttest_ind(a=mem_err[0], b=mem_err[3], equal_var=True)\n", |
| 709 | + "test2 = st.ttest_ind(a=min_dists[0], b=min_dists[2], equal_var=True)\n", |
| 710 | + "test3 = st.ttest_ind(a=min_dists[2], b=min_dists[5], equal_var=True)\n", |
| 711 | + "\n", |
| 712 | + "print(\"Memory error t-test between dye basic and stone:\\n \", test1, \"\\n\")\n", |
| 713 | + "print(\"Closest distance t-test between dye basic and dye amp:\\n \", test2, \"\\n\")\n", |
| 714 | + "print(\"Closest distance t-test between dye amp and stone:\\n \", test3, \"\\n\")\n", |
| 715 | + "\n", |
| 716 | + "ttests = {\"min_dists\": [list(a) for a in min_dists], \"mem_err\": [list(a) for a in mem_err], \"heading_err\": [list(a) for a in heading_err], \"heading_err\": torts}\n", |
| 717 | + "\n", |
| 718 | + "import json\n", |
| 719 | + "with open('ttest.json', 'w', encoding='utf-8') as f:\n", |
| 720 | + " json.dump(ttests, f)" |
696 | 721 | ]
|
697 | 722 | },
|
698 | 723 | {
|
|
709 | 734 | "for model, color in zip(models,colors):\n",
|
710 | 735 | " min_dist_v_route_length_2(model,color=color,ax=plt.gca())"
|
711 | 736 | ]
|
712 |
| - }, |
713 |
| - { |
714 |
| - "cell_type": "code", |
715 |
| - "execution_count": null, |
716 |
| - "id": "e5250bac", |
717 |
| - "metadata": {}, |
718 |
| - "outputs": [], |
719 |
| - "source": [] |
720 | 737 | }
|
721 | 738 | ],
|
722 | 739 | "metadata": {
|
|
735 | 752 | "name": "python",
|
736 | 753 | "nbconvert_exporter": "python",
|
737 | 754 | "pygments_lexer": "ipython3",
|
738 |
| - "version": "3.10.4" |
| 755 | + "version": "3.8.10" |
739 | 756 | }
|
740 | 757 | },
|
741 | 758 | "nbformat": 4,
|
|
0 commit comments