<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="bgpierc.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="bgpierc.github.io/" rel="alternate" type="text/html" /><updated>2024-04-15T15:07:31+00:00</updated><id>bgpierc.github.io/feed.xml</id><title type="html">Ben Pierce</title><subtitle>PhD Student at CWRU</subtitle><entry><title type="html">Gaussian Mixture Models &amp;amp; Expectation Maximization</title><link href="bgpierc.github.io/GaussMix/" rel="alternate" type="text/html" title="Gaussian Mixture Models &amp;amp; Expectation Maximization" /><published>2022-02-08T00:00:00+00:00</published><updated>2022-02-08T00:00:00+00:00</updated><id>bgpierc.github.io/GaussMix</id><content type="html" xml:base="bgpierc.github.io/GaussMix/"><![CDATA[<p>Recently, I’ve had some spare time to go back through some material from the end of college that I didn’t think I’d quite mastered (thanks covid!). One of these topics is the Gaussian Mixture model and how we can use expectation maximization to implement it.</p>

<h1 id="gaussian-mixture-models-and-em">Gaussian Mixture Models and E&amp;M</h1>
<p>Gaussian mixture models are a class of probabilistic unsupervised learning algorithms. A GMM assumes that the process that generated the data can be described by a finite number of Gaussian distributions with unknown parameters. The learning problem is then to find those parameters. This can be done via maximum likelihood estimation (MLE). The concept of MLE is to maximize some likelihood function so that given an assumed model, the observed data is most probable. From a Bayesian standpoint, MLE is equivalent to maximum a posteriori (MAP) with a uniform prior.</p>

<p>The simplest algorithm to do MLE iteratively is expectation maximization. It consists of two steps the (E)xpectation step and the (M)aximization step. In the E step, the expected value of the log likelihood function is calculated. The M step then chooses parameters to maximize the function calculated in the E step. This process is then repeats until convergence.</p>

<p>More detail on the theory behind these can be found in Bishop’s <em>Pattern Recognition and Machine Learning</em>, the psudocode from which I try to follow as close as I can.</p>

<h1 id="implementation">Implementation</h1>
<p>I tried to keep the implementation as straightforward as possible.</p>

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>

<pre class="prettyprint lang-py">
<code>
def GaussianMixtureModel(X, k = 2, max_iters = 10000, eps = 1e-3):
    # I followed the psudocode on Bishop p 438-439 as close as I could
    # select initial means randomly
    means = X[np.random.randint(0,len(X),k)] 
    # initiate responsibilities
    respons = np.zeros((X.shape[0], k))
    # initiate mixing coeffs pi_k
    mix = np.ones(k)
    # hardest part: getting correct shape here
    # I used the shape returned by sklearn.mixture._estimate_gaussian_covariances_full
    # which does an initial M step for the cov as well, but I didn't
    covs = np.full((k, X.shape[1], X.shape[1]),
                   np.cov(X.T))

    log_likelihoods = [0]
    for i in range(max_iters):  
        # E step
        llh , respons = E(X, k, mix, means, covs, respons)
        # M step
        mix, means, covs, respons = M(X,k, mix, means, covs, respons)
        # stop when the likelihood doesnt change with error eps
        if np.abs(llh - log_likelihoods[-1]) &lt;= eps:
            return means, respons, mix, covs, log_likelihoods
        # note down log likelihoods for learning curve
        log_likelihoods.append(llh)

    print("Max Iterations Exceeded")
    return means, respons, mix, covs, log_likelihoods
    
def log_likelihood(respons):
    ret = 0
    for i in range(len(respons)):
        ret += np.log(np.sum(respons[i]))
    return ret

def E(X, K, mix, means, covs, respons):
    # calc the llh and re-evaulte the responsibilities
    for k in range(K):
        # Bishop 9.23
        # easier to split up fraction and normalize later
        respons[:, k] = mix[k] * multivariate_normal(means[k], covs[k]).pdf(X)
    llh = log_likelihood(respons)
    respons /= respons.sum(axis = 1, keepdims = True)
    return llh, respons

def M(X, K, mix, means, covs, respons):
    # re-estimate params using current responsibilities
    # define N_k as rowwise sum of responsibilities
    # Bishop 9.27
    N_k = respons.sum(axis = 0)
    # Bishop 9.24
    means = respons.T@X / N_k # recalc means
    for k in range(K): # recalc variances
        # Bishop 9.25
        covs[k] = (respons[:, k] * (X - means[k]).T@(X - means[k])) / N_k[k]
    mix = N_k/len(respons) # Bishop 9.26
    return mix, means, covs, respons
</code>
</pre>

<p>Now let’s test our code on some generated data.</p>

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>

<pre class="prettyprint lang-py">
<code>
mu_x = np.array([5,10])
mu_z = np.array([6,11])

sig_x = np.zeros(2)+ 0.01
sig_z = np.zeros(2)+ 0.05

X = multivariate_normal.rvs(mu_x, sig_x, size = 100)
Z = multivariate_normal.rvs(mu_z, sig_z, size = 100)

plt.scatter(*X.T)
plt.scatter(*Z.T)
</code>
</pre>
<p><img src="../images/plot-dist.png" width="500" /></p>

<p>We’ve generated two different clusters, each with a different underlying distribution. Let’s try to run our model and see if it can correctly find the parameters of the distributions. 
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></p>
<pre class="prettyprint lang-py">
<code>
dat = np.vstack((X,Z))
means, respons, weights, covs, log_likelihoods = GaussianMixtureModel(dat)
print(means)
print(covs)
</code>
</pre>

<p>[[ 4.99037355  9.99691058]</p>

<p>[ 6.03674847 11.03166029]]</p>

<p><br /><br />
[[[ 0.01063869 -0.00127132]</p>

<p>[-0.00127132  0.0099645 ]]</p>

<p>[[ 0.05877937  0.00100672]</p>

<p>[ 0.00100672  0.05401486]]]</p>

<p>We appear to be quite close. Let’s visualize the 1,2,3 sigma contours.
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></p>
<pre class="prettyprint lang-py">
<code>
def plt_contours(X, preds, means, covs,
                 minx = -500, maxx = 800,
                 miny = -500, maxy =  5000):
    t = np.linspace(minx, maxx, 100)
    h = np.linspace(miny, maxy, 100)

    w_0, w_1 = np.meshgrid(t,h)
    z = multivariate_normal(means[0],covs[0]).pdf(np.dstack((w_0, w_1)))
    plt.contour(t, h, z, levels = 3)
    z = multivariate_normal(means[1],covs[1]).pdf(np.dstack((w_0, w_1)))
    plt.contour(t, h, z, levels = 3)
    plt.scatter(*X.T, c = preds)
    plt.show()

preds = np.argmax(respons, axis = 1)
plt_contours(dat, preds, means, covs,
                 minx = 4, maxx = 7,
                 miny = 9, maxy =  12)
                 </code>
</pre>
<p><img src="../images/contours.png" width="500" /></p>

<p>As you can see, the contour bands are about where we could expect, as we know the variance in the purple cluster is quite small compared to the yellow cluster. I’d call this a success!</p>

