Created
March 30, 2020 18:59
-
-
Save piEsposito/480b82f1116518947bf9392afdba02bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def evaluate_regression(regressor, | |
X, | |
y, | |
samples = 100, | |
std_multiplier = 2): | |
preds = [regressor(X) for i in range(samples)] | |
preds = torch.stack(preds) | |
means = preds.mean(axis=0) | |
stds = preds.std(axis=0) | |
ci_upper = means + (std_multiplier * stds) | |
ci_lower = means - (std_multiplier * stds) | |
ic_acc = (ci_lower <= y) * (ci_upper >= y) | |
ic_acc = ic_acc.float().mean() | |
return ic_acc, (ci_upper >= y).float().mean(), (ci_lower <= y).float().mean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment