Using method used across CatBoost lib for typeof import
@@ -2006,11 +2006,10 @@ class CatBoost(_CatBoostBase):
if type == EFstrType.PredictionDiff:
if data is None and isinstance(data, Pool):
- try:
- import builtins
- except ImportError:
- import __builtin__ as builtins
+ if sys.version_info[0] >= 3:
from builtins import type as typeof
+ else:
+ from __builtin__ import type as typeof
raise CatBoostError("Invalid data type={}, must be list or np.array".format(typeof(data)))
data, _ = self._process_predict_input_data(data, "get_feature_importance")
@@ -2019,11 +2018,10 @@ class CatBoost(_CatBoostBase):
else:
if data is not None and not isinstance(data, Pool):
- try:
- import builtins
- except ImportError:
- import __builtin__ as builtins
+ if sys.version_info[0] >= 3:
from builtins import type as typeof
+ else:
+ from __builtin__ import type as typeof
raise CatBoostError("Invalid data type={}, must be catboost.Pool.".format(typeof(data)))
need_meta_info = type == EFstrType.PredictionValuesChange
