Week 5

Working with Django

Lior Hirschfeld

This week I spent my time divided between finalizing the machine learning versions of both the repost and jargon bots, as well as developing the online blog with Django. After some testing, I realized that both of the bots had a problem in that when I would attempt to “fit” (update) their linear regressions models with new data, it would overwrite all that they had previously learned. Of course, this is an effect I do not want. I would like the models that are generated from this process to learn gradually over time, and a complete overwrite in old data would result in a model that is too temperamental and may easily form the wrong conclusion from encountering a single outlier. Although this solution was a bit clunky, I got around this problem by storing all the old data. This data is then accessed, the new entry is added onto that data, and all the data together is used to fit the model. Unfortunately, over time these entries will increase the size of the project, but as they only contain a few numbers of information each, the effect should not be significant.

Creating the blog with Django was quite easy. I have been fooling around with the framework on my own for a while, so the process went quite quickly. Django uses something called an MVC (Model, View, Controller) architecture to keep things organized.  Essentially, data is stored in the form of models. Currently, for my blog app, I have one Model: Post. Each post has certain attributes, including a title, body text, and a date of publication, as well as certain functionality it can perform. When someone views a page on the site, the controller processes the URL, accesses data from the Model, modifies it as necessary, and sends off the finished result to the view. In Django’s case, the view is a simple HTML template with Python insertions. The MVC architecture helps reduce duplicate code, as well as providing an organizational structure that makes the entire project much easier to navigate.