Coder Social home page Coder Social logo

Comments (7)

yaelbh avatar yaelbh commented on September 15, 2024

Maybe part of BaseAnalysis ?

from qiskit-experiments.

eggerdj avatar eggerdj commented on September 15, 2024

That could also work.

from qiskit-experiments.

nkanazawa1989 avatar nkanazawa1989 commented on September 15, 2024

Based on our discussion offline, let me add some discussion points.

I was first proposing to have internal data structure in columnar format, so that we can manage arbitrary xvalue (in QPT, xvalue may consist of multiple column of "meas_basis" and "prep_basis", Hamiltonian tomography may have more). More specifically, we can generate a dataframe in the BaseExperiment class. Data added to the instance will be immediately formatted and stored in the dataframe.

The point was if we really need such internal data representation at the cost of extra dependency. Because the list of dictionary shown above is still enough to generate xy values, and we can locally store the exp data instance as a json. However, I see two advantages of having such internal data structure.

  1. data handling
    dataframe can provide variety filtering methods. So we don't need to loop over the list manually.

  2. saveing/loading data
    json dump is not great method due to the serialization overhead. If we store the experiment result of 3Q QPT, we need to store typ. 1728 entries. I didn't benchmark this yet, but I imagine this will generate huge datafile and dump/load take long time. dataframe can support multiple binary file format such as hdf5.

Perhaps we can start from simple dict structure above, and switch to have proper data structure at some point.

from qiskit-experiments.

nkanazawa1989 avatar nkanazawa1989 commented on September 15, 2024

As we discussed in #24 , ambiguity of metadata field should be resolved by this extraction function. Sometime we cannot define explicit series, i.e. see Hamiltonian tomography example, it would be better to have API

def extract_xy_values(exp_data: ExperimentData, data_key: str, **filter: Any) -> Tuple[np.array, np.array]:

so that we can write

extract_xy_values(ham_tomo_data, data_key='delay', meas_basis='X', control_state=0)

Another point I want to discuss is how to extend this function to

  • no scan (e.g. discriminator)
  • multi-axes scan (e.g. chevron)

because current function supports only single data_key.

One possible solution would be:

def extract_xy_values(exp_data: ExperimentData, *data_key: str, **filter: Any) -> Union[np.array, Tuple[np.array, np.array]]:

Then we can extract x-y value more flexibly.

  • no data key
extract_xy_values(discr_data, prep_state=0) -> np.ndarray(1, N)
  • 1d scan
extract_xy_values(ramsey_data, 'delay', meas_basis='x') -> Tuple[np.array(1, N), np.array(1, N)]
  • 2d scan
extract_xy_values(ramsey_data, 'delay', 'detuning') -> Tuple[np.array(2, N), np.array(1, N)]

from qiskit-experiments.

chriseclectic avatar chriseclectic commented on September 15, 2024

I updated the curve fit PR to allow a bit more generic way of getting x and y data in its helper functions:

It now has

def curve_fit_data(
    data: List[Dict[str, any]],
    data_processor: Callable,
    x_key: str = "xval"
) -> Tuple[xdata: ndarray(N), ydata: ndarray(N), sigma: ndarray(N)]

and

def multi_curve_fit_data(
    data: List[Dict[str, any]],
    data_processor: Callable,
    x_key: str = "xval",
    series_key: str = "series"
) -> Tuple[xdata: ndarray(N, 2), ydata: ndarray(N), sigma: ndarray(N)]

I think these cover the last two cases naoki mentioned above (minus filtering which would be a nice addition). The no-scan case I don't see as xy data at all. It is just regular data processing since you are converting a list of data into some array of values (Note the array convention is transposed to the one Naoki suggests because of the way i originally wrote the curve_fit and multi_curve_fit functions which these are designed to extract the input for)

Here the data_processor function is a bit different to the data processor PR, but is a callable with specific signature data_processor(data: Dict[str, any]) -> Tuple[y: float, sigma: float]

from qiskit-experiments.

nkanazawa1989 avatar nkanazawa1989 commented on September 15, 2024

Can this be closed? @chriseclectic

from qiskit-experiments.

gadial avatar gadial commented on September 15, 2024

Closing as this issue was addressed

from qiskit-experiments.

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.