1212array([0, 1])
1313"""
1414
15+ from typing import Any
16+
1517import numpy as np
16- from typing import Any , Dict , List
1718
1819
1920class 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 :
0 commit comments