<jupyter_start><jupyter_text>Computing time We compare the computing time of our method with other existing methods, including Hopfield approximation (HF), Maximum Likelihood Estimation (MLE), and Pseudo Likelihood Estimations (PLE). The code for PLE was adapted from ConIII package (https://github.com/eltrompetero/coniii).As shown in the previous sections, MLE cannot work for large system such as 40 variables, PLE cannot work for very large system size such as 100 variables. In the following, we will consider a small system with 20 variables. The computing time of MLE and PLE increases rapidly as system size increases (see our paper for more detail).<jupyter_code>import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import emachine as EM
import timeit
np.random.seed(0)<jupyter_output><empty_output><jupyter_text>We set parameters.<jupyter_code>n_var = 20
g = 1.0
n_seq = 400<jupyter_output><empty_output><jupyter_text>Variable configurations are generated.<jupyter_code>w_true,seqs = EM.generate_seq(n_var,n_seq,g=g)
ops = EM.operators(seqs)
# Epsilon Machine (EM)
start_time = timeit.default_timer()

eps_list = np.linspace(0.5,0.9,9)
E_eps = np.zeros(len(eps_list))
w_eps = np.zeros((len(eps_list),ops.shape[1]))
for i,eps in enumerate(eps_list):    
    w_eps[i,:],E_eps[i] = EM.fit(ops,eps=eps,max_iter=100)
    #print(eps,E_eps[i])    
ieps = np.argmax(E_eps)
#print('The optimal value of eps:',eps_list[ieps])
w_em = w_eps[ieps]

run_time_em = timeit.default_timer() - start_time
# Hopfield approximation (HF)
start_time = timeit.default_timer()
w_hf = EM.hopfield_method(seqs)
run_time_hf = timeit.default_timer() - start_time
# Maximum Likelihood Estimation (MLE)
start_time = timeit.default_timer()
w_mle = EM.MLE_method(seqs)
run_time_mle = timeit.default_timer() - start_time
# Pseudo Likelihood Estimation (PLE)
start_time = timeit.default_timer()
w_ple = EM.PLE_method(seqs)
run_time_ple = timeit.default_timer() - start_time<jupyter_output><empty_output><jupyter_text>We compare the performance and computing time of these methods.<jupyter_code>MSE_em = ((w_true - w_em)**2).mean()
MSE_hf = ((w_true - w_hf)**2).mean()
MSE_mle = ((w_true - w_mle)**2).mean()
MSE_ple = ((w_true - w_ple)**2).mean()

df = pd.DataFrame([['EM',MSE_em,run_time_em],
                   ['HF',MSE_hf,run_time_hf],
                   ['MLE',MSE_mle,run_time_mle],
                   ['PLE',MSE_ple,run_time_ple]],
                  columns = ['Method','Mean squared error','Computing time (s)'])
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11905697445972495, 'fraction_numerical': 0.01100196463654224, 'mean_word_length': 5.286419753086419, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 1, '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': '191638', 'license': 'MIT', 'n_tokens_mistral': 938, 'n_tokens_neox': 904, 'n_words': 222, 'path': '.ipynb_checkpoints/computing_time-checkpoint.ipynb', 'repo_name': 'danhtaihoang/e-machine', 'size': '2545'}