|
21 | 21 | data.X_test = scaler_X.transform(data.X_test) |
22 | 22 |
|
23 | 23 | data.y_train, scaler_y = data.scale(data.y_train, scaling_methods=("standard", "minmax")) |
24 | | -data.y_train = data.y_train.ravel() |
25 | | -data.y_test = scaler_y.transform(data.y_test.reshape(-1, 1)).ravel() |
| 24 | +data.y_test = scaler_y.transform(data.y_test) |
26 | 25 |
|
27 | 26 | # Define param bounds |
28 | 27 |
|
29 | | -# param_grid = { ==> This is for GridSearchCV, show you how to convert to our MetaSearchCV |
| 28 | +# param_grid = { ==> This is for GridSearchCV, base on this, you can convert to our MetaSearchCV bounds |
30 | 29 | # 'criterion': ['squared_error', 'friedman_mse', 'absolute_error', 'poisson'], # (regression) |
31 | | -# 'splitter': ['best', 'random'], # Cách chọn cách chia tại mỗi node |
32 | | -# 'max_depth': [None, 5, 10, 20, 30], # Độ sâu tối đa của cây |
33 | | -# 'min_samples_split': [2, 5, 10], # Số lượng mẫu tối thiểu để một node được chia |
34 | | -# 'min_samples_leaf': [1, 2, 4], # Số lượng mẫu tối thiểu tại một node lá |
35 | | -# 'max_features': [None, 'sqrt', 'log2'], # Số đặc trưng tối đa khi tìm split tốt nhất |
36 | | -# 'max_leaf_nodes': [None, 10, 20, 50], # Giới hạn số lượng node lá |
37 | | -# 'ccp_alpha': [0.0, 0.01, 0.05, 0.1], # Complexity parameter để cắt tỉa cây (post-pruning) |
| 30 | +# 'splitter': ['best', 'random'], |
| 31 | +# 'max_depth': [None, 5, 10, 20, 30], |
| 32 | +# 'min_samples_split': [2, 5, 10], |
| 33 | +# 'min_samples_leaf': [1, 2, 4], |
| 34 | +# 'max_features': [None, 'sqrt', 'log2'], |
| 35 | +# 'max_leaf_nodes': [None, 10, 20, 50], |
| 36 | +# 'ccp_alpha': [0.0, 0.01, 0.05, 0.1], |
38 | 37 | # } |
39 | 38 |
|
40 | 39 | param_bounds = [ |
41 | | - StringVar(valid_sets=("squared_error", "friedman_mse", "absolute_error", "poisson"), name="criterion"), # (regression) |
42 | | - StringVar(valid_sets=("best", "random"), name="splitter"), # Cách chọn cách chia tại mỗi node |
43 | | - IntegerVar(lb=2, ub=15, name="max_depth"), # Độ sâu tối đa của cây |
44 | | - IntegerVar(lb=2, ub=10, name="min_samples_split"), # Số lượng mẫu tối thiểu để một node được chia |
45 | | - IntegerVar(lb=1, ub=5, name="min_samples_leaf"), # Số lượng mẫu tối thiểu tại một node lá |
46 | | - StringVar(valid_sets=("sqrt", "log2"), name="max_features"), # Số đặc trưng tối đa khi tìm split tốt nhất |
47 | | - IntegerVar(lb=2, ub=30, name="max_leaf_nodes"), # Giới hạn số lượng node lá |
48 | | - FloatVar(lb=0.0, ub=0.1, name="ccp_alpha"), # Complexity parameter để cắt tỉa cây (post-pruning) |
| 40 | + StringVar(valid_sets=("squared_error", "friedman_mse", "absolute_error", "poisson"), name="criterion"), |
| 41 | + StringVar(valid_sets=("best", "random"), name="splitter"), |
| 42 | + IntegerVar(lb=2, ub=15, name="max_depth"), |
| 43 | + IntegerVar(lb=2, ub=10, name="min_samples_split"), |
| 44 | + IntegerVar(lb=1, ub=5, name="min_samples_leaf"), |
| 45 | + StringVar(valid_sets=("sqrt", "log2"), name="max_features"), |
| 46 | + IntegerVar(lb=2, ub=30, name="max_leaf_nodes"), |
| 47 | + FloatVar(lb=0.0, ub=0.1, name="ccp_alpha"), |
49 | 48 | ] |
50 | 49 |
|
51 | 50 | # Initialize and fit MetaSearchCV |
|
59 | 58 | scoring="MSE", # or any custom scoring like "F1_macro" |
60 | 59 | seed=42, |
61 | 60 | n_jobs=2, |
62 | | - verbose=True |
| 61 | + verbose=True, |
| 62 | + mode='single', n_workers=None, termination=None |
63 | 63 | ) |
64 | 64 |
|
65 | 65 | searcher.fit(data.X_train, data.y_train) |
|
0 commit comments