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)
| 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 | """ |
no test coverage detected