<jupyter_start><jupyter_text>Data Generation<jupyter_code>n_samples = 1000
x_dom = 20
X = np.zeros((n_samples, 2))
X.T[0] = np.linspace(-x_dom, x_dom, n_samples)
X.T[1] = np.sin(np.linspace(-x_dom, x_dom, n_samples))

E = np.random.random(n_samples) - 0.5

Y = ((X.T[0] + X.T[1] + E) * ((X.T[0] + X.T[1] + E) - x_dom) * ((X.T[0] + X.T[1] + E) + x_dom)).reshape(n_samples, 1)
Y_upper_bound = ((X.T[0] + X.T[1] + 0.5) * ((X.T[0] + X.T[1] + 0.5) - x_dom) * ((X.T[0] + X.T[1] + 0.5) + x_dom)).reshape(n_samples, 1)
Y_lower_bound = ((X.T[0] + X.T[1] - 0.5) * ((X.T[0] + X.T[1] - 0.5) - x_dom) * ((X.T[0] + X.T[1] - 0.5) + x_dom)).reshape(n_samples, 1)
np.save('../data/X', X)
np.save('../data/Y', Y)

np.save('../data/E', E)
np.save('../data/Y_upper_bound', Y_upper_bound)
np.save('../data/Y_lower_bound', Y_lower_bound)
plt.plot(X.T[0], Y)
plt.show()<jupyter_output><empty_output><jupyter_text>Polynomial Regression<jupyter_code>model = PolynomialRegressor(test_degrees=30, eps=0.01, early_stopping=True, patience=3)
model.fit(XYPair(np.linspace(-x_dom, x_dom, n_samples).reshape(n_samples, 1), Y), verbose=1)
model.degree
model.coefs
model.labels
model.func
model.print_func()
plt.plot(X.T[0], Y)
plt.plot(X.T[0], Y_upper_bound, c='b')
plt.plot(X.T[0], Y_lower_bound, c='b')
plt.plot(X.T[0], model.predict(), c='r')
plt.show()
fig = plt.figure(figsize=(6, 6))
ax = fig.add_subplot(1, 1, 1, projection='3d')
ax.plot(X.T[0], X.T[1], Y.flatten())
ax.plot(X.T[0], X.T[1], Y_upper_bound.flatten(), c='b')
ax.plot(X.T[0], X.T[1], Y_lower_bound.flatten(), c='b')
ax.plot(X.T[0], np.zeros(n_samples), model.predict().flatten(), c='r')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.25961538461538464, 'fraction_numerical': 0.042067307692307696, 'mean_word_length': 4.904255319148936, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '184350', 'license': 'MIT', 'n_tokens_mistral': 871, 'n_tokens_neox': 841, 'n_words': 123, 'path': 'src/Test.ipynb', 'repo_name': 'leloykun/data-science-tools', 'size': '1664'}