Initialize Pool from array like data.
(
self,
data,
label,
cat_features,
text_features,
embedding_features,
embedding_features_data,
pairs, graph, weight,
group_id,
group_weight,
subgroup_id,
pairs_weight,
baseline,
timestamp,
feature_names,
feature_tags,
thread_count
)
| 1411 | return non_embedding_data_feature_names |
| 1412 | |
| 1413 | def _init( |
| 1414 | self, |
| 1415 | data, |
| 1416 | label, |
| 1417 | cat_features, |
| 1418 | text_features, |
| 1419 | embedding_features, |
| 1420 | embedding_features_data, |
| 1421 | pairs, graph, weight, |
| 1422 | group_id, |
| 1423 | group_weight, |
| 1424 | subgroup_id, |
| 1425 | pairs_weight, |
| 1426 | baseline, |
| 1427 | timestamp, |
| 1428 | feature_names, |
| 1429 | feature_tags, |
| 1430 | thread_count |
| 1431 | ): |
| 1432 | """ |
| 1433 | Initialize Pool from array like data. |
| 1434 | """ |
| 1435 | if isinstance(data, (pd.DataFrame, pl.DataFrame)): |
| 1436 | if feature_names is None: |
| 1437 | feature_names = self._infer_feature_names(data, embedding_features_data, embedding_features) |
| 1438 | if isinstance(data, pd.Series): |
| 1439 | data = data.values.tolist() |
| 1440 | if isinstance(data, FeaturesData): |
| 1441 | samples_count = data.get_object_count() |
| 1442 | features_count = data.get_feature_count() |
| 1443 | elif data is not None: |
| 1444 | if isinstance(data, list): |
| 1445 | data = np.asarray(data, dtype=object) |
| 1446 | if len(np.shape(data)) == 1: |
| 1447 | data = np.expand_dims(data, 1) |
| 1448 | samples_count, features_count = np.shape(data)[:2] |
| 1449 | if embedding_features_data is not None: |
| 1450 | features_count += len(embedding_features_data) |
| 1451 | if isinstance(embedding_features_data, dict): |
| 1452 | embedding_features_data_values = list(embedding_features_data.values()) |
| 1453 | else: |
| 1454 | embedding_features_data_values = embedding_features_data |
| 1455 | for embedding_feature_data in embedding_features_data_values: |
| 1456 | if len(embedding_feature_data) != samples_count: |
| 1457 | raise CatBoostError( |
| 1458 | "samples count in 'embeddings_features_data' does not correspond to samples count in main data" |
| 1459 | ) |
| 1460 | pairs_len = 0 |
| 1461 | if label is not None: |
| 1462 | self._check_label_type(label) |
| 1463 | self._check_label_empty(label) |
| 1464 | if isinstance(label, pl.Series): |
| 1465 | label = pl.DataFrame([label]) |
| 1466 | elif not isinstance(label, pl.DataFrame): |
| 1467 | label = self._label_if_pandas_to_numpy(label) |
| 1468 | if len(np.shape(label)) == 1: |
| 1469 | label = np.expand_dims(label, 1) |
| 1470 | self._check_label_shape(label, samples_count) |
no test coverage detected