Showing posts with label Coursera. Show all posts
Showing posts with label Coursera. Show all posts

Sunday, June 7, 2020

Compilers, Project Euler 100

It was sad to see Stanford retire Lagunita (apparently due to a decision to retire their Open edX implementation). Many of their classes appear to be slated for addition to edX, including the Compilers class -- at least according to an email sent to Lagunita participants. I seem to recall the content originally being available on Coursera. It certainly has the look, feel, and substances of the original batch of very high quality courses (like Tim Roughgarden's Algorithms courses, Andrew Ng's AI course, Dan Boneh's Cryptography Part I... we're still waiting on Part II after many years, apparently because he is trying to finish his book). There seems to be a great deal more of content on the MOOCs now, but also maybe some more noise.

In any case, I spent most of my study time in March speeding through the Compilers videos and finishing the first programming assignment on lexing (yacc / flex) to make sure all the mechanics work. Fortunately, there are offline graders that can be run in the class VM, so it will be possible to complete the other programming assignments at a more leisurely pace. Given that there isn't currently an active forum for unaffiliated students like me to ask questions, GitHub has been in an invaluable resource to reference other students' implementations and try to triangulate certain issues.

Speaking of using reference materials... seven years after starting Project Euler and learning about the Sieve of Eratosthenes, I've finally completed more than 100 problems. About 65 problems have been solved in Haskell over the past year (the balance at some point during prior years, in Python).


I had no qualms referencing the internet for many problems, since it's unlikely I would have independently stumbled upon many of the math theorems required to solve some problems efficiently (like the Sierpinski triangle and Lucas' Theorum behind one of the problems on Pascal's triangle). In that regard, I'm glad of folks who have ignored Proect Euler's rules of the road and posted their research online. At least for autodidactic purposes, it seems like more information is (almost?) always better. How to use and internalize the information, how to differentiate research from shortcuts, how to set boundaries of information taken vs internally synthesized -- those are all the responsibility of the student, with decisions ultimately depending on one's goals. My (recent) goals have been in rough descending order to learn functional programming paradigms, to learn Haskell, to enjoy problem solving, and last + least to learn some underlying math. As far as the first two go, continuing with more problems probably offers diminishing returns (especially compared to pursuing orthogonal problem spaces), but I'll likely continue with it on the slow path for the enjoyment. 

Tuesday, May 24, 2016

New Coders Survey 2016


Brief analysis of the dataset from the Free Code Camp's New Coders Survey 2016:

https://github.com/tkuriyama/notebooks/blob/master/ipython/New_Coders_Survey_2016.ipynb

TLDR; coding schools / bootcamps yield mixed results, but there are lots of folks interested in coding and lots of resources available beyond Udacity and Coursera.

Tuesday, July 28, 2015

DNA Sequencing

A quick post before July expires...

I've been following Algorithms for DNA Sequencing on Coursera this month. As one might imagine, it's mainly about algorithms related to string / sequence matching and alignment. The "sequence assembly" problem is something I haven't come across before and is quite intriguing -- especially how it relates to the history of the human genome project.

I'm a little surprised by the course because I realize, in comparison, how good almost every other Coursera course I've taken has been. This course is about what you'd expect in a resource that's available for free: the instructor is clearly knowledgeable and interested in teaching, but the details are often vague and the explanation of algorithms are not very rigorous. It's still excellent as freeware, but I'm not sure I'd be happy if I'd paid Coursera to take the course as a "Signature Track" student.

As an aside, I found myself pulling my hair out due to a Python performance issue and a little bit of line profiling magic in iPython saved the day.

http://pynash.org/2013/03/06/timing-and-profiling.html

It turns out that calling in dict.keys() to check for key presence in a dictionary is silly as it creates a temporary list; in dict is obviously the way to go as it does what you would expect -- the hash lookup.

Wednesday, December 4, 2013

Classifying Handwritten Digits

Six weeks into Andrew Ng's Machine Learning class on Coursera, I found a Kaggle competition to classify handwritten digits that's almost identical in nature to one of the programming assignments. This seemed like a good chance for further practice in implementing neural networks.

