def calculate_lightgbm_output_shapes(operator): """ Shape calculator for LightGBM Booster (see :epkg:`lightgbm`). """ op = operator.raw_operator if hasattr(op, "_model_dict"): objective = op._model_dict['objective'] else: objective = op.objective_ if objective.startswith('binary') or objective.startswith('multiclass'): return calculate_linear_classifier_output_shapes(operator) if objective.startswith('regression'): return calculate_linear_regressor_output_shapes(operator) raise NotImplementedError( # pragma: no cover "Objective '{}' is not implemented yet.".format(objective))
def calculate_lightgbm_output_shapes(operator): op = operator.raw_operator if hasattr(op, "_model_dict"): objective = op._model_dict['objective'] elif hasattr(op, 'objective_'): objective = op.objective_ else: raise RuntimeError( # pragma: no cover "Unable to find attributes '_model_dict' or 'objective_' in " "instance of type %r (list of attributes=%r)." % ( type(op), dir(op))) if objective.startswith('binary') or objective.startswith('multiclass'): return calculate_linear_classifier_output_shapes(operator) if objective.startswith('regression'): # pragma: no cover return calculate_linear_regressor_output_shapes(operator) raise NotImplementedError( # pragma: no cover "Objective '{}' is not implemented yet.".format(objective))
def my_custom_shape_extractor(operator): raw = operator.raw_operator operator.raw_operator = raw.estimator_ calculate_linear_classifier_output_shapes(operator) operator.raw_operator = raw