Comments (4)
Yes. @woodsp-ibm
Thank you so much for the detailed explanation.
from qiskit-machine-learning.
This was originally posted here https://stackoverflow.com/questions/68598726/ad-hoc-data-resulting-in-test-input-as-an-array-instead-of-a-dictionary
As I mentioned there the above code sample works fine if you use these imports (i.e using all Aqua - which is deprecated now though)
from qiskit.ml.datasets import ad_hoc_data
from qiskit.aqua.utils import split_dataset_to_data_and_labels
It shows you using Aqua in the error message i.e. it occurs related to
anaconda3\lib\site-packages\qiskit\aqua\utils\dataset_helper.py which no longer exists in this repo.
There were changes done to datasets. What Tutorial are you following - I imagine it was done for Aqua if you are using function from Aqua.
This tutorial from Machine Learning here shows using ad_hoc with the code here for Classification https://qiskit.org/documentation/machine-learning/tutorials/03_quantum_kernel.html?highlight=ad_hoc#Classification Maybe this helps you.
from qiskit-machine-learning.
This was originally posted here https://stackoverflow.com/questions/68598726/ad-hoc-data-resulting-in-test-input-as-an-array-instead-of-a-dictionary
As I mentioned there the above code sample works fine if you use these imports (i.e using all Aqua - which is deprecated now though)
from qiskit.ml.datasets import ad_hoc_data from qiskit.aqua.utils import split_dataset_to_data_and_labels
It shows you using Aqua in the error message i.e. it occurs related to
anaconda3\lib\site-packages\qiskit\aqua\utils\dataset_helper.py which no longer exists in this repo.
There were changes done to datasets. What Tutorial are you following - I imagine it was done for Aqua if you are using function from Aqua.
This tutorial from Machine Learning here shows using ad_hoc with the code here for Classification https://qiskit.org/documentation/machine-learning/tutorials/03_quantum_kernel.html?highlight=ad_hoc#Classification Maybe this helps you.
Yes I completely understand that. The following code works and makes sense.
from qiskit.ml.datasets import ad_hoc_data
from qiskit.aqua.utils import split_dataset_to_data_and_labels
But my doubt is : What should be my procedure of import after taking into consideration the deprecation. That is, like from qiskit_machine_learning.datasets import ad_hoc_data
, what should be my "new" valid code for importing split_dataset_to_data_and_labels
? (i.e. importing without ANY DeprecationWarning)
from qiskit-machine-learning.
I had linked above a new tutorial that shows the use of the ad_hoc dataset as it now is. Code when it was moved from Aqua was also possibly refactored/removed etc. While your code "works" in accessing the dataset, what you got back as values before is different from what you get now. Hence the error you got when trying to take data from the dataset here and giving it to the old aqua routine. If I change your code to this
from qiskit_machine_learning.datasets import ad_hoc_data
feature_dim=2
training_dataset_size=20
testing_dataset_size=10
random_seed=10598
shots=10000
train_features, train_labels, test_features, test_labels, adhoc_total = ad_hoc_data(
training_size=training_dataset_size,
test_size=testing_dataset_size,
n=feature_dim,
gap=0.3,
plot_data=True, one_hot=False, include_sample_total=True
)
and I am naming the vars as per the tutorial I linked above, that uses adhoc data, so you can clearly see by name what they contain, then you will see what you get back is features and labels. It is not a dictionary of labels as keys with data that you can split apart - which is why you get the error when you try and put return values from the new dataset into the old code that tries to split them. The method is no longer here.
Is that clearer?
from qiskit-machine-learning.
Related Issues (20)
- Warning showing in 02a_training_a_quantum_model_on_a_real_dataset from pandas HOT 1
- Add Python 3.12 support
- Update links to qiskit.org/documentation HOT 1
- Clarification on Method Used for PSD Projection in FidelityQuantumKernel HOT 5
- VQC inside session HOT 3
- Improve documentation on reshaping SamplerQNN output via interpret Callable
- How to merge custom quantum circuit with quantum machine learning model circuit? HOT 2
- Machine Learning Unit Tests Badge Shows Fail
- TorchConnector returns two sets of weights in the state dict instead of one
- ISA circuit support for latest Runtime HOT 4
- Enhancement of PyTorch connector HOT 2
- Extend unit test coverage with `Hypothesis` in numerical tests
- Add `jit` compilation to the Torch connector with `thunder`
- Revamp `README.md` with structured information HOT 4
- Set up a security policy (@maintainers)
- Multi-class Classification Problem Using QSVC HOT 3
- Error when testing samples with labels other than {0, 1} in the MNIST dataset. HOT 6
- Revert CI environment to latest PyTorch once UTF bug is fixed
- Binary classification problem using NeuralNetworkClassifier and cross entropy loss HOT 1
- MacOS in CI - macos-latest is now ARM HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qiskit-machine-learning.