Sunday, February 23, 2014

Week 6

This week we have been learning a lot about the insides of Python in terms of coding advantages. I had never used lambda functions nor packing and unpacking variables in a function's parameters, but it definitely seems to me that, after getting used to such programming standards, a coder's cleverness would benefit significantly. At least, I think that the use of lambda functions are a very elegant and efficient way of quickly solving a problem by coming up with a function on-the-go. I still remember professor Downing's class example where he showed us an entire function, if I'm not mistaken it was to calculate the root mean square error, that was written in several statements, and then, with Python's beauty, was brought down to just the one statement, ha! 

This week we have our first midterm, I really have no idea of what to expect. In my opinion, so far in this class we have learned mostly about coding (and more specifically Python coding) techniques to improve the way one writes programs, but I'm not sure how professor Downing will test this on the midterm. I will probably go over the material we have learned in class and practice by using them in testing programs. But there is definitely a conceptual part to it. We were given a study guide with several key topics from which we can start studying.

On a separate note, professor Downing also gave us a heads up that we need to start creating groups for the project we will be working on. My group and I have started brainstorming about interesting topics we could work on, even though this week's priority is the midterm. I was not able to attend class the day that the project's parameters were explained but from what I have gathered, the first thing we need to to do is choosing a topic that can ramify into different complementary topics. So for example if we were to choose the music industry then we could branch out into music producers, songwriters, musicians, and singers. We will see what we end up choosing.

Friday, February 14, 2014

Week 5

This week we really dove into differenciating generators, lists, dictionaries, and sets; similarities and differences. This definitely helped in the process of developing our Netflix project, which I will get to in a second. I think the most interesting features I found were that generators, for example, are exhaustible, meaning that once you ask for its contents, they get automatically erased. It seems to me that they (generators) are a data structure with which you want to be very careful in case you wanted to use it. Lists are your typical array but as my partner and I found during our project, they are relatively slow to traverse (especially compared to dictionaries). And finally, I remember from my Java classes that the map data structure is one of the fastest ones out there, given that it uses either a hash table or a binary search tree as internal container (yielding an average of O(1) and O(logN) respectively for most basic operations). So as soon as I realized that dictionaries in Python are the equivalent to maps in Java, I knew that they had to be among the fastest data structures, and after testing we definitely saw it.

Our Netflix project had two basic requirements: Getting it to run under a minute, and yielding an root mean square error of less than one. My partner and I kept running into the problem of getting a runtime of over a minute. So, after much debugging, we came to two conclusions. One, we needed to use dictionaries for everything. Lists are definitely very slow. The second conclusion was that we were reading in too many cache files; about five or six. We kept taking them out as long as we were still getting a root mean square error of less than one, and, as it turns out, we ended up only using two caches. Now we have a running time of less that one minute and a root mean square error of less than 1. It has definitely been one of the most interesting and relevant projects I have worked on.

Wednesday, February 12, 2014

Week 4

The first week of February was a short one as well. The university decided to close down (once again) due to weather issues. However, we did learn (or kept going over) some useful and very interesting stuff. Prof. Downing has put a lot of focus on the importance and usefulness of assertions, which are a very fast and effective way of testing at runtime whether your code is doing what it is supposed to be doing. In order to show us in code how they are usually implemented, he gave us a couple of examples where some assertions work, meaning they make sure the code is doing the correct thing, and others where they don't hold and even some where they don't get called due to other factors. He also quizzed us on this so I definitely think this is something he wants us to start implementing as part of our coding standards.

We already started our Netflix project. I think it is one of the most interesting projects I have gotten lately. It consists of trying to predict what a handful of Netflix users think of different movies (aka their ratings). There are different cache files, which contain important data regarding their usual behavior (past ratings, ratings per decade, etc.) and, with the help of those files, we need to predict what they think of any movie x. Prof. Downing told us that Netflix at one point was offering a million dollars to whomever came close to what their actual algorithm predicts (I cannot remember how precise it had to be). So for now my partner and I have implemented a reading function in order to process the cache files and store them for future use, and a running function, which basically starts the program. I think it is going to be a really interesting lab and one that will give us great satisfaction in the end, given that we'll be able to say that we implemented a Netflix rating-predictor (hopefully!)

Saturday, February 1, 2014

Week 3

This week in class we have been learning more about assertions, exceptions and even the "try and catch" block (as Java calls it), which in Python goes by the name of the "try and except" block. I learned that the "try and except" block may also have a "finally" or an "else" clause, which seemed very interesting to me. After the first couple of weeks in the class I can say I am enjoying very much prof. Downing's teaching style. It had been quite some time since I took a class where they called on students, but now I remember how effective it is at making us be very attentive during the class. I feel everything we talk about in class soaks in much more smoothly than in other classes.

The first project, Collatz, was due this past Thursday. Looking back, it was a little more challenging than I had thought. Especially since my computer kept complaining about the makefile and wouldn't run it, which prevented me from creating the Collatz.html and Collatz.log files. Another problem I had was that the oracle that was supposed to test our solutions showed that I was not passing its tests, when a couple of days before it showed I -was- passing them (I definitely panicked for a while). I am assuming it had something to do with the fact that I have been working both on my computer and on the GDC building's computers so with different environments a lot must change. I can definitely say I feel much more comfortable with git, Github, and the command line after this assignment. To the point that I'm now using Github repositories for some of my other programming classes to keep an updated copy of my projects in the cloud. However, in terms of the coding assignment itself, I am sure that the projects will get more and more challenging as the weeks come. I think it's very safe to say this project's main purpose was to get us familiarized with a style of work and turn-in requirements rather than to test out coding skills.