Skip to content

Commit bce8654

Browse files
committed
Update ARIMA time series Model
1 parent a130bf8 commit bce8654

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

machine_learning/adaboost.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@
1212
array([0, 1])
1313
"""
1414

15+
from typing import Any
16+
1517
import numpy as np
16-
from typing import Any, Dict, List
1718

1819

1920
class AdaBoost:
@@ -23,8 +24,8 @@ def __init__(self, n_estimators: int = 50) -> None:
2324
n_estimators: Number of boosting rounds.
2425
"""
2526
self.n_estimators: int = n_estimators
26-
self.alphas: List[float] = [] # Weights for each weak learner
27-
self.models: List[Dict[str, Any]] = [] # List of weak learners (stumps)
27+
self.alphas: list[float] = [] # Weights for each weak learner
28+
self.models: list[dict[str, Any]] = [] # List of weak learners (stumps)
2829

2930
def fit(self, feature_matrix: np.ndarray, target: np.ndarray) -> None:
3031
"""Fit AdaBoost model.
@@ -77,11 +78,11 @@ def _build_stump(
7778
feature_matrix: np.ndarray,
7879
target_signed: np.ndarray,
7980
sample_weights: np.ndarray,
80-
) -> Dict[str, Any]:
81+
) -> dict[str, Any]:
8182
"""Find the best decision stump for current weights."""
8283
n_samples, n_features = feature_matrix.shape
8384
min_error = float("inf")
84-
best_stump: Dict[str, Any] = {}
85+
best_stump: dict[str, Any] = {}
8586
for feature in range(n_features):
8687
thresholds = np.unique(feature_matrix[:, feature])
8788
for threshold in thresholds:

machine_learning/arima.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
array([10.99999999, 12.00000001])
1313
"""
1414

15+
1516
import numpy as np
16-
from typing import Optional
1717

1818

1919
class ARIMAModel:
@@ -27,8 +27,8 @@ def __init__(self, ar_order: int = 1, diff_order: int = 0, ma_order: int = 0) ->
2727
self.ar_order = ar_order
2828
self.diff_order = diff_order
2929
self.ma_order = ma_order
30-
self.coef_: Optional[np.ndarray] = None
31-
self.resid_: Optional[np.ndarray] = None
30+
self.coef_: np.ndarray | None = None
31+
self.resid_: np.ndarray | None = None
3232

3333
def difference(self, time_series: np.ndarray, order: int) -> np.ndarray:
3434
"""Apply differencing to make series stationary."""

0 commit comments

Comments
 (0)