I am using source code of split_dataset_to_data_and_labels as I am unable to install qiskit-aqua because of error. But in that source code, "keys" is not being identified. I am using qiskit's tutorials as I am learning, and code I wrote from it, is-:
feature_dim = 2
training_dataset_size = 20
testing_dataset_size = 10
shot = 10000
sample_Total, training_input, test_input, class_labels = ad_hoc_data(training_size=training_dataset_size,
test_size=testing_dataset_size,
gap=0.3,
n=feature_dim,
plot_data=True)
datapoints, class_to_label = split_dataset_to_data_and_labels(test_input)
print(class_to_label)
It is giving this error-:
AttributeError Traceback (most recent call last)
Input In [6], in <cell line: 10>()
4 shot = 10000
5 sample_Total, training_input, test_input, class_labels = ad_hoc_data(training_size=training_dataset_size,
6 test_size=testing_dataset_size,
7 gap=0.3,
8 n=feature_dim,
9 plot_data=True)
---> 10 datapoints, class_to_label = split_dataset_to_data_and_labels(test_input)
11 print(class_to_label)
Input In [4], in split_dataset_to_data_and_labels(dataset, class_names)
22 labels = []
23 if class_names is None:
---> 24 sorted_classes_name = sorted(list(dataset.keys()))
25 class_to_label = {k: idx for idx, k in enumerate(sorted_classes_name)}
26 else:
AttributeError: 'numpy.ndarray' object has no attribute 'keys'
The link to source code, I am using is https://github.com/Qiskit/qiskit-aqua/blob/main/qiskit/aqua/utils/dataset_helper.py . I found at https://stackoverflow.com/questions/66591189/can-you-help-me-in-this-error-attributeerror-numpy-ndarray-object-has-no-att that flags can be used but it also gives error.