This file contains 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
""" | |
Simulated comparison of estimators for L1 calibration error: | |
1. Plugin estimator, i.e. ECE [Guo et al. 2017] | |
2. De-biased estimator [Kumar et al. 2019] | |
In each simulation, we draw y_per_bin, p_per_bin, and fix n_per_bin to a constant. | |
We draw samples y_hat_per_bin and compare MSE of the two estimators as a function of bin size. | |
""" | |
import numpy as np |
This file contains 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
""" | |
We combine Robbins-Monro stochastic gradients of the MAP estimate with | |
an amount of Gaussian noise balanced with the step size. | |
Then it turns out the algorithm produces samples from the posterior as t → ∞. | |
Here we have a prior and data-generating process specified by the following. | |
θ₁ ~ N(0, σ₁²) | |
θ₂ ~ N(0, σ₂²) |
This file contains 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
""" | |
Simulation experiment with a logistic regression model with 2D class-conditional Gaussians. | |
μ₁ = [1, 1] | |
μ₀ = [-1, -0.5] | |
x⁽¹⁾ ~ N(μ₁, I) for y = 1 | |
x⁽⁰⁾ ~ N(μ₀, I) for y = 0 | |
At training time we sample y ~ Bernoulli(0.1) but at test time y ~ Bernoulli(0.5) i.e. label balanced. |
This file contains 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
""" | |
This file contains code to fit a heteroskedastic linear model; i.e. | |
y ~ N(η₁, η₂) η₁ = θ₁ᵀx, η₂ = θ₂ᵀx. | |
Here η represent the natural parameters, | |
η₁ = μ/σ², η₂ = 0.5/σ² > 0. | |
Since this model is in the Exponential Family, it is convex. |
This file contains 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
CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT); | |
CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('select', 'Function', 'docs.html#select-and-drop-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('drop', 'Function', 'docs.html#select-and-drop-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('starts_with', 'Function', 'docs.html#selection-filter-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('ends_with', 'Function', 'docs.html#selection-filter-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('contains', 'Function', 'docs.html#selection-filter-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('everything', 'Function', 'docs.html#selection-filter-functions'); | |
INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('columns_between', 'Function', 'docs.html#selection-filter-functions'); |
This file contains 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 project_onto_l1_ball(x, eps): | |
""" | |
Compute Euclidean projection onto the L1 ball for a batch. | |
min ||x - u||_2 s.t. ||u||_1 <= eps | |
Inspired by the corresponding numpy version by Adrien Gaidon. | |
Parameters | |
---------- |