## Notes on Perceptron. Part 7: Practical Convergence vs. Theoretical for Separable Data

This post illustrates that practical convergence for separable data of PLA is achieved much faster than the theoretical estimate suggests

## Experiment vs. Theoretical Estimate

Consider a separable data set generated using methods from this post. The data set has the following values of the parameters included in formula (12) for max steps until convergence for PLA from this post: $b=3$, $|w^*|^2 \approx 0.68$, $a \approx 0.003$.

Here $b$ is the max squared norm of training vectors (that are generated in the square -1,+1 resulting in value 2 plus bias 1); $|w^*|$ is norm of classifier decision vector $w^*$ and $a$ is margin, i.e. minimal separation of data points from decision boundary. The max number of epochs until PLA converges is estimated then as $N \approx 2.4 * 10^5$.

By fixing dataset with described parameters and running stochastic PLA 500 times with different random seed we obtained the following histogram of number of epochs until convergence. As the histogram shows, the theoretical estimate is higher than typical practical values by orders of magnitude. The obtained distribution is uni-modal and is centered around  value which is almost three orders of magnitude closer to zero. The code snippet used to generate histogram is straightforward:

```    epochs = []
n_runs = 500
for _ in range(n_runs):
pla_rand = perceptron.PLARandomized(training_data)
while pla_rand.next_epoch():
pass
epochs.append(pla_rand.epoch_id)

n, bins, patches = plt.hist(epochs, 5, normed=1, histtype='stepfilled')
plt.setp(patches, 'facecolor', 'grey', 'alpha', 0.25)
plt.xlabel('n epochs')
plt.ylabel('n runs')
plt.title(r'Stochastic PLA: Number of epochs to convergence')
plt.savefig("stochastic_PLA_convergence_" + str(data_dim).zfill(3) + "_" + str(n_points)+'_' + str(n_runs) + ".png",
bbox_inches='tight')
```

We omitted the required import statements for brevity. Also we normalized number of runs (normed=1 in histogram parameters). The implementation of PLARandomized is essentially the same as for basic deterministic PLA with the only difference – random choice of mis-classified sample on each epoch.

## References

 S.Haykin “Neural Networks: A Comprehensive Foundation”, 19989, Prentice-Hall, 842 pages.
 Yaser S. Abu-Mostafa, Malik Magdon-Ismail, Hsuan-Tien Lin. “Learning From Data”  AMLBook, 213 pages, 2012.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7725647,"math_prob":0.97976255,"size":2228,"snap":"2019-43-2019-47","text_gpt3_token_len":508,"char_repetition_ratio":0.0926259,"word_repetition_ratio":0.0,"special_character_ratio":0.23204668,"punctuation_ratio":0.15113351,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9966237,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,5,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-22T05:40:27Z\",\"WARC-Record-ID\":\"<urn:uuid:46c12f67-0c75-4013-9ce2-7966624ac29b>\",\"Content-Length\":\"22958\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8df46f74-b6a4-4042-b74b-5a3172a83719>\",\"WARC-Concurrent-To\":\"<urn:uuid:d28e5509-530d-4e6e-a1ba-ca34b3f49902>\",\"WARC-IP-Address\":\"192.252.144.14\",\"WARC-Target-URI\":\"http://www.3dmatics.com/blog/2015/02/notes-on-perceptron-part-7-practical-convergence-vs-theoretical-for-separable-data/\",\"WARC-Payload-Digest\":\"sha1:377CB4HW4EJGYBWK45M6OZ5IZVRRE5RC\",\"WARC-Block-Digest\":\"sha1:EL6YAJYUWZRNIMYT47MS7SZJSAPV5YML\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496671239.99_warc_CC-MAIN-20191122042047-20191122070047-00044.warc.gz\"}"}