<jupyter_start><jupyter_text>Cohort Project - DWave Data Set<jupyter_code>import numpy as np
import helper as dw
import csv<jupyter_output><empty_output><jupyter_text>Load the Training and Validation data from the DWave npz file<jupyter_code>train, val = dw.load_dataset("dataset_x1a46w3557od23s750k9.npz")
print (train.shape)
print (val.shape)<jupyter_output><empty_output><jupyter_text>Load the correlated features csv data<jupyter_code>corr_feat = []
with open('correlated_features.csv', newline='') as csvfile:
  reader = csv.reader(csvfile, delimiter=',')
  for row in reader:
    corr_feat.append(row)

print (len(corr_feat))

#for r in cf:
#  print (r[0],r[1],r[2])<jupyter_output><empty_output><jupyter_text>Add Code below to process the data<jupyter_code>#BASIC Template code - TO BE MODIFIED
from dwave.system import DWaveSampler, EmbeddingComposite

#Converts the QUBO into a BinaryQuadraticModel and then calls sample().
sampler = EmbeddingComposite(DWaveSampler())

#Example encoding for x0,x1,x2,x4: needs to be generalized based on dataset
Q = {('x0', 'x0'):1, ('x1', 'x1'):1, ('x2', 'x2'):1, ('x3', 'x3'):1, ('x4', 'x4'):1,}

results = sampler.sample_qubo(Q, num_reads=10000)

# print the results
for smpl, energy in results.data(['sample', 'energy']):
    print(smpl, energy)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1361573373676248, 'fraction_numerical': 0.030257186081694403, 'mean_word_length': 7.116564417177914, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '177894', 'license': 'MIT', 'n_tokens_mistral': 522, 'n_tokens_neox': 490, 'n_words': 120, 'path': 'Project_1_RBM_and_Tomography/.ipynb_checkpoints/CDL_DWaveSet-checkpoint.ipynb', 'repo_name': 'CDLQuantum2020-RBM-Team3/CohortProject_2020-1', 'size': '1322'}