Quick Start: accuracy ~ 93.5%


I loaded the Kaggle training data and modified code I already had for a 3-layer neural network:

  • 1 hidden layer of 100 nodes, regularization parameter lambda = 0.3
    • Accuracy of ~ 92% after 100 iterations 
In an attempt to improve the regularization parameter lambda, I plotted a number of sample values against their corresponding error rates (% misclassifications). With the caveat that I only ran 10 iterations for each value, lambda = 1 appeared to minimize the cross validation error.  Retraining the network accordingly increased accuracy to ~ 93.5%.  Further training seemed only to increase the variance.

Larger Networks: accuracy ~ 96%

  • 2 hidden layers of 200 nodes each, lambda = 0.01
    • Accuracy of ~ 94.5% after 130 iterations 
  • 1 hidden layer of 500 nodes, lambda = 0.01
    • Accuracy of ~ 96.5% after 75 iterations
Of the handful of networks that I tried, it seemed like a single hidden layer of 500 nodes learned the training examples the most efficiently.  The 75 iterations completed in about an hour and a half.  

As with the initial network, the regularization parameter lambda was chosen by minimizing the error against cross validation data.  After 75 iterations, the network had almost perfect accuracy on the training data (>99.5%), but the accuracy on cross validation and segregated test data hovered around 96%.

At this point, the network appeared sufficiently large to learn the training data -- it just wasn't generalizing well enough for new data.  I tried to lower the variance by running more iterations and including the previously segregated test data as training data, with little success.  A few last thoughts:

  • I'm not sure how to reason about the optimal size and structure of a neural network, given a dataset.  There must be a good way to approach this by taking a subset of data (for reasonable processing time) and running through a number of informed guesses.
  • I calibrated lambda using random initial parameters.  Does it help to reevaluate the regularization along the way, as the network is trained more and becomes more prone to overfitting?

Submission: accuracy ~ 96%



The standing of 170th place is, of course, nothing to write home about -- but it's gratifying after just six weeks of coursework.



Sunday, November 24, 2013

UI Choices: Coursera vs Udacity


Two roads diverged in a yellow wood
And sorry I could not travel both... 


Now that I've spent a considerable amount of time on both Coursera and Udacity, the difference in UI design really stands out to me.

For an imperfect analogy: Coursera is like Windows, whereas Udacity is like OS X.

On Coursera, a course website is comprised of many sections, full of information like schedules and logistics.  Course videos can be viewed online, but also downloaded easily, often with accompanying written and typed notes provided in a convenient format.  The Coursera experience feels like a natural extension of a brick-and-mortar classroom experience; indeed, some universities offer rudimentary sites of the same nature.





Udacity, on the other hand, provides a single, streamlined interface, integrating course videos and quizzes.  Lecture notes are provided in the form of a Wiki, auto-generated from subtitles and improved by the community at large.  Udacity provides some simple FAQs, but really there's little to understand in terms of course logistics.  You simply complete what you want, or can, at your own pace; there's not much emphasis on grades.




Perhaps the largest difference I've noticed so far is the assignment submission process.  On Udacity, everything I've done is via the rudimentary Python IDE provided inline: complete the code and press "Test Run" or "Submit" for evaluation.  This is very simple and easy to use.

Simplicity, of course, can also be restrictive.  On Coursera, an Algorithms assignment might just expect some numerical values, so the student can write in any language and submit results via the web GUI.  For classes that require additional software, like Octave/MatLab for Machine Learning, scripts are provided so that assignments may be submitted directly from the software environment in question (e.g. just call "submit" in Octave).

Although I have a slight preference for the Coursera format (mainly for the ability to review material easily), maybe it's not really about what's better or worse.  What we see is the development of a nascent ecosystem, in which initial design decisions can reflect--and maybe also reinforce--something like a genomic difference between types of MOOCs.  It's sort of surprising to think about how design, which is ostensibly cosmetic, reflects a deeper identity. But I guess this a question of the genre "turtles all the way down"...




Saturday, November 16, 2013

Retention Rate

