Visualization¶
Note
Requires the viz extra: uv pip install "emotional-memory[viz]"
Example: visualise the ranking-time breakdown returned by
retrieve_with_explanations():
explained = em.retrieve_with_explanations("project success", top_k=1)
top = explained[0]
plot_retrieval_radar(
[
top.breakdown.raw_signals.semantic_similarity,
top.breakdown.raw_signals.mood_congruence,
top.breakdown.raw_signals.affect_proximity,
top.breakdown.raw_signals.momentum_alignment,
top.breakdown.raw_signals.recency,
top.breakdown.raw_signals.resonance,
]
)
Use raw_signals to inspect the ranking-time signal values and
weighted_signals to inspect each signal's contribution to the final score.
emotional_memory.visualization.plot_circumplex(memories: Sequence[tuple[float, float, float]], *, ax: Axes | None = None, title: str = 'Valence-Arousal Circumplex', cmap: str = 'RdYlGn') -> Figure
¶
Plot memories on Russell's (1980) valence-arousal circumplex.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
memories
|
Sequence[tuple[float, float, float]]
|
Sequence of |
required |
ax
|
Axes | None
|
Optional existing |
None
|
title
|
str
|
Plot title. |
'Valence-Arousal Circumplex'
|
cmap
|
str
|
Matplotlib colormap name for consolidation strength. |
'RdYlGn'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
emotional_memory.visualization.plot_decay_curves(*, base_decay: float = 0.5, arousal_modulation: float = 0.5, retrieval_boost: float = 0.1, floor_arousal_threshold: float = 0.7, floor_value: float = 0.1, arousal_values: Sequence[float] = (0.0, 0.5, 1.0), retrieval_counts: Sequence[int] = (0, 5, 10), initial_strength: float = 1.0, ax: Axes | None = None, title: str = 'Memory Decay — ACT-R Power Law') -> Figure
¶
Plot families of ACT-R power-law decay curves.
Shows the McGaugh (2004) emotional enhancement effect (high arousal slows decay) and the spacing effect (retrieval count slows decay).
Formula::
eff_decay = base_decay
* (1 - arousal_modulation * arousal)
* (1 / (1 + retrieval_boost * retrieval_count))
strength(t) = initial * t ^ (-eff_decay)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_decay
|
float
|
Base power-law exponent. |
0.5
|
arousal_modulation
|
float
|
How much arousal slows decay. |
0.5
|
retrieval_boost
|
float
|
Decay reduction per retrieval event. |
0.1
|
floor_arousal_threshold
|
float
|
Arousal above which floor applies. |
0.7
|
floor_value
|
float
|
Minimum strength for high-arousal memories. |
0.1
|
arousal_values
|
Sequence[float]
|
Arousal levels to plot (colors vary). |
(0.0, 0.5, 1.0)
|
retrieval_counts
|
Sequence[int]
|
Retrieval counts to plot (linestyles vary). |
(0, 5, 10)
|
initial_strength
|
float
|
Starting consolidation strength. |
1.0
|
ax
|
Axes | None
|
Optional existing |
None
|
title
|
str
|
Plot title. |
'Memory Decay — ACT-R Power Law'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
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 | |
emotional_memory.visualization.plot_yerkes_dodson(*, mood_arousal: float = 0.3, ax: Axes | None = None, title: str = 'Yerkes-Dodson: Consolidation vs Arousal') -> Figure
¶
Plot the Yerkes-Dodson inverted-U for memory consolidation strength.
Uses consolidation_strength(arousal, mood_arousal) directly —
the same function the engine calls at encoding time. Peak is near
effective_arousal ≈ 0.7 (blend of encoding + mood arousal).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mood_arousal
|
float
|
Background mood arousal (default 0.3). |
0.3
|
ax
|
Axes | None
|
Optional existing |
None
|
title
|
str
|
Plot title. |
'Yerkes-Dodson: Consolidation vs Arousal'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
emotional_memory.visualization.plot_retrieval_radar(scores: Sequence[float], labels: Sequence[str] = SIGNAL_LABELS, *, ax: Axes | None = None, title: str = 'Retrieval Signal Breakdown', color: str = '#4C72B0') -> Figure
¶
Radar chart showing the six retrieval signal scores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
Sequence[float]
|
Six values in [0, 1] corresponding to the six signals: [semantic, mood, affect, momentum, recency, resonance]. |
required |
labels
|
Sequence[str]
|
Spoke labels (must match length of |
SIGNAL_LABELS
|
ax
|
Axes | None
|
Optional existing polar |
None
|
title
|
str
|
Plot title. |
'Retrieval Signal Breakdown'
|
color
|
str
|
Fill color. |
'#4C72B0'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
emotional_memory.visualization.plot_mood_evolution(history: Sequence[tuple[float, float, float, float]], *, ax: Axes | None = None, title: str = 'Mood Field Evolution') -> Figure
¶
Plot valence, arousal, and dominance over time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
history
|
Sequence[tuple[float, float, float, float]]
|
Sequence of |
required |
ax
|
Axes | None
|
Optional existing |
None
|
title
|
str
|
Plot title. |
'Mood Field Evolution'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
emotional_memory.visualization.plot_adaptive_weights_heatmap(*, base_weights: Sequence[float] = (0.35, 0.25, 0.15, 0.1, 0.1, 0.05), resolution: int = 20, ax: Axes | None = None, title: str = 'Adaptive Retrieval Weights vs Mood') -> Figure
¶
Heatmap of how each retrieval weight shifts across mood states.
Sweeps valence ∈ [-1, +1] and arousal ∈ [0, 1] on a grid
(dominance fixed at 0.5). For each grid cell calls
adaptive_weights() and displays a 6-panel heatmap.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_weights
|
Sequence[float]
|
Six baseline retrieval weights (must sum to 1.0). |
(0.35, 0.25, 0.15, 0.1, 0.1, 0.05)
|
resolution
|
int
|
Grid resolution ( |
20
|
ax
|
Axes | None
|
Must be |
None
|
title
|
str
|
Figure suptitle. |
'Adaptive Retrieval Weights vs Mood'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
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 | |
emotional_memory.visualization.plot_resonance_network(links: Sequence[object], node_labels: dict[str, str] | None = None, *, ax: Axes | None = None, title: str = 'Resonance Network') -> Figure
¶
Draw the resonance graph with circular node layout.
Does not require networkx — uses a simple circular layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
links
|
Sequence[object]
|
Sequence of |
required |
node_labels
|
dict[str, str] | None
|
Optional mapping |
None
|
ax
|
Axes | None
|
Optional existing |
None
|
title
|
str
|
Plot title. |
'Resonance Network'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
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 | |
emotional_memory.visualization.plot_appraisal_radar(appraisal: object, *, ax: Axes | None = None, title: str = 'Appraisal Vector (Scherer CPM)', color: str = '#DD5555') -> Figure
¶
Spider chart for appraisal vector dimensions.
Accepts an AppraisalVector (Scherer CPM), a GenericAppraisalVector
(custom schema), or a plain dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
appraisal
|
object
|
|
required |
ax
|
Axes | None
|
Optional existing polar |
None
|
title
|
str
|
Plot title. |
'Appraisal Vector (Scherer CPM)'
|
color
|
str
|
Fill / line color. |
'#DD5555'
|
Returns:
| Type | Description |
|---|---|
Figure
|
The |
Source code in src/emotional_memory/visualization.py
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 | |