add scale_pos_weight parameter
@@ -528,6 +528,21 @@ class CatBoost(_CatBoostBase):
raise CatboostError("Invalid param `{}`.".format(param))
def _process_synonyms(self, params):
+ if 'objective' in params:
+ if 'loss_function' in params:
+ raise CatboostError('only one of parameters loss_function, objective should be initialized.')
+ params['loss_function'] = params['objective']
+ del params['objective']
+
+
+ if 'scale_pos_weight' in params:
+ if 'loss_function' in params and params['loss_function'] != 'Logloss':
+ raise CatboostError('scale_pos_weight is only supported for binary classification Logloss loss')
+ if 'class_weights' in params:
+ raise CatboostError('only one of parameters scale_pos_weight, class_weights should be initialized.')
+ params['class_weights'] = [1.0, params['scale_pos_weight']]
+ del params['scale_pos_weight']
+
if 'eta' in params:
if 'learning_rate' in params:
raise CatboostError('only one of parameters learning_rate, eta should be initialised.')
@@ -540,12 +555,6 @@ class CatBoost(_CatBoostBase):
params['learning_rate'] = params['max_bin']
del params['max_bin']
- if 'objective' in params:
- if 'loss_function' in params:
- raise CatboostError('only one of parameters loss_function, objective should be initialized.')
- params['loss_function'] = params['objective']
- del params['objective']
-
if 'max_depth' in params:
if 'depth' in params:
raise CatboostError('only one of parameters depth, max_depth should be initialised.')
@@ -1313,6 +1322,10 @@ class CatBoostClassifier(CatBoost):
eta : float, synonym for learning_rate.
max_bin : float, synonym for border_count.
+
+ scale_pos_weight : float, synonym for class_weights.
+ Can be used only for binary classification. Sets weight multiplier for
+ class 1 to scale_pos_weight value.
"""
def __init__(
self,
@@ -1379,6 +1392,7 @@ class CatBoostClassifier(CatBoost):
objective=None,
eta=None,
max_bin=None,
+ scale_pos_weight=None,
**kwargs
):
if objective is not None:
