<jupyter_start><jupyter_text>Toy 4-D GP<jupyter_code>n = 2000
d = 4
x = 2. * torch.rand(n, d) - 1.

with torch.no_grad():
  covar_module = gp.kernels.ScaleKernel(gp.kernels.RBFKernel())
  params = covar_module.state_dict()
  params['raw_outputscale'] = torch.tensor(1.0).log()
  params['base_kernel.raw_lengthscale'] = torch.Tensor([[1.5]]).log()
  covar_module.load_state_dict(params)

  covar = gp.distributions.MultivariateNormal(torch.zeros(n), covariance_matrix=covar_module(x))

rperm = torch.randperm(n)[:n//2]
train_x = x[rperm]
train_y = (covar.sample() + 0.1 * torch.randn(x.size(0)))[rperm]

#   sample_x = x.squeeze(-1).unsqueeze(0).expand(5, -1).numpy()
#   sample_y = covar.sample(torch.Size([5])).numpy()
#   label = np.repeat(np.array([['a', 'b', 'c', 'd', 'e']]).T, n, axis=1)
#   plot_data = {
#     'x': sample_x.flatten().tolist(),
#     'y': sample_y.flatten().tolist(),
#     'id': label.flatten()
#   }

# alt.Chart(pd.DataFrame(plot_data)).mark_line().encode(x='x', y='y', color='id') +\
# alt.Chart(pd.DataFrame({ 'x': train_x.squeeze(-1).numpy(), 'y': train_y.numpy() })).mark_circle().encode(x='x', y='y')
results = defaultdict(list)<jupyter_output><empty_output><jupyter_text>Exact GP<jupyter_code>for _ in tqdm(range(10)):
  egp = ExactGPModel(train_x, train_y).float()

  train_dict = train_util(egp, train_x, train_y)
  
  for name, p in egp.named_parameters():
    results[name].append(p)
  results['kind'].append('Exact GP')
  for k, v in train_dict.items():
    results[k].append(v)<jupyter_output><empty_output><jupyter_text>Bilateral GP<jupyter_code>for _ in tqdm(range(10)):
  bigp = BilateralGPModel(train_x, train_y).float()

  with gp.settings.max_root_decomposition_size(50):
    train_dict = train_util(bigp, train_x, train_y)
  
  for name, p in bigp.named_parameters():
    results[name].append(p)
  results['kind'].append('Bilateral GP')
    
  for k, v in train_dict.items():
    results[k].append(v)
for _ in tqdm(range(10)):
  skipgp = SKIPGPModel(train_x, train_y, 100).float()

  with gp.settings.max_root_decomposition_size(50):
    train_dict = train_util(skipgp, train_x, train_y)
  
  for name, p in skipgp.named_parameters():
    results[name].append(p)
  results['kind'].append('SKIP-GP')
    
  for k, v in train_dict.items():
    results[k].append(v)
results.keys()
data = {
  'obs_noise': [v.exp().item() for v in results['likelihood.noise_covar.raw_noise']],
  'ls': [v.exp().item() for v in results['covar_module.raw_lengthscale']] + [v.exp().item() for v in results['base_covar_module.raw_lengthscale']],
  'train/ll': results['train/ll'],
  'kind': results['kind'],
}
error_bars = alt.Chart(pd.DataFrame(data)).mark_errorbar(extent='stdev').encode(
  x=alt.X('obs_noise:Q', scale=alt.Scale(zero=False)),
  y=alt.Y('kind:N')
)

points = alt.Chart(pd.DataFrame(data)).mark_point(filled=True, color='black').encode(
  x=alt.X('obs_noise:Q', aggregate='mean'),
  y=alt.Y('kind:N'),
)

(error_bars + points).properties(width=800,height=100)
error_bars = alt.Chart(pd.DataFrame(data)).mark_errorbar(extent='stdev').encode(
  x=alt.X('ls:Q', scale=alt.Scale(zero=False)),
  y=alt.Y('kind:N')
)

points = alt.Chart(pd.DataFrame(data)).mark_point(filled=True, color='black').encode(
  x=alt.X('ls:Q', aggregate='mean'),
  y=alt.Y('kind:N'),
)

(error_bars + points).properties(width=800,height=100)
error_bars = alt.Chart(pd.DataFrame(data)).mark_errorbar(extent='stdev').encode(
  x=alt.X('train/ll:Q', scale=alt.Scale(zero=False)),
  y=alt.Y('kind:N')
)

points = alt.Chart(pd.DataFrame(data)).mark_point(filled=True, color='black').encode(
  x=alt.X('train/ll:Q', aggregate='mean'),
  y=alt.Y('kind:N'),
)

(error_bars + points).properties(width=800,height=100)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20464247598719318, 'fraction_numerical': 0.0144076840981857, 'mean_word_length': 5.647163120567376, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '619593', 'license': 'Apache-2.0', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1502, 'n_words': 203, 'path': 'notebooks/bi_gp_ls.ipynb', 'repo_name': 'activatedgeek/simplex-gp', 'size': '3748'}