<jupyter_start><jupyter_text>Using GSO and updated Objective<jupyter_code>import copy
from Optimization_Methods.GlowWorm import GlowWorm
q3 = np.percentile(queries[:,-1],75)
np.random.seed(30)
def objective_density(X):
    assert X.shape[1]==3
    res = np.log(xgb1.predict(X) - q3) - 4*np.sum(np.log(1+4*X[:,-1].reshape(1,-1)),axis=0) 
    res[np.isnan(res)] = -np.inf
    return res
gw = GlowWorm(objective_density, dimensions=3, nt=10, iter_max=750, glowworms=150, r0=0.17)
initial = copy.copy(gw.X)
pos = gw.optimize()
w_pos = pos[np.argsort(-objective_density(pos))][:20]
fig = plt.figure(figsize=(10,4))
ax = fig.add_subplot(121)
plt.imshow(ZZ, interpolation='nearest', origin='low', aspect='auto',
        extent=[0, 1, 0, 1])
plt.colorbar()
# ax.add_patch(patches.Rectangle((x_l_a, y_l_a),x_h_a-x_l_a,y_h_a-y_l_a ,fill=False,edgecolor='red',lw=3))
# ax.add_patch(patches.Rectangle((x_l, y_l),x_h-x_l,y_h-y_l ,fill=False,edgecolor='green',lw=3))
for x in w_pos:
    ax.add_patch(patches.Rectangle((x[0]-x[2], x[1]-x[2]),2*x[2], 2*x[2] ,fill=False,edgecolor='b',lw=2))
ax.set_xlabel('X Coordinate',fontsize=22)
ax.set_ylabel('Y Coordinate',fontsize=22)
ax.set_title('Surrogate Model $\hat{f}(\cdot)$', fontsize=22)
ax.tick_params(labelsize=16)

ax = fig.add_subplot(122, title='True Mapping')

plt.imshow(H, interpolation='nearest', origin='low',aspect='auto',
        extent=[0, 1, 0, 1])
plt.colorbar()
for x in w_pos:
    ax.add_patch(patches.Rectangle((x[0]-x[2], x[1]-x[2]),2*x[2], 2*x[2] ,fill=False,edgecolor='b',lw=2))
ax.set_xlabel('X Coordinate',fontsize=22)
ax.set_ylabel('Y Coordinate',fontsize=22)
ax.set_title('True Function ${f}(\cdot)$', fontsize=22)
ax.tick_params(labelsize=16)
# plt.axis('equal')
plt.tight_layout()
# plt.savefig('output/example_crimes.eps',format='eps',dpi=300)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.20719738276990185, 'fraction_numerical': 0.04798255179934569, 'mean_word_length': 7.048245614035087, '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': '187704', 'license': 'MIT', 'n_tokens_mistral': 857, 'n_tokens_neox': 810, 'n_words': 106, 'path': 'Crimes-Qualitative.ipynb', 'repo_name': 'Skeftical/SuRF-Reproducibility', 'size': '1834'}