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
""" | |
Copyright (C) 2015 Baxter Eaves | |
License: Do what the fuck you want to public license (WTFPL) V2 | |
Collapsed Gibbs sampler for Latent Dirichlet Allocation. | |
""" | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import random |
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
""" | |
Copyright (C) 2015 Baxter Eaves | |
License : WTFPL V2 | |
Rejection sampler for the epistemic trust model of Shafto, Eaves, et al (2012) | |
""" | |
import random |
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
""" | |
Copyright (C) 2015 Baxter Eaves | |
License: Do what the fuck you want to public license (WTFPL) V2 | |
Bayesian hierarchical clustering. | |
Heller, K. A., & Ghahramani, Z. (2005). Bayesian Hierarchical Clustering. | |
Neuroscience, 6(section 2), 297–304. doi:10.1145/1102351.1102389 | |
""" | |
import itertools as it |
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
""" | |
Copyright (C) 2016 Baxter Eaves | |
License: Do what the fuck you want to public license (WTFPL) V2 | |
Infinite Gaussian Mixture Model | |
Requires: numpy, scipy, matplotlib, seaborn, pandas | |
""" | |
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
""" | |
Copyright (C) 2015 Baxter Eaves | |
License: Do what the fuck you want to public license (WTFPL) V2 | |
Scrape abstracts from the Proceedings of the National Academy of Sciences. | |
Requires: beutifulsoup4 | |
""" | |
import re |
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
import numpy as np | |
import matplotlib.pyplot as plt | |
def pp_plot(f, p, nbins, ax=None): | |
""" P-P plot of the empirical CDFs of values in two lists, f and p. """ | |
if ax is None: | |
ax = plt.gca() | |
uniqe_vals_f = list(set(f)) |
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 is the first thing I've ever written in Haskell by myself. | |
-- Be gentle. | |
import Data.List (genericLength) | |
type Assignment = [Int] | |
-- |Cluster data into k clusters | |
kmeans :: (Floating a, Ord a) => [[a]] -> Int -> Assignment | |
kmeans xs k = _kmeans xs $ nearestMeans xs (take k xs) |