-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathadaptive_xgboost_example.py
39 lines (33 loc) · 1.8 KB
/
adaptive_xgboost_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from adaptive_xgboost import AdaptiveXGBoostClassifier
from skmultiflow.data import ConceptDriftStream
from skmultiflow.evaluation import EvaluatePrequential
# Adaptive XGBoost classifier parameters
n_estimators = 30 # Number of members in the ensemble
learning_rate = 0.3 # Learning rate or eta
max_depth = 6 # Max depth for each tree in the ensemble
max_window_size = 1000 # Max window size
min_window_size = 1 # set to activate the dynamic window strategy
detect_drift = False # Enable/disable drift detection
AXGBp = AdaptiveXGBoostClassifier(update_strategy='push',
n_estimators=n_estimators,
learning_rate=learning_rate,
max_depth=max_depth,
max_window_size=max_window_size,
min_window_size=min_window_size,
detect_drift=detect_drift)
AXGBr = AdaptiveXGBoostClassifier(update_strategy='replace',
n_estimators=n_estimators,
learning_rate=learning_rate,
max_depth=max_depth,
max_window_size=max_window_size,
min_window_size=min_window_size,
detect_drift=detect_drift)
stream = ConceptDriftStream(random_state=1000,
position=5000)
# stream.prepare_for_use() # Required for skmultiflow v0.4.1
evaluator = EvaluatePrequential(pretrain_size=0,
max_samples=20000,
show_plot=True)
evaluator.evaluate(stream=stream,
model=[AXGBp, AXGBr],
model_names=['AXGBp', 'AXGBr'])