<p>I’m sure the code could be made a bit faster, but sklearn’s implementation exists for production, so I opted for clarity. Anyway, thanks for reading and hopefully this toy implementation/example was useful.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[Recently, I’ve had some spare time to go back through some material from the end of college that I didn’t think I’d quite mastered (thanks covid!). One of these topics is the Gaussian Mixture model and how we can use expectation maximization to implement it.]]></summary></entry><entry><title type="html">Latest Paper Published</title><link href="bgpierc.github.io/paper/" rel="alternate" type="text/html" title="Latest Paper Published" /><published>2022-02-07T00:00:00+00:00</published><updated>2022-02-07T00:00:00+00:00</updated><id>bgpierc.github.io/paper</id><content type="html" xml:base="bgpierc.github.io/paper/"><![CDATA[<p>My latest paper has been published in <a href="https://ieeexplore.ieee.org/abstract/document/9623380">IEEE JPV</a>!</p>

<h1 id="abstract">Abstract</h1>
<p>This article presents a notable advance toward the development of a new method of increasing the single-axis tracking photovoltaic (PV) system power output by improving the determination and near-term prediction of the optimum module tilt angle. The tilt angle of the plane receiving the greatest total irradiance changes with Sun position and atmospheric conditions including cloud formation and movement, aerosols, and particulate loading, as well as varying albedo within a module’s field of view. In this article, we present a multi-input convolutional neural network that can create a profile of plane-of-array irradiance versus surface tilt angle over a full 180 ∘ arc from horizon to horizon. As input, the neural network uses the calculated solar position and clear-sky irradiance values, along with sky images. The target irradiance values are provided by the multiplanar irradiance sensor (MPIS). In order to account for varying irradiance conditions, the MPIS signal is normalized by the theoretical clear-sky global horizontal irradiance. Using this information, the neural network outputs an N -dimensional vector, where N is the number of points to approximate the MPIS curve via Fourier resampling. The output vector of the model is smoothed with a Gaussian kernel to account for error in the downsamping and subsequent upsampling steps, as well as to smooth the unconstrained output of the model. These profiles may be used to perform near-term prediction of angular irradiance, which can then inform the movement of a PV tracker.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[My latest paper has been published in IEEE JPV!]]></summary></entry><entry><title type="html">Active Learning via Ensembles</title><link href="bgpierc.github.io/active-learning/" rel="alternate" type="text/html" title="Active Learning via Ensembles" /><published>2020-12-11T00:00:00+00:00</published><updated>2020-12-11T00:00:00+00:00</updated><id>bgpierc.github.io/active-learning</id><content type="html" xml:base="bgpierc.github.io/active-learning/"><![CDATA[<p>This post is a paraphrased version of a report I submitted for a machine learning course. I found the topic to be quite interesting, so I’m reposting it here.</p>

<p>The field of active learning has many different approaches. This section focuses on the Query-by-Committee (QbC) framework, which uses ensembling methods to find the best sample to query the oracle for a label. There are generally two parts to this approach. The first part is to construct and train a model ensemble. Two methods are implemented in this work: bagging and boosting. Bagging has the advantage of simplicity, but boosting often gives a larger performance increase. The second part is finding the most optimal example to query the oracle. This is done by finding the maximum “disagreement” of the classifiers, which is done via a variety of methods, including entropy and KL divergence. Overall, the QbC method allows comparable or greater accuracy to a classifier trained on the whole dataset, but with a vastly reduced number of required samples. This work proposes a new QbC framework called jackAL based on the jackknife; this method offers an advantage over the others because it allows the model to maximize small quantities of data, which is often the case when active learning is required. A variation on the jackknife, jackknife-k is explored as well. 
<!--end_excerpt--></p>

<h1 id="bagging-and-boosting">Bagging and Boosting</h1>

<p>The first two algorithms implemented in this work come from Abe and Mamitsuka, 1998 [5], and also show up in Milidiú et al, 2012 [6] for natural language processing tasks and Körner et al [7] for the multiclass case. First, we give an overview of the paper; then, we detail our implementation of the QBag and QBoost algorithms. The paper begins by discussing the general concept of QbC. The theory behind QbC is that an ensemble of an ideal randomized learning algorithm will choose a query point to maximize the information. However, this assumes that the base learner is the Gibbs learner, which is intractable. Therefore, this paper presents two committee construction methods, Query-by-Bagging (QBag) and Query-by-Boosting (QBoost) instead.</p>

<p>The paper then discusses the pros and cons of using QBag and QBoost. Namely, QBag is simpler, and can isolate and minimize the variance in the data (but not the bias). QBag does this by subsampling from an identical distribution, meaning that it can minimize the small statistical variation in the data over many iterations. With QBoost, on the other hand, the sampling distribution itself can change as well, depending on the ensemble. Both algorithms follow a similar structure. This is summarized in Algorithm 1, which is a paraphrase of the generalized QbC algorithm provided in the paper.</p>

<p>The model predicts new examples via simple majority vote. The paper proceeds to test and compare the methods on a variety of datasets, and finds QBoost to be the better algorithm. We implemented both QBag and QBoost, and found both to be fairly straightforward modifications of Algorithm 1. Note that the original authors chose to use decision trees (C4.5) as the base algorithm, whereas this work uses multinomial naive Bayes; this choice was made for consistency across the other sections of this report. C4.5 could easily be dropped in, as the sklearn framework is very modular. Additionally, QBag and QBoost use a majority vote/average approach for disagreement, whereas we use the entropy approach discussed above.</p>

<p>Other differences from the original implementation was that we chose not to use cross validation; due to both performance requirements and again consistency across the report. The authors also tried a variety of test subsets (as joint and disjoint sets from the query and training data) in order to better simulate a true active learning scenario, as in this case, all labels are known a priori, so the accuracy evaluated at each step across the test or the test + training data would actually be unknown. For simplicity, we evaluate the algorithms using the whole dataset; this makes sense because we wish to see how quickly each converges to the expected value, which is a model trained on the whole dataset initially. The authors also conclude that the time complexity of a QbC model is O(NTR * F(N)), where F is the learning algorithm, N the input size, T the number of times the resampling is done, and R is the number of query candidates. This is noted by the Abe and Mamitsuka to be significant but not intractable. They additionally note that QBag is trivially parallel, although QBoost is not.</p>

<h1 id="active-decorate">ACTIVE-DECORATE</h1>

<p>QBag and QBoost have the advantage of simplicity, but they are certainly not the only 
ensembling methods. The third algorithm implemented in this work, DECORATE is from Melville and Mooney 2004 [18], and is adapted into a QbC method called ACTIVE-DECORATE in Melville and Mooney 2005 [19]. The authors of this paper seek to create an ensemble that is specifically very diverse. However, this is not done with resampling, like QBag and QBoost; instead, the authors propose inserting artificially generated data into the training corpus in hopes that this will cause further variation among the models in the ensemble.</p>

<p>The algorithm begins by training a base classifier on the whole training set. Then, for i iterations, artificial training data is generated, based on the distributions of the training set. The authors suggest the size of the artificial set to be between 50%-100% of the training set. Then, a model is trained on the union of the training and artificial sets, and added to the ensemble. If the ensemble gives a better overall accuracy on the training set, then the model is accepted into the ensemble, else, it is rejected. This process continues for a set number of iterations or until the desired number of models has been obtained.  New examples are classified by taking the average of the predicted probabilities of each model, and taking the maximum, as in Equation 1.</p>

<p>In their further work, the authors expanded the DECORATE algorithm to become an active learning method. The authors argue that ACTIVE-DECORATE will work better because DECORATE purposefully generates diverse ensembles, therefore, there will be more diversity in their predictions, which allows the votes of the ensemble to be less homogeneous. This increase in disagreement allows the active learner to get a better understanding of what the current training corpus lacks, thereby choosing better examples earlier then a resampling method like QBag or QBoost. Although the authors do not give an example for why, we posit that an explanation for this is that when the sample size is small, a the very beginning, QBag and QBoost both have a tendency to select redundant examples, and if the classes drawn by the subset are unbalanced, this can cause failure. For example, if the current training corpus is of length 5, and 4 of the 5 are positive, and the possible query options are all of the omitted class, then the model will have a tough time making a decision.</p>

<p>As with QBag and QBoost, the authors of ACTIVE-DECORATE suggest a decision tree algorithm be used as a base learner, whereas we again implemented multinomial naive Bayes. An interesting claim to note is that since naive Bayes is seen as a “stable” learning algorithm, it supposably does not minimize the variance due to statistical noise as well as unstable learners. This may factor into the performance of our ACTIVE-DECORATE . The authors also claim that DECORATE is on par with AdaBoost; we do not find this to be universally true, but also do not do a rigorous comparison between the two, as we focus on the active learning variant instead. The authors also explicitly note that boosting can fail with small sample size; this can be seen in our implementation as well in the Results section.</p>

<p>The authors offer two hypotheses for why their ACTIVE-DECORATE method is optimal. The first is that ACTIVE-DECORATE explicitly fosters diversity, and the authors believe this to be the critical component. We do not take so strong a stance, as evidenced by our novel extension, jackAL; the learners in a jackAL ensemble are all fairly similar. However, ACTIVE-DECORATE does boast the advantage of using the entire training set at each time, as it relies on generating random training examples. The authors also posit that DECORATE  will out-perform bagging, AdaBoost, and random forests on small datasets; although this may be true for the pure algorithm, we do not find this to always be the case for the active learning variants. Melville and Mooney ran a very similar test suite to the one used for QBag and QBoost as well. Additionally, they use a different disagreement metric, JS-divergence, which is a measure of similarity between probability distributions as well as the majority vote metric from Abe and Mamitsuka. They find that JS-divergence chooses examples to strength the model’s certainty, but the majority vote method maximizes the margin (the entropy minimization procedure we use reduces to this method in the binary classification case [1]).</p>

<h1 id="novel-extension-jackal--active-learning-with-the-jackknife">Novel Extension: JackAL- active learning with the jackknife</h1>
<p>As mentioned at the beginning, the jackknife is an early resampling method that involves taking leave-one-out samples of the training data. We can then build ensembles from these subsets. There are a few things to note about this process. Obviously, using the jackknife will result in a very large ensemble (size of n-1), which requires training many models. Thus, this procedure is very computationally expensive, and gets more so as the size of the dataset increases. In return, the jackknife’s many classifiers will reduce the impact of the statistical noise in the data quite a bit, as the effect of each and every point is considered. Additionally, the large number of subsets offered by the jackknife causes it to be suitable for when the size of the sample is small, such as in the early stages of the active learning problem. However, as the size of the sample increases, the jackknife becomes less and less feasible and useful, as the removed example has less and less of an effect. A modification of the jackknife, jackknife-k, is discussed in Wu 1986 [8], which simply deletes k elements of the set, rather than 1. Note that this method is analogous to bagging with many bags, which we know to be functional. However, in QBag, the number of bags is held to be constant. Jackknife-k provides us with an opportunity to vary k as a function of the size of the training subset. This allows us to reap the benefits of leaving one sample out when the sample size is very small, but increasing the size to have more of an effect on the ensemble when the number of samples is larger. Thus, we propose a new algorithm: jackAL (jackknife Active Learning), that implements jackknife-k where k obeys some schedule.</p>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>Algorithm 2: jackAL
Input: X, the training data
    k, the number of elements to delete or
    schedule, a function of |X| that returns a value for k
    n, the number of samples allowed to be queried

let the training corpus be a set containing one example
for i &lt; n; i++
    run jackknife-k(X,k,schedule) on the current corpus
    calculate the disagreement of the ensemble
    query the best point to add to the corpus via disagreement
return the current models
</code></pre></div></div>

<p>Prediction is done the same was as for ACTIVE-DECORATE. 
The choice of the schedule is still under testing. However, we hypothesize that monotonically  positive functions that “level out” at around 10-20% of the size of the dataset would behave optimally, as a large k  in the smaller cases could create poor ensembles, and a too small k when the dataset is small will likely have little effect other then smoothing statistical noise, the distribution of which we are overly interested in. As of now, the log10 function is chosen as the default behaviour. Note that this procedure is could be reframed as a modified QBag function, where the number of bags is variable as a function of the input size. We choose to stick with a jackknife implementation because we find that a small value of k is more optimal in the early regime of active learning with few samples, and this procedure is more analogous to the jackknife-1 then a bagging procedure with many bags. 
Additionally, the choice of Gaussian Naive Bayes (GNB) as the learner for continuous functions has not be robustly tested. As GNB tends to return probabilities very close to 0 or 1, it perhaps is not the optimal choice for a model like jackAL or ACTIVE-DECORATE. A better choice might be logistic regression, as it returns more “smoothly” distributed probabilities. As an aside, the predict_proba function from sklearn, which was used to obtain the probabilities, is known to be rather unreliable for models like GNB as well. 
We feel that jackAL works because it a) effectively minimizes statistical noise and b) chooses the right query points in the case where little data is available. Statistical noise is minimized because of the leave-k-out properties of jackknife-k; this enables models to reduce this pesky noise rapidly. Note that this hypothesis conflicts with the belief of the authors of ACTIVE-DECORATE; since the individual |n-k| subsamples will all be quite similar, there will not necessarily be much diversity between the individual models. We hypothesize that this differing approach causes jackAL to be more stable then ACTIVE-DECORATE, in the sense that the overall accuracy does not “bounce” around during training, which can be seen in the results section. However, ACTIVE-DECORATE may cause higher “spikes” of intermittent accuracy as well, in contrast to the slow-but-steady jackAL. We also posit that jackAL is a good choice because it chooses well with a small dataset. This makes sense; as jackAL constructs many models, it may be able to “squeeze” each drop of information out of a very small dataset. We additionally believe that this behavior of promoting a strong-start is very beneficial; this is analogous to the model picking up some form of momentum, although we have no way to empirically prove this or the earlier hypothesis. Nevertheless, we do find jackAL to be a competitive active learning method.</p>

<h1 id="implementation-details">Implementation Details</h1>

<p>In summary, the implemented methods from the literature for this study are QBag, QBoost, DECORATE, and ACTIVE-DECORATE. Additionally, the novel extension jackAL was implemented as well, in the original jackknife, jackknife-k, and scheduled jackknife-k forms. All code is written in Python 3.7. The model chosen to test the ensembles is Naive Bayes, using a multinomial distribution for categorical values and a Gaussian distribution for continuous values. The particular implementation used is from the scikit-learn library; our pure Python implementation proved to be too slow, especially in the case of ensembling, when the model must be retrained many times. The entropy function from scipy was additionally used for the disagreement metric. The NumPy library was used extensively to speedup computation times. 
Additionally, an optimization was made that applied to all algorithms: instead of looping through the entire query set, a smaller subset was sampled with replacement according to a uniform distribution. This optimization was suggested by Abe and Mamitsuka and implemented across the board for comparison’s sake.The size of this sample set is a parameter on all functions. This optimization is a significant speedup, and appears to have minimal impact on the performance. This may be dependent on the data, as it inherently assumes that the optimal query examples are mostly non-unique; that is, the samples form clusters of optimal examples, and we seek to select an arbitrary sample from that cluster. This concept is further explored in the Density Weighted Learning section in this report. 
All other code written for this work is the sole work of the authors; no additional references other than the original papers were used outside of the previously mentioned. In the future, all methods would experience a massive speedup with the introduction of parallelism. The problem is trivially parallel in some places, such as when training the n-k models when using jackAL. Additionally, the code could be further optimized in a few places. The experimentation and code to generate figures for this report can be found in a Jupyter notebook, and the particular functions are all separated in a .py file.</p>

<h1 id="results">Results</h1>

<p>The results of this experiment were quite promising. All methods of active learning performed surprisingly well. Such a large speedup was not anticipated before the start of this project. The results are delineated in Figure 1. 
All models appear to achieve similar training accuracy to a naive Bayes model trained on the whole dataset with vastly fewer required examples. Amongst the models, QBag and jackAL appear to be the most competitive, in contrast to the findings of the original authors of QBoost, who claimed that it was better then QBag. In fact, QBoost appeared to diverge rather then converge. This strange behaviour is due to the introduction of too much randomness; if the size of the query set (resampled at every iteration) is doubled from the 50 to 100, QBoost performs comparably to QBag. This example is left in to illustrate the importance of hyperparameter tuning. The jackAL method posited in this study appears to be quite good, and appears to be very consistent after around 10 examples seen on the Volcanoes dataset, which is a discrete dataset. 
The second dataset tested is the breast cancer dataset included in sklearn, which is a continuous, binary classification dataset with 569 samples. Notably, QBoost appears to oscillate quite a bit, as opposed to algorithms like QBag or jackAL. All active learning models are a vast improvement over random selection, as random selection only obtains ~50% accuracy by the time the other models converged. The voting dataset was also tested, but since random selection causes the model to converge within ~5 samples, it was deemed too easy for comparison purposes.</p>

<p><img src="../images/volcanoes.png" width="350" />                           <img src="../images/bc.png" width="350" /></p>

<h1 id="conclusions">Conclusions</h1>

<p>In conclusion, QbC appears to be a competitive, albeit computationally expensive, method. We foresee this type of learning being useful when obtaining more examples is expensive or time consuming; in the future, we hope to apply this method to degradation of photovoltaic modules that undergo artificial weathering. As the artificial weathering process is long and costly, it would be useful to know what kind of samples would be useful when putting the next batch into simulated exposure. All methods of QbC reviewed in the literature, including QBag, QBoost, and ACTIVE-DECORATE were shown to be effective on our test datasets, and the proposed novel extension, jackAL, performed as well or better then the known algorithms. Future work could include exploring different scheduling functions for jackAL and different disagreement functions then entropy.</p>

<h1 id="references">References</h1>

<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>[5]    N. Abe and H. Mamitsuka, “Query Learning Strategies Using Boosting and Bagging.,” Madison, Wisconsin, USA, Jan. 1998, vol. 15, pp. 1–9. Accessed: Dec. 01, 2020. [Online]. 

[6]    R. L. Milidiú, D. Schwabe, and E. Motta, “Active Learning with Bagging for NLP Tasks,” in Advances in Computer Science, Engineering &amp; Applications, Berlin, Heidelberg, 2012, pp. 141–147, doi: 10.1007/978-3-642-30111-7_14.

[7]    C. Körner and S. Wrobel, “Multi-class Ensemble-Based Active Learning,” in Machine Learning: ECML 2006, Berlin, Heidelberg, 2006, pp. 687–694, doi: 10.1007/11871842_68.

[8]    C. F. J. Wu, “Jackknife, Bootstrap and Other Resampling Methods in Regression Analysis,” Ann. Statist., vol. 14, no. 4, pp. 1261–1295, Dec. 1986, doi: 10.1214/aos/1176350142.

[9]    D. Lewis and W. Gale. A sequential algorithm for training text classifiers. In Proceedings of the ACM SIGIR Conference on Research and Development in Information Retrieval, pages 3–12. ACM/Springer, 1994.

[10]   D. Lewis and J. Catlett. Heterogeneous uncertainty sampling for supervised learning. In Proceedings of the International Conference on Machine Learning (ICML), pages 148–156. Morgan Kaufmann, 1994.
</code></pre></div></div>]]></content><author><name></name></author><summary type="html"><![CDATA[This post is a paraphrased version of a report I submitted for a machine learning course. I found the topic to be quite interesting, so I’m reposting it here. The field of active learning has many different approaches. This section focuses on the Query-by-Committee (QbC) framework, which uses ensembling methods to find the best sample to query the oracle for a label. There are generally two parts to this approach. The first part is to construct and train a model ensemble. Two methods are implemented in this work: bagging and boosting. Bagging has the advantage of simplicity, but boosting often gives a larger performance increase. The second part is finding the most optimal example to query the oracle. This is done by finding the maximum “disagreement” of the classifiers, which is done via a variety of methods, including entropy and KL divergence. Overall, the QbC method allows comparable or greater accuracy to a classifier trained on the whole dataset, but with a vastly reduced number of required samples. This work proposes a new QbC framework called jackAL based on the jackknife; this method offers an advantage over the others because it allows the model to maximize small quantities of data, which is often the case when active learning is required. A variation on the jackknife, jackknife-k is explored as well.]]></summary></entry><entry><title type="html">Finite State Automata</title><link href="bgpierc.github.io/finite-state-automata/" rel="alternate" type="text/html" title="Finite State Automata" /><published>2020-04-01T00:00:00+00:00</published><updated>2020-04-01T00:00:00+00:00</updated><id>bgpierc.github.io/finite-state-automata</id><content type="html" xml:base="bgpierc.github.io/finite-state-automata/"><![CDATA[<p>I’ve come across finite state automata (also known as finite state machines) in multiple different contexts. After all, regular languages are context-free (this joke will not be funny until later).  One of the more interesting aspects of computer science is how different topics pop up across different areas that appear to be totally unconnected.</p>

<h1 id="fsa-in-circuit-design">FSA in Circuit Design</h1>
<p>The first time I encountered finite state machines was in a logic and design class. In this context, state machines arose naturally as a model for a simple computation. Here’s a quick example:</p>

<p>Problem: Design a 3-bit binary counter with counting sequence 0,1,2,3,4,5,0,1,… 
This seems a simple enough problem. Here’s my sloppily-scrawled solution:</p>

<p><img src="../images/fsm1.png" width="500" /></p>

<p>If the clock ticks 1, increment the counter. Once 5 has been reached, wrap back around. In this context, a FSM has been used to informally describe the structure of some circuit, but it only appears to matter for human context. Indeed, the implementation of the FSM in hardware was more based on a truth table and Karnaugh map simplification then the structure of the FSM.</p>

<p><img src="../images/circuit.png" width="400" /></p>

<p>Thus, in this case, FSM were a useful tool to describe the overall structure of a problem, but leaves implementation details to a formalized method. The second place I encountered FSM is a similar story.</p>

<h1 id="tcp-specifications">TCP Specifications</h1>
<p>For my networks class, I had to understand (and write!) an implemention of the Transmission Control Protocol (TCP). TCP is used for pretty much every Web transaction where reliability is important, and is implemented at the operating system level via Unix sockets. The specification for TCP is laid out in the <a href="https://tools.ietf.org/html/rfc793">RFC</a>. Although the RFC never mentions FSM directly, it does lay out a sequence of states and state transitions for TCP, beginning on page 20. TCP can therefore be implemented as a state machine. TCP is based on the principle of reliable data transfer, which attempts to adjust for network errors such as flipped bits or dropped packets (this is what differentiates TCP from a fire-and-forget protocol like UDP). When designing a rdt protocol like TCP, it becomes useful to draw a FSM for both the send and receive side, as show below.</p>

<p><img src="../images/rdt.png" width="400" /></p>

<p>Unlike my experience with circuity, the high level of detail provided by the FSM is already quite useful; clearly, we can just place the conditions on this diagram into a series of if-statements and let the machine loop. This use case hints at how a informal model can be used to describe the structure of a program.</p>

<h1 id="automata-theory">Automata Theory</h1>
<p>The next place I encountered finite state machines was in a class on theoretical computer science. Naturally, the first thing that must be done is construct a theoretical computer. A finite state automata is one of the simplest models we can use (in contrast to pushdown automata and Turing machines). To give a formal definition:</p>

<p>A finite state automata M is a 5-tuple (Q, ∑, δ q, F) where</p>
<ol>
  <li>Q is a finite set of states</li>
  <li>∑ is a finite set called the alphabet</li>
  <li>δ is a transition function</li>
  <li>q is the initial state</li>
  <li>F is the set of accept states.</li>
</ol>

<p>Informally, a finite state automata is a set of states and a transition function, that work on some “alphabet”. Let’s make this more real.</p>

<figure>
  <img src="../images/fsa_machine.png" width="400" />
 <figcaption>
    Source: <a href="https://arxiv.org/abs/1212.6933">arXiv</a>
 </figcaption>
</figure>

<p>Imagine we have returned to the Stone Age of computing, and all we have on hand is a infinite tape for input, a “head” processing unit that can read from the tape, and a machine that threads the tape past the head. Additionally, the machine has a patient “operator” that knows what to do for every character that the head reads in from the tape. This theoretical machine is (surprisingly?) a very useful model for computation!</p>

<h1 id="regular-languages">Regular Languages</h1>
<p>As it turns out, the type of problems that a FSA can solve are known as regular problems. Generally, problems are called languages, where the elements of the language are solutions to the problem. This is a useful construct throughout computability and complexity theory. Now let’s use this theory for something, that something being everyone’s favorite problem-solving method of “dude, just use a regex”. Regex, short for Regular Expression, is a much-feared method of string matching, on account of it’s somewhat difficult syntax. However, a landmark result in language theory is that regular expressions are actually equivalent to finite state automata! That is, a regex exists if and only if you can construct a FSA that can compute it. The proof is quite interesting, but it’s much simpler to use nondeterminism (magic!), which will hopefully be discussed in a future post. Let’s give a concrete example.</p>
<figure>
  <img src="../images/hwfsa.png" width="600" />
 <figcaption>
    from my homework
 </figcaption>
</figure>

<p>Although regex syntax can be frightening, this simplified version has only two symbols, * and implied concatenation. The * symbol simply means “any number of,” and the concatenation is just “these must be next to each other on the tape”.</p>

<p>So how does our idea of a FSA help us in figuring out a regex? A common technique in FSA-programming is to imagine yourself as as the all-knowing “operator” that makes decisions based on what he or she reads from the tape, one at a time. This is very helpful when considering more complex regex that may be less trivial to write out in a few lines of English.</p>

<h1 id="bonus-section-context-free-languages">Bonus Section: Context Free Languages</h1>
<p>In order to justify my joke at the beginning (“After all, regular languages are context-free”), I’ve got to explain it. Essentially, imagine your FSA and add another tape; this time, we’ve made some technological progress, and can now write to this tape. This tape is a stack, meaning that it’s a first-in-first-out queue. Other then that, it’s the same thing as the FSA. We call the languages decided by these machines context-free, and the machines themselves pushdown automata (after the stack). Clearly, our new machine is more “powerful” then our FSA, and can do anything the FSA can do (and more!) Thus, all regular languages are also context free! I’ll save the implications of this for a later post, but now you can at least pretend to laugh.</p>

<h1 id="wrapup">Wrapup</h1>
<p>In summary, FSA are pretty neat, and pop up in all sorts of cool places. Honestly, each of the topics covered today deserve a post all on their own. The purpose of this post was to document my “hey, I’ve seen that before” feeling, and hopefully connect a few neurons in my own head, as I’ve found relating seemingly-disparate topics is quite good for digging deeper into it. Next up is probably nondeterminism, which is probably my favorite computer science “hand wave” and also my favorite justification for forgetting to show my work.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[I’ve come across finite state automata (also known as finite state machines) in multiple different contexts. After all, regular languages are context-free (this joke will not be funny until later). One of the more interesting aspects of computer science is how different topics pop up across different areas that appear to be totally unconnected.]]></summary></entry><entry><title type="html">Recent Poster presentations</title><link href="bgpierc.github.io/posters/" rel="alternate" type="text/html" title="Recent Poster presentations" /><published>2019-10-08T00:00:00+00:00</published><updated>2019-10-08T00:00:00+00:00</updated><id>bgpierc.github.io/posters</id><content type="html" xml:base="bgpierc.github.io/posters/"><![CDATA[<p>These posters are what I’ve been working on recently.</p>

<p><img src="../images/1907Pierce_Intersections.png" width="3500" /></p>

<p><img src="../images/1907TohokuSymposioum(1).png" width="3500" /></p>]]></content><author><name></name></author><summary type="html"><![CDATA[These posters are what I’ve been working on recently.]]></summary></entry><entry><title type="html">Photos from Cape Town, South Africa</title><link href="bgpierc.github.io/cape-town/" rel="alternate" type="text/html" title="Photos from Cape Town, South Africa" /><published>2019-06-28T00:00:00+00:00</published><updated>2019-06-28T00:00:00+00:00</updated><id>bgpierc.github.io/cape-town</id><content type="html" xml:base="bgpierc.github.io/cape-town/"><![CDATA[<p>A little over a year ago, I studied abroad in Cape Town, South Africa. I thought some of the photos I took
were pretty groovy, so I’m embedding them here as well.</p>

<script src="https://cdn.jsdelivr.net/npm/publicalbum@latest/dist/pa-embed-player.min.js" async=""></script>

<div class="pa-embed-player" style="width:100%; height:480px; display:none;" data-link="https://photos.app.goo.gl/sXRYWBPz6gNMKdKY6" data-title="ENGR 225B Cape Town" data-description="90 new photos · Album by Ben Pierce">
  <img data-src="https://lh3.googleusercontent.com/hmGwI8WtV1VgX2AQssh7TWM09YeIJU9tfH39GNhRCMuBwINelVCfXk1S1O1W9jHJwgyijoi-BLT_RA53FWtAHs34kZ4Vp62gsWVN_zQVcrzNg3B5mgrqu1nMgvnbO18pv3v50EksRw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Xfp2m8X6uljx3KvsB9wmOyGHK7XE8jFuPGYTGjW6d9rtBl2FwZiebf6FIqL4b5daPPNeOASh_TUoixUYidKcKsI0QK9YSgyTwYpghXy50p-6FUuM3yAdVXLuWkrZYRExs1EPAs-kGA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/YK0YPVzqDbiT4zNCwHhzhtaSZFWOJM0U8op4eTbWICa4F2Y2B32lkWzntdPVyB5A1-tz-zHE_SYNaX7cb77GUv9-bgkL_nqnFqsjsWF2twNP7ZB5SLRESghlTo8z4UapUbfLrpqCog=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/bBGQd3DN1UDBlfMzJAeyMxYAW5savzxqpisaEE-bCR9ozunT1my10SVhPcLp4Ew8B3bBNvCDXhruWvs8Oqz902yuV-MHaGN7bWGqh11ypUO_MPaA5lPbduk29btCeqe2U6e94eK46A=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/RxtIjEcBT-B4N8IBH1hDzGsYJFJG1TiVPjqWU9A5AC_yCYhid8OEejijQOJbYmH3RX6Dr6YmZ_7QOeNI64bo-SdhCWbBtzCWwz7lwM3Lm8E8O2Kvzu4vDfY3Bfczdx3kntLf1uuE0Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/_mg2_K-RBjYyLMLNW2ndwHNIT0ua_ChifKMi8wsXu2t7u2sn-JiMHjLe0HVQu01aEymk3Kq2wSYgaqm_pRgKBsJfkzIUjp54oNRssyYevkdaYndtiKI_N_eoLzCwlrAo3JLVg6GARA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/ZW6zsSeb7mHqqKeLe5cE8XHrVuOUBUdBFMYTZa7cAq3u5uzJrIamjbirkODFjoF8u9ugWVlrZZd0NPITrKtK1RRUCDzu2iYYdoK8JAfGuDBWJSpXeZsXp6vwDrfSSG1Nvj2vmm-T1A=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/NA-728kbuLcjvazOxQjYDF1gHZkDO6jkCxIcoCHOl6TwUhEwv4MXIpSKju1OUEWoZ9Ge2O7agXH8IGp7yAO_2HbMvkxo0dI9pZ2Q4OgOEk7-PuveGZQjpsGnz63WKkaH_CWMsGqtWg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/MZmnBvPc7feDf0ARY3Mm-lwBaA8wPu68LcFaBDbChh_KLxHA9RevliUkmgR8DuH4x0IavLZZj32l21RNS-S8hgapaqu2oMgUmPFbozJlZYotENIYRAklpsaDonSvHRV9mFInngS5cQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Yg0oU720cZnT5glOucH9RBtsDN6DnWD5t4gfB6ZhQd_FBhM4llheERN4TGsopcubzg7QaRzokU1GmEtUoz7koimZLx1-kqb4eO9jo9l_Q6dyK6zb9BNYbDJTGeS0_BkG9QNvoK9ZJA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/AOmmI3JCvpU5e9DvQToj8A5lqOtBdR_kcBJniGeDGSyW1yX_t-WnHo8EhdYMUEsY_SS_SMw8lfkvshwW3pB6XFEbeSex_84M_l_AxdecHhuzkLv76ocTCvu_1rYGCbgiK7KNqom8DA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/eJ8wWBcRdDkNLhMIE3YBapqkRJOZksLM1ScsIHNmqrfYCav0eCqlLdbtXosUc1tq4tuTg6A-LlMWPILvCndZHbmJ4Qw5aTWf8vMcbnc_cEHskYQIqm05-R7LIbSBTOwtK8S91pZ4JQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/vDp0mMyAEXsbYSA-gWkksXFvI5NXqFWJ44SI9Vev1jmZjjmyqxG_WHHciCS9bmHDExI-qFlEfHQuvUwhHiRVeEIw4OPz6PV2BqcrHpI3MfyW-eMuK-mjcRfT3RUXMeynjoPSlf9yJQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/xS1XTSe5I2PB3JaF725tiBJA6J_3NT_372Uk4NamipVvdet1ozpd3P4etMKGRieKX3N7lLfXNLY7MqJjInNXNqkx6A7a929vve1JAVIlGLbuJyPo36RdTMW9vB4KEkS5dHbL-PCPkA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/qFuwx6IEZzTpv7Gp6iPuxyol2WAQ5oWV4MFB5KK7-6JZ7SOZN-lQ4pPSrR0D4oSVbC9VuXXggKv6nvILTJU3vmePn0EvUJ_KrfFf0IWiYjsWMKZoUOayGLs0B_ark7zran3LfyAY8w=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/FbG4RzqubqrWbposlK5-415RVQtON3ZoF3HUAOMMlXEfCEpPpv_RIyxC5mUMz4pfLxYAyZUBoibU82aJwTuHtlCCU4-WvdAE_3yg5OeX8Kndg6cTmLnlv3BaYJc_lpA69Lp3_iSKMg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/0OUjfpEgm7zd7tocemD0_fF2rISHhaCDm9BBAUo595j3dj7P0rjWi_0bRUod0yY1_GVAtDsZllYb9nkcyMyA3m-4GwgsPdyZXvyVVMPqGlPem391l5Uji0mObczM2amLvc9XahQYZg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Bnp13WDSJv-3eRyMmOTxjVVQLUmj4Nu9pq0viNmtLI8N3Mq9LatiDENf2oJhVyR8lQBhUFxc-i9gD-VJovdtrMfvhWy7he4U7tbxpJMABXncCwlPVBZHXWrVeyg7aniu_8p-EY2mZA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/IxrLl--iecVoSVkquq8g0QHHzuvoocdJ3f3Ynxi4AWDLmM_KkwKl-vb9RSP0amyfQmlHfHdV0nXaA3vcL75YLZT_SR7_DVT05FCb2vN82bZn6jCKMcmHz8K7oFdryB8O7WHmCo0WSg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/FW_NE2ViMtwNbkqH0Pftmv-RU0G143RMrrp0uUBLrmzuDe9w7SC2bEmz13fQ0-k7quSsb3ZvFGbjtShDW7TPaUKiZzvzZJVjfodKv1J4HX4U60b8CW7x4EBX0pz1s75d7QbNZjgEqg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/VGz2-WlqEmqJUf7iB1OtB5aHYAyjkA2sxO8es5SN-otpl30qdn-vsDzTu-m8SGy_CVRY6BlDtSjhORl2FHpXY09V83MjO41TEBFqti_vinSfP70qNxs26sU1j2vQI5Vim5Jf9lg-vQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/svKDu5gyMyLGvJOszLwS4UQXi8HqJ6NkCPQ9_hc1fQ5m5rqvUMEfYzPtRuua4kXwbNiXJIhzTCHqvlyhr-VXy8NIRFy6oUCccoIdCXjkJC6nO7Q80XtJDPkhXmwwUBqp1II_6MJb8g=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/SvQJ1t0yx02mBlHw6vhgptQCwz31ZwYevgkI97MRo93X2ruG_Rn5SDkZBBbSKZ0ZQg46PvKlcZ6fCUObVCFe4LfePwQj3_sQTX7MeCeF9fA7DBCRd--TLgLMeZ3QMY_tMh5P1z4Zsw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/ZyHMkk0yDZJCB0fMHsVw7aMlJmFeuj5Ti3duLEHGP4nD7lNGbRiPwongTaW2BDauJSwd9LByYi6R6mi_cpZc5xEGbNqsOa-A2O0XtI4BlaT8OwLHuZncT8Sut909EP4lQJIxJKKbZA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/v-SJFfOpoWb2SxZ223J4Ego4PApo2nEMiq5E724N2IRLOHgspaVkzVJMxhM8B0Y441k9x4kj9EFkMcpfcgyfMd8R8MNxDVTuY6lIalPYV6RZFiJlTDmgnnn5f04pTU8nNdUUf8Mwrw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/PqtX2w8XucKuksvw3cyh2oL0MWyb6EL2XU1JWUNHJ7OiHtaO7vkvoIbptNyDZ-H1h0ZeRR_U4UkKf6iNVYHsiED_4qXYKNvKL9gk2RmTHNwIcXFhXLKdfYEUVmE5q1y3nd3Zc8Aoew=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/THviZBZt-Z573hdPQYNZnT72ZiXQFEXXN6N7IMf0w1mQg5jcopugLDFVMKexMLXRw3SmgGx0HMExqrnmP-ASyfhl94QZPZKiQhemf3-jdP2dOeUN_UifP47cZ6jY6T_GIVMAgB-znA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/cEy3oIk8jK_42Wmjz6kvV3d7UN5ox3CFNc9azP6HOQ4qS_Dld50Q_QWDfaBOQxgQEodF9AzKqWbxDLq0wiRgVXqDrOjavS69heAKRFvFnVHLlI5dh_YtpDFAt9u0EHYXgHXe3M2uHQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/0h9vJxL_FfM6-SLzFO8Fd9pwoZsRw_mrWy8ZnwXV0KyeT1-CTlgJTfneZk0xjd4js3toVTxOQsge_OEl0HGH2Aog8glnds29xEVAfXVyvu_HEqSZsoyDWnA1dQgmfxWLYJU0cK4haw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/4VPGh2hckniRyav_TGNMCBZfwJ3zvFQzdG7vC27dNlF349eFtOZwd997-CalYzY1ro_zOSw1II194y9yCX4RX82cpxMr6mT1tLAaOftc7X-aksW5ORci2KcKwQeXcXVKR7QWdFLGmQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/yYG2GL6DbLdZsG-SzH5zdaa3LJPODTwH6kvCsyFIyJ7KewgJY7bawZJWdkHNrRJWRWqXK05kvKNaA3g604wi-9_zrPoTnj-DgELJaQS25DsSmtHbssTo4DxditHBdT53TisY1ew-Sw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/PBlkBZ8XC7XRi7lusS5ZgwdBP33UVpa1CRvmBnTxDMgoY_dZ9US8HY889eZlTAb29MkC5UDnpHABWQVlSm4RRv9yW7nCeBe9ITsZbb6P5D80zB--i3sro7hroqyDeYhj_qdsRXkfaw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/_cIEQEN5deG7KOMsLH23OljOcXm6-76gt5ctoDPrWUveuW9PwNNzatSVhtIofALf2vdSd1RI2dCO3uQGLrGCNnwqyIVlUjkAEJVi-9hOytKyG_ZvEDfZSyyBxKKeucxWBStuHs3S1g=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/TvITIXkvmBGU8ioSJSZnwBS5YU9BAun5Zbf9snZ9gF7qYw5bIz6ftjQX5qptW6ySJuLsLF9CrDJdwmDMtfOcGGZ7DmlnR2ZEFCbwn7oO5jX4CY7J0QHedL08e0GhxLkxpu43YwsRsg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/p6FlAzgAcgyHQofU0i1oe39QvhgWyeZexgnP91np1_QAC3rK5FPvPvaXZ4mbyqfJtt5_dbvyn-hz1oBdinBZa8JBIDtkzQXfPdttSE_0B_LzUk8a7SJdbS6LgsvAyTqzfmU4Uea48Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/nlmqlm1r6LblD02vCHUjqV4YawEaYxSk9hvHrdP05sbaYW6oL5WjQVxoXz79sTg4jY6QRFoJatkJPU0swis3XxBMWN1xYKZRSR3WyocBsgTWCErB83isYoBimIpi_GvA9RGR3lqbbg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/09b8jn7eM1LPd5evHxZFrVr-AA0Jhnzz-78xPlvgyHrVdoP-VjC4Tb84MWCz_774_aURnTkBrNrIQ10ekw9lW0nQkjdC9ecuZb8zCXXJTITa3Hx4_Yjib1MPe52IsLjeWZF8xpNwYw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/6cehNNvmMg0VHcV8ZrAYR7vrmcnRQAnlBYuByp9j0iE1kG3HmVHh6hiSHSiuCLXl3nrmaY7Zq3DmTmV5CJ8OxJ2lgcUiHqlCs1uY2xqiDqgJMGGRIfBLNPqszPi1JdN97bgbfDD1Dw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/5FL-0laGMkUDQQYTlR84GbX6RS0oZhJ4rLPtynU0z9BJnEpqk2Ccv5t6ym55uc7Nzi8p7NryEXcRb3NqTMUUFL_YhY8MgQC8NktVGVW1GMP1rpFPnDL0a86jExv-DRvLTAkUNHkbSQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/YHTaWUD_WzNv3sWTc4VSIyYlbTk-Oe-UInjtPtSIqf9fUMaC-ZSEknhgfRVRM0D5utkgdT0OLQ0eHt8r31HNvwC3OvstSAVcNsRU5S7kvS-1UyLTqwdWKVDNrZ82kmrxOYHb5ElQig=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/dRqoOCiqNBHBWlAvlLm9FkQX8BAocuTXj9MhpT-2w5aIZ7JDCVjS4YMlySUhLcKFpiE0jSZVX_UAfMGbCAHbhxtYzqGaFY8BTa3rGO9RfdI_xevOKq-8e472x6CvqbCC0b_84atJ_Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/MzGfzs_QloIt_kjN8qduSD0wU6A_e2LFk0Hvy1EC1v5V6ycwfdHR8G7Ov_jL3bst_c8Tc7OOKDaNJDA8QqLBcOr-l_MuRLGuup9virKHamY36FKtDAPjH1G0YEA_0wKZAycfkTqePw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/FfNwcDQwXPRgodEv9bSa5skHO4-E6nZsZtimXln2O11J8i90q2rUAY0voiY6fHwDGL6C_72uN4Lqtr6t9FtXB8jYt1MK5L0EAPK9fbkUVOUpujCbt4NFFep_5E76ttiQyaGNCXuPcw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/4rneEbDHF5bvGa2yakDJXaB8EriCmeJmJMX27PlU0anCUdjHJwEyAD09dnExzMJRyQ5e-s49Nb28OohR_BwHakwYkUUNz7-gW0fEH4KdhD5RvAcxp5Udv46HGRoClH7qsdUoWugAxg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/I7gTxSbIM1WlyBF7ZbDcPh_YiLFb6xMgrCz7gizarjbiNdRW59B1sw0cgXghTZ5kdc9IpgBWwTiZOEzzqW9peOIdifcE7wqWfkDXBIpLyKZvGaWFvReh_ZZcp-67X0g5mrYYXbN1-g=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/xoi7b0qZt-TgTpMRzUFNXiAHwukTWXSnT91VMvgs1A2dinBtLcUSuxM7ps4aJHn9cADfIzk22j8WYoGGGixgo9YIr2o49jtCsz3YsfjS5sX3k1Q8J9gL9SFYxtgzNur3LjEXMCV1uw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/TVbNH-IQybjeiJOQvy7339KFk4KDgx59wt8J9NqbqRJ_Rtjguu9kdopjDkEuNfHO08e4s4I5G_TKiHh4L10EkJeQNnPQk8FlWkM-5XaYvejk2J_lXtorfBZi0eraRPWSGUNu_CALVA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/KbwTPLLV7q3GaiXPYfSt3kDNRrv201IhRQg2QAaem6QVMZbNCTwVpjgihr9hyaJa0MvSYjD5bMEPIYby63lPYQ1j44tX7jrSs0-6I7e3EBYWBO81RZ6ffPfU5fztaXu6xxV73XPKAg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/NWcGh_ORChlsKXq8M5Kcj5uhZHqhk6oYxBoC63WtrhniYxb3b_YII-Qm8e8ooP5YPWD7HDbzqYnJInbwo0cxRh0LDwgdnigPCPhKZKXaSZWw5XkSeZluVJmwZK8KJLrM6u0iznCS2Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/L7IdhKuix5pgU9mDD0bjfUyqFozp9vfDpR9iXsLKouh1ELS07BzsJ422ZPEUtKp3enyWJGTVxZfj95S7jX71Z9fNUbDIzpyZuMZ-tezYG5knqX8TXAorAeRcfbc0S080c6EZwOQUOg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/1_18pkDnzAldVA8mpnoiqm2OqeqjzZzIdC8JpUVNay4fIfGXdHgKsk4Pt5iAq7MQLO9jDprw6XMBurLlIGztup30ePRE38TpcV_KsChRiD93bXDjXw-phswd6yNRcdfj3xriFqj8nA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/nKqE9xbX0AK62iB_uHFc0T0GajRjRpnOCxdxb56TIkSlMq9uqSVbjsaNt1a3ZJfS_RwfPGhSkUfSmAzWvY7Wc_eHgutPwuf0KnfGKHPp_MnZFYMqDG8oGK9piXdQjyerPZ-L4f1OdQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/3tagCzu79FnaYhvxvIe4l3ZX0PwmXDukcCy83S-Hmvk_MMxQ878YNcWP-e76b67_8uOKpm2s0w5JYvRypcYo3M515YNloK3nf6GxzfmUb084GIro-Q70Kq0CkkhhfjnQ0D4Gf4v2qQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/-7SXlwkfU2cDaGESm1wu91EU-QbptY3jAEvrl2wR3B83hBTKQhdIMRWdRdeas1WYnrYsYL-LSJU6YrgauoV1BoyaKBGQM-BjXwwo0TAHtKYW1fhZaVR4X0OxOaPM6_rNIkhOJbHCwg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/iX1DhbjMCWHPxGg3S0-T7Y1Zej_qxK5XUb-jL9N1IcUBnjpCvzkPmkBGoPUxvPhUdbagnriZB3AULupVnZfZEYbFq7nTbxs2S5ndx32O-VKGFAAgpdQnLAUMNgx9yhnIRi7pvNZ9-A=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/_1XsrOK1-LWlxQANZiCBCbuMwrt1MA4wVNkgdX7iRPAycbe3rPsiD0XTBUj4SuxxD_O4OBN0boEmv62qLfoknq41XzH4goy-4J3u-a0wXJTE_jyPZ9i8AQzXSrKlHx1SGTd80QnX7g=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/adDAJ7bSBBr1y-KVZRYnQk68bt9fDqXX3wYluDu1BuU9Lc0bc1eZxMsJqBNqAjp79mCln0DkX47G8nIAExtoSv3k7oDnDsyvdSAsxBuOyAgEI-8gKAcJyWX2mj71CHuklbd-KBl-kQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/HsqYxq5JwMyfsM6qSRG_d3jxeJB2R_0gtUknAI0710NZ2NkJsKD4B35_bM_ep8SiMSU_wXhHJM32fNtUwQtxo3P_l1Hw-HKgE2gH6Dm8fsEaQqLDg4kAoevtdITU1AqlXU9FXGKtIw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/zvzeBE-YAnKuFAvJ0ZMU7DFOHJUiaOeqP5sYEMEjzHxPG11HJExae6svQLX8rBkl3d5s2596cfu43cM2M5nFLekreUssUemfpnfPJpu3W5zgE8me5zbkgWIq0_AzdxhQct0mJEcC2Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/pSlV06ZlN7EpIefSxNDTpaP9DvI2V7umbQVv3KfnYiKPbRY_KIbqZi766YMh2fUukIxZgpiFbt9J8wmE2pmcdyZxSCgI1f8ipefqfjwtLZJJCW2KP7VVEnKJtuFBwxyqZb5QdfeDNw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/HODVGMyTEnOp5h88BGylT8jfmSNPdD3VHxhGdUlJ7YahnYOZl6AyLkbNmEcpTK1AQMlXjmG8RnsgZdtDKxeBZCmdWeVhaFretlQRfgLwRbtN4rER7sny8IpEQRd1TdMI05EDCM6VTg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/OBWLR8gBMjwqBmlV0rHjDUX2G9HRErDAHFLgOkWH9WqRhxPtiPZkfMPPlXij0xKtDIA1WpsAYS1VC8WkaEIYHRiCwieucL_rtRJOyxoTWmGcbCL1Y-i4uGKU-PuNgo8-sru8MzMGSA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/4a8xfPPN651ArrmEWYtNDhTp-hEmNO4WDbM3V_ZzXZ-04Bv90kmf7hDA1qe8_QYCrpw1UXKmcoxB7qnEGxyjx9THv4dtAua019Rmhgv3h5pD2-cMa44sLN9qvSTzMLI-tc7Q6G_shA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/u61UmezFG8ntthfWtMNkCefVs5tVcVbkBbH1otBUOdDEtHKN_r0PKSMpNGMaJlaF2M_FLGHsF7sZXWIH850F1JNseNvGAcBgOOX1aH0i3ipKorTDnsPE7yUb8_-1BJKq2t9zqR7BWA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Roqxv6sWTOFJUPvkKWY6OC0UYW-cYPdDZ4kaSBCj3RvTx477PdylvjqGCDa-vwevJzzBuQKRszkAaXIJZGUpHcihS2ie1akVR72Ga04uc6KGplisf2KoABjVz6E3UMfH0vditznzHQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/hOUQjcAjTrqFZq5s_xQo-GHmFwpHfr-i48Rpztb7CxBv4SxdNLdCKgs7zP6kudLJHiTYqpSgP7UP_gzRiYoP_HE_s8wsXAYJRMvjx8xHQZ5aYAZhQV1IgI0brl8rvXb2JBh8JQnZww=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/hcB7HhG4g21o0nec0wjyP6loh3Z0hz6rebRexUPmyOFW7cilwVJD7bIlk4ATTlf_RuuHCh6bMm6-0VxKNaObFr3niHjmkJx2gUU45JyqdQAEgZyoHl-1KSIugMBSFBXClTC3OUS27Q=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Vtkmo3GTQAJ7vTlJwjNYoDowNCm3EexLhmifoQ_vq-QENbsvXwV9dfpjhPDrZs2PZoKD0oj9R-tAKpAgM5BgUW0SM3bolWnLpsh8X7-GoirKr4YPGgbF9eIq47wPZxL1M_V1Mn4c5g=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/9aAL0jcCz82w2b6JsIDh_ug0uEXGfrgcanF8t7IV-bF6WvQi8xdJdKKjS_zppfnfr6CdOFQpcVP55TEtsBDUj3oOJqJJhlxnqw703qg3kxlBAJEeGI5-dWoGayBqnvp_3abR0OccTw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/1xCvYfiC33G-jdrKILnVuv9ITlob6myMIUoxvRuK4G7YwgCgcqvf1gXKbwi6UXxHF3VBGtHZtw_23IfX-npwy-HQT21Qsde1fW0P3_kZbHDvzU-_URSyXSAZmQ8Y2cVWvAUNbEjUpw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/6D7S1SknRNGs0_tLzM9mptRPQSGfw6jBtHk_NSqAzhLY8XlCerwAgTms6zLrE-mKwYOb8avaGUzb0fIupjOZ6mX2RRa7T0J-gfs121yDWyhmJo12hlNJIlXmLZK-VCaWNhY1FQ2PKQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/DHM9aFhjtGkerweq10PH7J2BSDIqapapCyjkjJkEXRsNR8dvCZGEsjWpQM44jGYZEgY-puMySKRCT5k61pI-tMjoqPFceORohwU_m-h9JiVFPxjQJp4vcg6TuNIAvb2SavX59WGQMg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/FGeser9GqfBU8v7e_bg5nAxxA4VjfPg_y_kDfsS7buZe-mcR1jOnmz-8p6elhY7eFyfzqYjzdShHYd4noIkUf5vbBhxb5E7VrHCyY9EEkdPlM7xNxmCGbH3c_yLXLXr5mDt1KKUIeg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/GkQF415PX9A8cRbooymtGG0q3R2TMQxYf9cp_aKMevrIrmBz7hhGG6oRCDWi8silg54oHeXdUMOUeI0bjOvnYPW07z7AMpuZ4rhk0QOUW5aXKUC6yN1tAVc0uZoDzpQhO0DXFsOcEw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/dk5DKmyAEwpTL-hTyPlrC6aOFvYxVCH5HgHLw8h5XuRPVyq-rK9EwZwr6_hXvAvGjjf5SV_Acy2ngXrqn7CJKWHj5UJy7oo4kspK01E_IKPKnBKyzuxof3HHYQ3suW5LrImVK-yHKw=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/PG1VrjZ-x0hkkdUratoN7b12CFuojAnB6_SQutkeBqIIK_W9nXfVyYFn6ciJIFLHRx6YG73FEzEzU8AY64CT-jfYI9Sg6OEBuEtVz2tkvbAUIG2DnT38UlAxmwRfcvRI7r6ah0_SWQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/-I4XofJlRedwOnpW20ZPWGmq0f0msQLwukMkH1XfrDS9MBeNxRIq7khizjhtzMyUziAFfTY7oHyQodwarxoQodtaO3IsC9tfpdq4LnSnya-s3oRyHjRxN4OY2ka-T8cuv32PdsT7CA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/zfQNPjc5HFP7KBxDODtsqK2b-ZT4Tkg60J6YMWMLa4HwVsBplP6W88hYxf0iEkvizn7GAt2ptZ70Elj3awjNZ5XdrcZyu5Qq2T0-fUNHNnQHpJOuNpiLLW8VCEmi5aU44gZD4ENFEQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/ui-fHiOvCNCcc5cDnzvOFcVgblGlUsgtyoN6moXfIo6zvADfZY0dpqkh9oWQSJc9DSHm3ZPSGBdIrC0SEg1GEgBtgH5ec3hTPR_23GpNQju7HsUR44bQqnI1ppLU2zCWD62e_sYjLQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/t_HKNsz4xk4orrEHvmVxt1RZeJBxy9EE4vfSFenm5vqqCgZviCJrYVJF9yi8hB50OcKCCasOn6lCIztsr6dDnlwf4L6hVIR1Gd7yPrfj33bVf4t4kOnjF1oN0KcV1S5mbQrZxCMDqQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/Woyx892-v9XDwG5IOEYM1QfE-e-BruMP2fdkjjtNZ3MdybVQ_lJTE_1jo7wV8aeclvmGhuZ7fOEdLxEABIyufbkwio09D0nnvFS9DwpPRMQb1nqdEfRWL568SALlMhjxBN_LpgU6gA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/cmF25D7zVN3Nb03lo9cD_VH8NGlJ3VgZ2xc7IHPJ9HEax0IgHORdhe6eEKaUofzhbPsh_pG2jZcYPLTV_ndYybBnnkWaD8NdSrX0smoinmZp9KWEs3Sw2pbEhFASiJ8AOOQrLTbFWQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/v7lJgOBFtCGhA98Q-wJ9LxLWJQBz94e63zqIFyPNw9f-at7LzYujeDf8omRwcjmeAprQL0C8lKw3fA0tc8ORGEHCbHAyC8vlUKzCimKLQr_iHIIEZhl_9-ybvO3apZTzxDd-RX6Mlg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/VKPTtlxaJCaMPc3ry0eTloZtM4iIAW7TJDwaTobzM0NLU0_box39_QN117lr2BnuYkyuqZyywfph_IKOj0Mgxf40_gnLH8CbnOG4m1sLN6C8pOF0jvEC8xX2nVVfNUvibVJSb-GsJQ=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/639bOF-6fYWQgu0yeFzfmJ7I7YK8FZUvOBQJRKR4ZZCJVTJXzXUICrvtXloPoKBrdHX9k-UbJrXNabDXyI1UET8-diTflzqJUkO1K9SjYlbhrAzckI_XPcv9wBgEEdbsXlXUZyPoVA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/kfgoYzjUWotG-j9CWDOCsih-6vpfQ5sm-pKpTbhhQW5R4jfwJOE4tsMtrglEd6cf9nVH9QCKv9IBqci2eqNqHG2yXedoSSMe3X4WRlgDyZbEqXJoeXWV7QzsR_K4LmZCX-bVjDQrjA=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/F_fbil7HiG8Qgh5QP6KkC6212ezKNDylg04vo5dg04exN064UbhOaNkSWoNA1cR0JEXSju4QNpEhJ2I6my5qavUv-HUzaZpa_GZ7XL7mPHCGUUOlbPgGRreqy7lMQCA8iGSYBDKGWg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/tf-FUb2rWYI4qGBFEPPiGJ90Lhca_kWxgYgW60rbZWUJRdjO5gpzgMi01tLH2e2WQHbBO68CHUAstranSSXd4alcP5IzpBLRxqorXps6MRWqYu4yO2ovf5kg5Ay9DLa8NIZAolMddg=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/5Q5OuZ5D0yA0oN4zMk2Cn2Lc3z21ogeR_o7YdgYiCcNWl6wxyD_4O6uaG8eX1Ow08587KyFi9C3V-H-x8WdJk35xVq-gR4yewWpStPf9-geM479TZzEk2Y1Y0rapBz349GKXUFatig=w1920-h1080" src="" alt="" />
  <img data-src="https://lh3.googleusercontent.com/q1zlHjiddkf9S0IU4zGPOJ3yVjTErMTARmIzHWP2hIPjH_kVD1VFJr7RkqBcp89oYrdLYibiitFAumFNFANuFq-GpBZLQFvsExaAeIYLpYPiCRzxdE8eWlnPiKJx7OXXxcumwMJVQQ=w1920-h1080" src="" alt="" />
</div>]]></content><author><name></name></author><summary type="html"><![CDATA[A little over a year ago, I studied abroad in Cape Town, South Africa. I thought some of the photos I took were pretty groovy, so I’m embedding them here as well.]]></summary></entry><entry><title type="html">The (NP Complete) Concave Hull</title><link href="bgpierc.github.io/concave-np-complete/" rel="alternate" type="text/html" title="The (NP Complete) Concave Hull" /><published>2019-06-28T00:00:00+00:00</published><updated>2019-06-28T00:00:00+00:00</updated><id>bgpierc.github.io/concave-np-complete</id><content type="html" xml:base="bgpierc.github.io/concave-np-complete/"><![CDATA[<p><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/8/8f/Simple_polygon.svg/300px-Simple_polygon.svg.png" alt="from Wikipedia" /></p>

<p>In my recent research, I’ve stumbled across the fascinating topic of hulls. For simplicity, we can define a hull to be an n-sided polygon that encloses all points p ∈ S, a set of k points. The most common type of hull is a convex hull, which is the smallest convex polygon that contains S, in contrast to the more rarely seen concave hull, which we can define to be the smallest polygon that encloses S. The difference between the two is, of course, that a convex hull is constrained to be an actually convex shape, whereas the concave hull has no such restriction.</p>

<h1 id="why-use-a-hull">Why use a hull?</h1>
<p>There’s actually a ton of interesting applications of hulls. One particularity novel use is described in <a href="ttps://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#links">this</a> cool blog post, which uses an alpha shape approximation to find contours of places from geotagged data. Another common use of a hull is to postprocess the result of a clustering algorithm, such as k-means or DBSCAN. This is the application I was originally concerned with.</p>

<h1 id="what-kind-of-hull">What kind of hull?</h1>
<p>The easiest type of hull to use is the convex hull. There’s several Python implementations of the convex hull, included in projects like <a href="https://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;cad=rja&amp;uact=8&amp;ved=2ahUKEwjPt-3p4o3jAhWVQs0KHfG3Bj0QFjAAegQIBBAB&amp;url=https%3A%2F%2Fdocs.scipy.org%2Fdoc%2Fscipy%2Freference%2Fgenerated%2Fscipy.spatial.ConvexHull.html&amp;usg=AOvVaw2xCnhbutY0EXwZIA8vYy14">scipy</a>, <a href="https://docs.opencv.org/3.4/d3/dc0/group__imgproc__shape.html#ga014b28e56cb8854c0de4a211cb2be656">OpenCV</a>, and <a href="https://shapely.readthedocs.io/en/stable/manual.html">Shapely</a>. The convex hull is quite intuitive, conceptually. Let’s dive into some code.</p>

<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script>

<pre class="prettyprint lang-py">
<code>
import matplotlib.pyplot as plt
from sklearn.datasets.samples_generator import make_blobs
from scipy.spatial import ConvexHull

X, y = make_blobs(n_samples=100, centers=1, n_features=2, random_state=0)

hull = ConvexHull(X)

for simplex in hull.simplices:
    plt.plot(X[simplex, 0], X[simplex, 1], 'k-', color = 'red')

plt.scatter(*zip(*X), marker = '.', color = 'black')
plt.show()
</code>
</pre>
<p>Output:</p>

<p><img src="../images/convex.png" width="500" />
<!---*** for fucking color change in the syntax lol---></p>

<p>Cool, that was easy! We’ve succesfully associated some sort of area with these points, which we can find with various methods. Scipy in particular has already done this for us, so there’s no need to do it explicitly. Mathematically, a common method is through <a href="https://en.wikipedia.org/wiki/Green%27s_theorem">Green’s Theorem</a>, which you might remember from vector calculus.</p>

<h1 id="so-whats-the-problem-here">So what’s the problem here?</h1>
<p>The problem is that it a convex hull can be a (surprise!) bad approximation for a concave shape. Ideally, a concave hull would look more like the blue line:</p>

<p><img src="../images/concave_and_convex.png" width="500" /></p>

<p>This is clearly much more accurate, although still an approximation. But how do we get here?</p>

<h1 id="whats-the-deal-with-concave-hulls">What’s the deal with concave hulls?</h1>
<p>Unfortunately for us, it ain’t as easy as the convex hull. None of the previously mentioned libraries have a built-in function for the concave hull, and for good reason. The problem is that finding a perfect concave hull is actually <a href="https://en.wikipedia.org/wiki/NP-completeness">NP-complete</a>. If you’re not familiar with the notion of NP-completeness, it essentially means that the problem is incredibly difficult to solve (Non Polynomial time!) and (the cool part) if we solve one NP-complete problem, we’ve solved them all!</p>

<h1 id="np-complete">NP-Complete?</h1>
<p>The process of determining if a problem is actually NP-complete is termed a reduction; that is, we mean to transform the problem into something else that we know is NP-complete. Therefore, every problem in the class is merely a rephrasing of the rest. In this case, we can fairly trivially show that finding a concave hull reduces to a problem called the “min-area traveling salesperson”.</p>

<p>The traveling salesperson problem is fairly simple to describe. From <a href="https://en.wikipedia.org/wiki/Travelling_salesman_problem">Wikipedia</a>:</p>

<blockquote>
  <p>“Given a list of cities and the distances between each pair of cities, what is the shortest possible route that visits each city and returns to the origin city?”</p>
</blockquote>

<p>We can visualize this graphically like so:</p>

<p><img src="../images/salesman.png" width="500" /></p>

<p>That looks like something we recognize! We’ve actually enclosed the minimal area, which was what we defined a concave hull to be earlier. Although our visual intuition is enough for the purposes of this blog post, you can find a more formal proof in papers by <a href="https://arxiv.org/pdf/1309.7829.pdf">Fekete et al.</a> and <a href="https://arxiv.org/pdf/1309.7829.pdf">Asaeedi et al.</a>.</p>

<p>As a side note, for those of you who know quite a bit about complexity theory (and before I get emails to correct me), the traveling salesman problem is actually NP-hard, rather then NP-complete because it’s not technically a decision problem. However, the min-area traveling salesman is, as we can reduce it to finding a Hamiltonian cycle in a planar digraph, which is NP-complete as shown by <a href="https://www.cs.princeton.edu/courses/archive/spring04/cos423/handouts/the%20planar%20hamiltonian.pdf">Garey et al</a>.. If I’ve still got this wrong, please let me know!</p>

<p>Back to the matter at hand: there’s not really an easily available package for concave hulls because it’s actually hard to compute one.</p>

<h1 id="so-now-what">So now what?</h1>
<p>Now we delve into the world of approximations. Fortunately for us, some really smart people has already thought about this in numerous blog posts. I particularity like <a href="https://sgillies.net/2012/10/13/the-fading-shape-of-alpha.html">this one</a> by Sean Gillies, who wrote Shapely/fiona and <a href="http://blog.thehumangeo.com/2014/05/12/drawing-boundaries-in-python/">this post</a> by Kevin Dwyer, who expanded on Sean’s ideas and gave a really nice explanation.</p>

<p>As both of those posts provide excellent explanation, I won’t repeat it here. However, I have taken the liberty of creating a small class based on Sean’s and Kevin’s work for my own personal use to streamline the process the bit (and generate the figure with the concave approximation above!) You can <a href="https://gist.github.com/bp0017/bf7e548a04f133d53ebac41f3e2b8ad7">find it on my GitHub</a> if you want to play around with it a bit.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[]]></summary></entry><entry><title type="html">Pretty Printing of .csv’s in the terminal</title><link href="bgpierc.github.io/prettyprint-csv/" rel="alternate" type="text/html" title="Pretty Printing of .csv’s in the terminal" /><published>2019-06-04T00:00:00+00:00</published><updated>2019-06-04T00:00:00+00:00</updated><id>bgpierc.github.io/prettyprint-csv</id><content type="html" xml:base="bgpierc.github.io/prettyprint-csv/"><![CDATA[<p>I spend much of my time ssh’ed into a remote machine (my school’s high performance computing cluster) and often come across .csv files that I’d like to view. <code class="language-plaintext highlighter-rouge">cat</code>, although fast, does not handle .csv’s in any special way, and if the .csv is not short and simple, can result in unintelligible output. I was recently diving through my organization’s .bashrc and found this handy script.
<script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></p>
<pre class="prettyprint">
function pcsv() {

cat $1 | sed -e 's/,,/, ,/g' | column -s, -t | less -#5 -N -S

}
</pre>

<p>which results in some pretty nicely formatted output.</p>

<figure>
<img src="../images/pcsv_demo.gif" />
<figcaption> from the Iris dataset </figcaption>
</figure>

<p>Thanks to whichever fed up grad student that wrote this.</p>]]></content><author><name></name></author><summary type="html"><![CDATA[I spend much of my time ssh’ed into a remote machine (my school’s high performance computing cluster) and often come across .csv files that I’d like to view. cat, although fast, does not handle .csv’s in any special way, and if the .csv is not short and simple, can result in unintelligible output. I was recently diving through my organization’s .bashrc and found this handy script. function pcsv() {]]></summary></entry><entry><title type="html">A Test Post</title><link href="bgpierc.github.io/Hello-World/" rel="alternate" type="text/html" title="A Test Post" /><published>2014-03-03T00:00:00+00:00</published><updated>2014-03-03T00:00:00+00:00</updated><id>bgpierc.github.io/Hello-World</id><content type="html" xml:base="bgpierc.github.io/Hello-World/"><![CDATA[<p>First post! This is a test!</p>]]></content><author><name></name></author><summary type="html"><![CDATA[First post! This is a test!]]></summary></entry></feed>