Skip to content
Snippets Groups Projects
Commit bb3bfe5b authored by rink's avatar rink
Browse files

add option to pass in absolute tolerance

parent b048d747
No related branches found
No related tags found
No related merge requests found
......@@ -18,15 +18,19 @@ def quantile_loss(q):
return tf.reduce_mean(tf.maximum(q * e, (q - 1) * e))
return loss
def true_func(x):
# Y = 2 + 1.5 * X + epsilon # Linear relationship with variance increasing
# Y = 1 + np.exp(X / 4) + epsilon
# Y = 1 + np.exp(X / 4) + np.sin((2*np.pi/5)*X)
return 1 + np.exp(x / 4) + np.sin((2*np.pi/5)*x)
# Generate synthetic dataset
def make_data(num_points=1000):
np.random.seed(42)
X = np.random.rand(num_points, 1) * 10
# epsilon = np.random.normal(0, X/2, size=(num_points, 1)) # Noise increasing with X
epsilon = np.random.normal(0, 0.5 + X/6, size=(num_points, 1))
# Y = 2 + 1.5 * X + epsilon # Linear relationship with variance increasing
# Y = 1 + np.exp(X / 4) + epsilon
Y = 1 + np.exp(X / 4) + np.sin((2*np.pi/5)*X)
Y = true_func(X)
Y_eps = Y + epsilon
# Split into training and test sets
......@@ -122,6 +126,7 @@ def run(num_points=1000, num_plot_pts=200):
plt.plot(X_range, mae_predictions, label="MAE", color='magenta')
plt.plot(X_range, mse_predictions, label="MSE", color='cyan')
plt.plot(X_range, bulk_predictions, label="Bulk Quantile Model (Wimmers)", color='orange')
plt.plot(X_range, true_func(X_range), label="True Function", color='black')
plt.xlabel("X")
plt.ylabel("Y")
plt.legend()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment