boltzmann9 0.1.4__py3-none-any.whl → 0.1.7__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,115 @@
1
+ """Visualization utilities for data exploration."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Optional
6
+
7
+ import numpy as np
8
+ import pandas as pd
9
+
10
+
11
+ def plot_simulation_data(
12
+ df: pd.DataFrame,
13
+ *,
14
+ n_bits: int,
15
+ k_bins: int,
16
+ start: int = 0,
17
+ stop: int = 100,
18
+ figsize: tuple[int, int] = (15, 10),
19
+ ) -> None:
20
+ """Plot simulation data visualization.
21
+
22
+ Creates a 6-panel figure showing:
23
+ 1. Continuous vs discretized R values
24
+ 2. Distribution histogram
25
+ 3. Bin indices over time
26
+ 4. Binary representation heatmap
27
+ 5. Bin index distribution
28
+ 6. Decision variable by bin
29
+
30
+ Args:
31
+ df: DataFrame with simulation data.
32
+ n_bits: Number of bits used for binary encoding.
33
+ k_bins: Number of discretization bins.
34
+ start: Start index for time series plots.
35
+ stop: End index for time series plots.
36
+ figsize: Figure size tuple.
37
+ """
38
+ try:
39
+ import matplotlib.pyplot as plt
40
+ except ImportError as e:
41
+ print(f"matplotlib not available: {e}")
42
+ return
43
+
44
+ fig = plt.figure(figsize=figsize)
45
+
46
+ # Plot 1: Continuous vs Discretized
47
+ ax1 = plt.subplot(3, 2, 1)
48
+ plt.plot(
49
+ df["t"][start:stop],
50
+ df["R_continuous"][start:stop],
51
+ alpha=0.5,
52
+ label="Continuous",
53
+ linewidth=1,
54
+ )
55
+ plt.xlabel("Time")
56
+ plt.ylabel("R")
57
+ plt.legend()
58
+ plt.title("Continuous vs Discretized R")
59
+ plt.grid(True, alpha=0.3)
60
+
61
+ # Plot 2: Histogram
62
+ ax2 = plt.subplot(3, 2, 2)
63
+ plt.hist(df["R"], bins=k_bins, edgecolor="black", alpha=0.7)
64
+ plt.xlabel("R (discretized)")
65
+ plt.ylabel("Frequency")
66
+ plt.title(f"Distribution across {k_bins} bins")
67
+ plt.grid(True, alpha=0.3)
68
+
69
+ # Plot 3: Bin indices over time
70
+ ax3 = plt.subplot(3, 2, 3)
71
+ plt.plot(
72
+ df["t"][start:stop], df["R_bin_index"][start:stop], drawstyle="steps-post"
73
+ )
74
+ plt.xlabel("Time")
75
+ plt.ylabel("Bin Index")
76
+ plt.title("Bin Index over Time")
77
+ plt.yticks(range(k_bins))
78
+ plt.grid(True, alpha=0.3)
79
+
80
+ # Plot 4: Binary bits over time (heatmap style)
81
+ ax4 = plt.subplot(3, 2, 4)
82
+ binary_matrix = np.array(
83
+ [df[f"R_bit_{i}"][start:stop].values for i in range(n_bits)]
84
+ )
85
+ plt.imshow(binary_matrix, aspect="auto", cmap="binary", interpolation="nearest")
86
+ plt.xlabel("Time")
87
+ plt.ylabel("Bit Position")
88
+ plt.title(f"Binary Representation over Time ({n_bits} bits)")
89
+ plt.yticks(range(n_bits), [f"Bit {i}" for i in range(n_bits)])
90
+ plt.colorbar(label="Bit Value")
91
+
92
+ # Plot 5: Bin index distribution
93
+ ax5 = plt.subplot(3, 2, 5)
94
+ bin_counts = df["R_bin_index"].value_counts().sort_index()
95
+ plt.bar(bin_counts.index, bin_counts.values, alpha=0.7, edgecolor="black")
96
+ plt.xlabel("Bin Index")
97
+ plt.ylabel("Frequency")
98
+ plt.title("Bin Index Distribution")
99
+ plt.xticks(range(k_bins))
100
+ plt.grid(True, alpha=0.3)
101
+
102
+ # Plot 6: Decision variable vs bin index
103
+ ax6 = plt.subplot(3, 2, 6)
104
+ df_valid = df[df["x"].notna()]
105
+ decision_by_bin = df_valid.groupby("R_bin_index")["x"].mean()
106
+ plt.bar(decision_by_bin.index, decision_by_bin.values, alpha=0.7, edgecolor="black")
107
+ plt.xlabel("Bin Index")
108
+ plt.ylabel("Mean Decision (x)")
109
+ plt.title("Average Decision by Bin")
110
+ plt.xticks(range(k_bins))
111
+ plt.ylim([0, 1])
112
+ plt.grid(True, alpha=0.3)
113
+
114
+ plt.tight_layout()
115
+ plt.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: boltzmann9
3
- Version: 0.1.4
3
+ Version: 0.1.7
4
4
  Summary: Restricted Boltzmann Machine implementation in PyTorch
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -0,0 +1,19 @@
1
+ boltzmann9/__init__.py,sha256=ziEu9BCO40bLdp0HWpLTD32iwpNQSEBsfltOlz0R87A,960
2
+ boltzmann9/__main__.py,sha256=yj4HraCGopPtcUNTFtgTJ9VaXpVHzUWsnqfMOG04Sas,71
3
+ boltzmann9/cli.py,sha256=mPD6QonSOZ3P3Vc5hznK3Ib3Lf_3ROvLBmcY385BFho,11388
4
+ boltzmann9/config.py,sha256=tNvK6HsToX21Gu3KPCgt_6rOi9yYDpRG53zkniSZ2Wc,1604
5
+ boltzmann9/data.py,sha256=xgaHu6DPaanHrptl8ECq31t6E5yD9MatdVb8JHG-l0U,4011
6
+ boltzmann9/data_generator.py,sha256=aXm8b6O4qoXpDa8TCOdDxF_lDaMtcLNR0P06u2cXb1g,7550
7
+ boltzmann9/model.py,sha256=npBDd_pow4f9gcsLIpWMmJLBB6sGljtaOluvXcFlLP0,31538
8
+ boltzmann9/pipeline.py,sha256=C3L7tHVakrmvdnW9KYMXhXvscwG7TP8xmVHbunx1E8w,5965
9
+ boltzmann9/preprocessor.py,sha256=USxpMCnC80wp4zO72lPxmFeVdfB4I5NE4P2YlojCVPQ,21758
10
+ boltzmann9/project.py,sha256=Iap-nxhhAZDw2Y4yQg53gFQ0CQPCk2zfmZZC0bTPmxQ,5333
11
+ boltzmann9/run_utils.py,sha256=1eRDEkN8j1mG5g9iXArWRA1yQq6pw2agVUGV4Yhy0jk,7823
12
+ boltzmann9/tester.py,sha256=yMYhYKWWiG-LhJQvKv7QmMCYPQLbmtMxFVrJ9iHZVs8,5659
13
+ boltzmann9/utils.py,sha256=8ftNcbV4dz52-t0Ewu4E7CmkkVzPDa6kd8ZnxaBvhMM,1337
14
+ boltzmann9/visualization.py,sha256=iPSytX7GMfmbRbR43xOmybLZBLmy58D4Rp8wasISMcs,3407
15
+ boltzmann9-0.1.7.dist-info/METADATA,sha256=4i9cMFOYamgkAeYOCgNl-2P000hYO_FLa38nPihsSNU,3097
16
+ boltzmann9-0.1.7.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
17
+ boltzmann9-0.1.7.dist-info/entry_points.txt,sha256=Y2wY1lqICCjTxuaPgme2QxkoAknrASKmhLljcb5FEyw,51
18
+ boltzmann9-0.1.7.dist-info/top_level.txt,sha256=AE0_urGKOFSgKxXf7WQfjGDROWYppyI4tw1VIg-paQI,11
19
+ boltzmann9-0.1.7.dist-info/RECORD,,
@@ -0,0 +1 @@
1
+ boltzmann9
@@ -1,5 +0,0 @@
1
- boltzmann9-0.1.4.dist-info/METADATA,sha256=6uk2GRe3SD0UDl1Q69PtluVsIr9UjRG4Y9OWIc2swFs,3097
2
- boltzmann9-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
3
- boltzmann9-0.1.4.dist-info/entry_points.txt,sha256=Y2wY1lqICCjTxuaPgme2QxkoAknrASKmhLljcb5FEyw,51
4
- boltzmann9-0.1.4.dist-info/top_level.txt,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
5
- boltzmann9-0.1.4.dist-info/RECORD,,
@@ -1 +0,0 @@
1
-