Skip to content

copyright2010/IQGO-Iterative-Quantum-Gate-Optimiser

Repository files navigation

IQGO Module

Installation

To install the IQGO module, run the following command:

pip install IQGO-module

Getting Started

from sklearn.datasets import load_iris
from IQGO_module.iqgo_training import IQGO_train
import numpy as np
import pandas as pd

X, y = load_iris(return_X_y=True, as_frame=True)

acc_test, acc_val, save_noise, cct = [], [], [], []

# test multiple seed values 
seeds = np.array([42**4,231,42*4,123,3223,341,222])

for noise in seeds:

    # initialise IQGO with the noise level, noise random seed and the kfold splits
    init_iqgo = IQGO_train(noise_level = 0.0, seed_val=noise, kfold_splits=5)

    fitted_circuit = init_iqgo.fit(data_train=X, labels=y, number_of_layers = 3)

    # hardcode the best compiled circuit for testing 
    #fitted_circuit = np.array([13, 26, 8]) #best

    predictions, column_means = init_iqgo.predict(data_train = X, labels = y, compiled_circuit=fitted_circuit,mode='test')
    acc_test.append(column_means)
    
    predictions, column_means = init_iqgo.predict(data_train = X, labels = y, compiled_circuit=fitted_circuit,mode='val')
    
    acc_val.append(column_means)
    save_noise.append(noise)
    cct.append(fitted_circuit)
    print('done')
    print(fitted_circuit)


print('Acc test: ',acc_test)
print('Acc val: ',acc_val)

save_noise = np.transpose(save_noise)

print(save_noise)
all = pd.DataFrame([save_noise, acc_test, acc_val, cct])

# save the compiled circuits to select the best one
all.to_csv('compiled_circuits.csv')

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages