Last active
September 6, 2017 11:33
-
-
Save vegarsti/df4068bd3701b2b397f7c68cbeadad50 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
# defaultdict use case | |
# Finding a Pareto front, where (x1, x2) is a list of tuples satisfying | |
# e.g. (x1, x2) : |df[(df[var1 > x1]) & df[var2 > x2)]| < 0.1|df|, | |
# where |df| is the size of df, i.e., df.shape[0] (in Pandas) | |
pareto = defaultdict(lambda: np.Inf) | |
for x1, x2 in xs: | |
pareto[x1] = min(pareto[x1], x2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment