Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inquiry about implementation of mean_wQuantileLoss and m_sum_mean_wQuantileLoss #153

Open
hanlaoshi opened this issue Oct 31, 2023 · 0 comments

Comments

@hanlaoshi
Copy link

I am currently working on reproducing the mean_wQuantileLoss and m_sum_mean_wQuantileLoss metrics from a research paper. However, I have encountered significant discrepancies between my results and those obtained from the model.

I would appreciate any assistance in identifying potential errors in my implementation.

Here is a summary of my approach:
def quantile_loss(y_true, y_pred, q):
loss = 2 * np.sum(np.abs((y_pred - y_true) * ((y_true <= y_pred) - q)))
return loss
def quantile_loss(y_true, y_pred, q):
loss = 2 * np.sum(np.abs((y_pred - y_true) * ((y_true <= y_pred) - q)))
return loss
def mean_wQuantileLoss(forecasts, targets, quantiles=(np.arange(20)/20.0)[1:]):
B, T, D = targets.shape
loss = 0.0
for i in range(B):
for d in range(D):
for q in quantiles:
loss += quantile_loss(targets[i, :, d], forecasts[i, :, d], q) / np.sum(np.abs(targets))
return loss / (B * D * len(quantiles))

def m_sum_mean_wQuantileLoss(forecasts, targets, quantiles=(np.arange(20)/20.0)[1:]):#
B, T, D = targets.shape
forecasts = np.sum(forecasts, axis=-1)
targets = np.sum(targets, axis=-1)
total_loss = 0.0
for i in range(B):
loss = 0.0
for q in quantiles:
loss += quantile_loss(targets[i], forecasts[i], q) / np.sum(np.abs(targets))
total_loss += loss / len(quantiles)
return total_loss / B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant