diff --git a/modules/deeplearning/quantile_regression.py b/modules/deeplearning/quantile_regression.py index e3fc775a3d1a391ee40df2d40888561f44f9b785..c7b2585048c7e0846af2faa41a12e98dc55de80d 100644 --- a/modules/deeplearning/quantile_regression.py +++ b/modules/deeplearning/quantile_regression.py @@ -22,14 +22,14 @@ 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) + 0.5*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)) + epsilon = np.random.normal(0, 0.5 + X/10, size=(num_points, 1)) Y = true_func(X) Y_eps = Y + epsilon @@ -86,7 +86,7 @@ def build_mse_model(): def run(num_points=1000, num_plot_pts=200): # Define quantiles - quantiles = [0.1, 0.5, 0.9] + quantiles = [0.05, 0.5, 0.95] models = {} X_train, X_test, Y_train, Y_test, X, Y = make_data(num_points=num_points) @@ -120,9 +120,9 @@ def run(num_points=1000, num_plot_pts=200): # Plot the results plt.figure(figsize=(8, 6)) plt.scatter(X_test, Y_test, alpha=0.3, label="Test Data") - plt.plot(X_range, predictions[0.1], label="Quantile 0.1", color='red') + plt.plot(X_range, predictions[0.05], label="Quantile 0.05", color='red') plt.plot(X_range, predictions[0.5], label="Quantile 0.5 (Median)", color='green') - plt.plot(X_range, predictions[0.9], label="Quantile 0.9", color='blue') + plt.plot(X_range, predictions[0.95], label="Quantile 0.95", color='blue') 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')