<jupyter_start><jupyter_text>Compute 1-fold Cross Validation for the GMM, CP and TT models<jupyter_code>import sys
sys.path.append('../')

import utils as utl
import datasets as d

%load_ext autoreload
%autoreload 2
# generate toy data
data = d.get_ffjord_data('checkerboard', batch_size=10000)
# define some FAIR K's 
# check the Fariness notebook to see more about this.
Ks_TT = [10, 15, 20, 25, 30, 50, 100]
Ks_CP = [82, 183, 324, 505, 726, 2010, 8020]
Ks_GMM = [59, 131, 232, 361, 519, 1436, 5729]
epochs = 500
CV_splits = 5
batch_size = 500

print('\nCross-validating TT:\n-------------------')
train_error_TT, test_error_TT = utl.CV_1_fold(
    data, Ks_TT, 'TT', CV_splits, epochs, batch_size=batch_size)
print('\nCross-validating CP:\n-------------------')
train_error_CP, test_error_CP = utl.CV_1_fold(
    data, Ks_CP, 'CP', CV_splits, epochs, batch_size=batch_size)
print('\nCross-validating GMM:\n-------------------')
train_error_GMM, test_error_GMM = utl.CV_1_fold(
    data, Ks_GMM, 'GMM', CV_splits, epochs, batch_size=batch_size)
print(train_error_TT.shape)
print(train_error_CP.shape)
print(train_error_GMM.shape)
print('      Training error             Test error')
print(f'TT:  {train_error_TT[0]}         {test_error_TT[0]}')
print(f'CP:  {train_error_CP[0]}         {test_error_CP[0]}')
print(f'GMM: {train_error_GMM[0]}        {test_error_GMM[0]}')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16987865810135616, 'fraction_numerical': 0.05852962169878658, 'mean_word_length': 4.098181818181819, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '562942', 'license': 'MIT', 'n_tokens_mistral': 619, 'n_tokens_neox': 548, 'n_words': 124, 'path': 'notebooks/Cross-Validation Comparisons.ipynb', 'repo_name': 'simonamtoft/tfde-tfp', 'size': '1401'}