Giter Site home page Giter Site logo

Comments (4)

Shashank-Ravi-0 avatar Shashank-Ravi-0 commented on July 29, 2024 1

Yes. @woodsp-ibm
Thank you so much for the detailed explanation.

from qiskit-machine-learning.

woodsp-ibm avatar woodsp-ibm commented on July 29, 2024

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.

Shashank-Ravi-0 avatar Shashank-Ravi-0 commented on July 29, 2024

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.

woodsp-ibm avatar woodsp-ibm commented on July 29, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.