MCPcopy Create free account
hub / github.com/catboost/catboost / _check_data_empty

Method _check_data_empty

catboost/python-package/catboost/core.py:938–960  ·  view source on GitHub ↗

Check that data is not empty (0 objects is ok). note: already checked if data is FeatureType, so no need to check again

(self, data)

Source from the content-addressed store, hash-verified

936 )
937
938 def _check_data_empty(self, data):
939 """
940 Check that data is not empty (0 objects is ok).
941 note: already checked if data is FeatureType, so no need to check again
942 """
943
944 if isinstance(data, PATH_TYPES):
945 if not data:
946 raise CatBoostError("Features filename is empty.")
947 elif isinstance(data, (ARRAY_TYPES, SPARSE_MATRIX_TYPES)):
948 if isinstance(data, list):
949 data_shape = np.shape(np.asarray(data, dtype=object))
950 else:
951 data_shape = np.shape(data)
952 if len(data_shape) == 1 and data_shape[0] > 0:
953 if isinstance(data[0], Iterable):
954 data_shape = tuple(data_shape + tuple([len(data[0])]))
955 else:
956 data_shape = tuple(data_shape + tuple([1]))
957 if len(data_shape) not in (2, 3):
958 raise CatBoostError("Input data has invalid shape: {}. Must be 2 or 3 dimensional".format(data_shape))
959 if data_shape[1] == 0:
960 raise CatBoostError("Input data must have at least one feature")
961
962 def _check_label_type(self, label):
963 """

Callers 1

__init__Method · 0.95

Calls 6

isinstanceFunction · 0.85
lenFunction · 0.85
CatBoostErrorClass · 0.50
tupleClass · 0.50
shapeMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected