Skip to content

Commit 9a4fe8c

Browse files
use of config
1 parent 94bb827 commit 9a4fe8c

File tree

5 files changed

+17
-8
lines changed

5 files changed

+17
-8
lines changed

config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ input:
33
timestamp_col: "Zeitstempel"
44
value_col: "Messwert"
55
factor: 4 # 15-min → kW depends on sampling
6+
7+
model:
8+
n_states: 10
9+
laplace_alpha: 1.0

src/markov/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
from .transition_counts import build_transition_counts
33
from .transitions import build_transition_matrices
44

5-
N_STATES: int = 10
6-
75
__all__ = [
8-
"N_STATES",
96
"bucket_id",
107
"NUM_BUCKETS",
118
"build_transition_counts",

src/markov/_core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import numpy as np
22
import pandas as pd
33

4-
from . import N_STATES
4+
from src.config import CONFIG
5+
56
from .buckets import NUM_BUCKETS
67

8+
N_STATES = int(CONFIG["model"]["n_states"])
9+
710

811
def _transition_counts(
912
df: pd.DataFrame, *, state_col="state", bucket_col="bucket", dtype=np.uint32

src/markov/transition_counts.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import numpy as np
22
import pandas as pd
33

4-
from . import N_STATES
4+
from src.config import CONFIG
5+
56
from .buckets import NUM_BUCKETS
67

8+
N_STATES = int(CONFIG["model"]["n_states"])
9+
710

811
def build_transition_counts(
912
df: pd.DataFrame,

src/markov/transitions.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import numpy as np
22
import pandas as pd
33

4+
from src.config import CONFIG
5+
46
from ._core import _transition_counts
57

8+
alpha = float(CONFIG["model"]["laplace_alpha"])
9+
610

7-
def build_transition_matrices(
8-
df: pd.DataFrame, *, alpha: float = 1.0, dtype=np.float32
9-
) -> np.ndarray:
11+
def build_transition_matrices(df: pd.DataFrame, *, dtype=np.float32) -> np.ndarray:
1012
counts = _transition_counts(df, dtype=dtype)
1113
counts += alpha
1214
counts /= counts.sum(axis=2, keepdims=True)

0 commit comments

Comments
 (0)