I wonder about the retention rate of students for fixed-term classes, i.e. the breakdown of number of students who sign-up, who actually start the course, and who complete the course.  The behavior of students in this matter obviously impacts the sustainability and revenue model of MOOC offerings (though I hope they can remain free to most students!).

The one class I haven't able to complete so far has been Martin Odersky's Functional Programming Principles in Scala on Coursera.  There were a few reasons, like the fact that I started a few weeks late, but it ultimately boils down to the fact that functional programming isn't at the top of my current priority queue.

Part of the beauty of free courses, of course, is that the only cost of walking away is the opportunity cost.  Free to come and go -- Udacity seems to embrace this principle the most.


Visualizing Algorithms

Bret Victor suggests in his fascinating talk that the current programming paradigm involves "playing computer", insofar as we must envision how a computer will interpret code as we build up more and more complex ideas.  It's clear that most human minds cannot immediately internalize complex ideas -- this is why teaching is about breaking down subjects into digestible modules, often with visual aids.

Although the materials in a class like Tim Roughgarden's Algorithms: Design and Analysis are extremely well presented, I can't help but think that for topics like graph search and dynamic programming, visualizations could be an additional, effective tool for helping students learn.

I tried my hand at creating one such visualization -- the algorithm is for finding the longest palindromic substrings within a given string, e.g. "racecar" within "red hot racecar".  Here's the link.



Coursera

I've completed Tim Roughgarden's Algorithms: Design and Analysis Part I and Part II, as well as Dan Boneh's Cryptography Part I.


As to be expected from Stanford, the level of instruction is very high.  A few thoughts on the courses:

  • It's clear that the professors are personally interested in teaching and reaching a wide audience.   Despite the non-trivial material covered, the courses were quite lucid -- more so than many of my undergraduate classes.
  • For me, the difficulty level was just right.  Some of the programming assignment were challenging, requiring 15 - 20 hours.  But they were doable and satisfying.   So I imagine that anyone who's studied some computer science, with sufficient motivation, would be able to complete the courses.  And I think a topic like cryptography is interesting to more knowledgeable folks, too, as it pertains to almost every aspect of our electronic lives.


As for the Coursera format:

  • The fact that courses run over a fixed period is noteworthy.  At this point, other MOOCs like edX and iversity seems to share this approach, with the notable exception of Udacity. Perhaps I'll address this further in another post, but the clear advantage of the approach is that the forums are in sync. Assuming there's a normal distribution of knowledge among participants, chances are that someone else can answer a question you have.  I found the forum discussions very helpful, especially in completing open-ended assignments like the Traveling Salesman Problem.
  • The evaluation system works well for the programming assignments, given that: (a) there is a unique answer that can be verified easily; (b) a certain degree of optimality is required to find the answer, i.e. if you can get the right answer, your solution is likely decent.  It's nice to see these substantial assignments supplemented by in-video and weekly multiple choice quizzes.  I suppose the larger question for MOOCs is how effective feedback can be provided in the humanities.
  • Breaking up classes into many small modules makes a lot of sense.  This approach seems common at all MOOCs.  It's practical in terms of keeping one's attention, finding specific parts to review, and skipping select topics when appropriate.  There's no one falling asleep in lecture here.



Why

Over the past six months or so, I've been studying computer science in my spare time.  My main resources have been providers of free Massive Open Online Courses (MOOC), like Coursera and Udacity.  I thought it would be interesting--at the very least for myself--to track my progress and reflections.  MOOCs are quickly becoming a hot topic.  What is their place in the educational ecosystem?  And can they remain free?

I'll write a few catch up posts to cover what's happened so far, but first a few points of reference:

  • What I know as I begin
    • I took a data visualization class in college. I taught myself some Python and know enough to muddle through basic tasks in VBA, JavaScript, etc.  I worked in financial technology for four years.  
  • What I expect 
    • To survey introductory material in a wide range of topics
    • To learn enough to be able to dive deeper into selected topics
  • What I do NOT expect
    • To become an expert programmer 
    • To learn every fundamental principle 
    • [29 July 2015] A retrospective edit: first principles are the only way to go :)

Sic infit...