<jupyter_start><jupyter_text>EmulatorI am using Gaussian Process to build an Emulator of FOM(Figure Of Merit) in 6-D parameter Space. I have predicted a FOM value for last raw from given data. Results are shown as the value of predicted FOM and given FOM.<jupyter_code>import george
import numpy as np
import matplotlib.pyplot as pl
from george import kernels
from scipy.optimize import minimize
from george.metrics import Metric
%matplotlib inline
a = np.loadtxt("parameters_with_FOM.txt")
area = a[:,0]
depth = a[:,1]
shear_m = a[:,2]
sigma_z = a[:,3]
sig_delta_z = a[:,4]
sig_sigma_z= a[:,5]
FOM = a[:,6]
#slicing up the array in 7 column array
Sarea = (area-np.mean(area))/np.std(area)
Sdepth = (depth-np.mean(depth))/np.std(depth)
Sshear_m = (shear_m-np.mean(shear_m))/np.std(shear_m)
Ssigma_z = (sigma_z-np.mean(sigma_z))/np.std(sigma_z)
Ssig_delta_z = (sig_delta_z-np.mean(sig_delta_z))/np.std(sig_delta_z)
Ssig_sigma_z = (sig_sigma_z-np.mean(sig_sigma_z))/np.std(sig_sigma_z)
SFOM = (FOM-np.mean(FOM))/np.std(FOM)
#standardizing the data
x = np.column_stack([Sarea, Sdepth, Sshear_m, Ssigma_z, Ssig_delta_z, Ssig_sigma_z])
#Putting together standardised parameter array
kernel = kernels.ExpSquaredKernel(metric=[1,1,1,1,1,1], ndim=6)
#creating a kernel-covariance in 6-D parameter space
gp = george.GP(kernel, mean=np.mean(SFOM))
gp.compute(x[:-1])

def neg_ln_lik(p):
            gp.set_parameter_vector(p)
            return -gp.log_likelihood(SFOM[:-1]) 
def grad_neg_ln_like(p):
            gp.set_parameter_vector(p)
            return -gp.grad_log_likelihood(SFOM[:-1]) 

result = minimize(neg_ln_lik, gp.get_parameter_vector(), jac=grad_neg_ln_like)

gp.set_parameter_vector(result.x)
#running Gaussian process
PSFOM, PerameterValues = gp.predict(SFOM[:-1], [x[-1]])
#Predicting the test point(Which is the last raw of data here)
PFOM = (PSFOM*np.std(FOM))+np.mean(FOM)
#De-standardizing the standardised predicted FOM value
PFOM[0], FOM[-1]
#Comparing the predicted FOM and given FOM<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1310990635781173, 'fraction_numerical': 0.011828486939379004, 'mean_word_length': 5.403785488958991, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '588797', 'license': 'MIT', 'n_tokens_mistral': 807, 'n_tokens_neox': 792, 'n_words': 181, 'path': 'Emulator_fom.ipynb', 'repo_name': 'CosmoLike/LSST_emu', 'size': '2029'}