Skip to content

Commit 20aeab7

Browse files
add verbosity parameter
1 parent d0d24b8 commit 20aeab7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

unifiedbooster/gbdt_classification.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ def __init__(self, model_type='xgboost',
99
n_estimators=100,
1010
learning_rate=0.1,
1111
max_depth=3,
12-
subsample=1.0,
12+
subsample=1.0,
13+
verbosity=0,
1314
**kwargs):
1415
self.model_type = model_type
1516
self.n_estimators = n_estimators
1617
self.learning_rate = learning_rate
1718
self.max_depth = max_depth
1819
self.subsample = subsample
20+
self.verbosity = verbosity
1921
# xgboost -----
2022
# n_estimators
2123
# learning_rate
@@ -37,6 +39,7 @@ def __init__(self, model_type='xgboost',
3739
'learning_rate': self.learning_rate,
3840
'subsample': self.subsample,
3941
'max_depth': self.max_depth,
42+
'verbosity': self.verbosity,
4043
**kwargs
4144
}
4245
elif self.model_type == "lightgbm":
@@ -45,6 +48,7 @@ def __init__(self, model_type='xgboost',
4548
'learning_rate': self.learning_rate,
4649
'bagging_fraction': self.subsample,
4750
'max_depth': self.max_depth,
51+
'verbose': self.verbosity - 1 if self.verbosity==0 else self.verbosity
4852
**kwargs
4953
}
5054
elif self.model_type == "catboost":
@@ -53,13 +57,14 @@ def __init__(self, model_type='xgboost',
5357
'learning_rate': self.learning_rate,
5458
'rsm': self.subsample,
5559
'depth': self.max_depth,
60+
'verbose': self.verbosity
5661
**kwargs
5762
}
5863

5964
if model_type == 'xgboost':
6065
self.model = XGBClassifier(**self.params)
6166
elif model_type == 'catboost':
62-
self.model = CatBoostClassifier(**self.params)
67+
self.model = CatBoostClassifier(**self.params, logging_level='Silent')
6368
elif model_type == 'lightgbm':
6469
self.model = LGBMClassifier(**self.params)
6570
else:

unifiedbooster/gbdt_regression.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ def __init__(self, model_type='xgboost',
99
n_estimators=100,
1010
learning_rate=0.1,
1111
max_depth=3,
12-
subsample=1.0,
12+
subsample=1.0,
13+
verbosity=0,
1314
**kwargs):
1415
self.model_type = model_type
1516
self.n_estimators = n_estimators
1617
self.learning_rate = learning_rate
1718
self.max_depth = max_depth
1819
self.subsample = subsample
20+
self.verbosity = verbosity
1921
# xgboost -----
2022
# n_estimators
2123
# learning_rate
@@ -37,6 +39,7 @@ def __init__(self, model_type='xgboost',
3739
'learning_rate': self.learning_rate,
3840
'subsample': self.subsample,
3941
'max_depth': self.max_depth,
42+
'verbosity': self.verbosity,
4043
**kwargs
4144
}
4245
elif self.model_type == "lightgbm":
@@ -45,6 +48,7 @@ def __init__(self, model_type='xgboost',
4548
'learning_rate': self.learning_rate,
4649
'bagging_fraction': self.subsample,
4750
'max_depth': self.max_depth,
51+
'verbose': self.verbosity - 1 if self.verbosity==0 else self.verbosity
4852
**kwargs
4953
}
5054
elif self.model_type == "catboost":
@@ -53,13 +57,14 @@ def __init__(self, model_type='xgboost',
5357
'learning_rate': self.learning_rate,
5458
'rsm': self.subsample,
5559
'depth': self.max_depth,
60+
'verbose': self.verbosity
5661
**kwargs
5762
}
5863

5964
if model_type == 'xgboost':
6065
self.model = XGBRegressor(**self.params)
6166
elif model_type == 'catboost':
62-
self.model = CatBoostRegressor(**self.params)
67+
self.model = CatBoostRegressor(**self.params, logging_level='Silent')
6368
elif model_type == 'lightgbm':
6469
self.model = LGBMRegressor(**self.params)
6570
else:

0 commit comments

Comments
 (0)