Skip to main contentIBM Quantum Documentation
This page is from an old version of Qiskit SDK and does not exist in the latest version. We recommend you migrate to the latest version. See the release notes for more information.

qiskit.aqua.utils.split_dataset_to_data_and_labels

split_dataset_to_data_and_labels(dataset, class_names=None)

GitHub

Split dataset to data and labels numpy array

If class_names is given, use the desired label to class name mapping, or create the mapping based on the keys in the dataset.

Parameters

  • dataset (dict) – {‘A’: numpy.ndarray, ‘B’: numpy.ndarray, …}
  • class_names (dict) – class name of dataset, {class_name: label}

Returns

List contains two arrays of numpy.ndarray type where the array at index 0 is data, an NxD array, and at index 1 it is labels, an Nx1 array, containing values in range 0 to K-1, where K is the number of classes. The dict is a map {str: int}, mapping class name to label. The tuple of list, dict is returned when class_names is not None, otherwise just the list is returned.

Return type

Union(tuple(list, dict), list)

Raises

KeyError – data set invalid

Was this page helpful?
Report a bug or request content on GitHub.