Monday, 7 March 2011

On generative and discriminative models

In a supervised learning problem, we want to find the function f: X -> Y, or P(Y|X). Discriminative models directly estimate P(Y|X). It is given the name because given X, we can directly discriminate (or determine) the value of the target Y. Generative models, on the other hand, estimate the joint probability P(Y, X) by finding P(X|Y) and P(Y). It is called generative because given the parameters P(X|Y) and P(Y), we can generate observable samples from the model.

Discriminative models include: logistic regression, conditional random fields, support vector machine
Generative models include: HMM, naive Bayes, Gaussian mixture models.

For solving a classification problem, a discriminative classifier is almost always preferred because discriminative models do not need to model the distribution of the observed variables, and they can generally express more complex relationships between the observed and target variables. However, Ng et al. also demonstrated in their experiments that generative methods may also converge more quickly to its (higher) asymptotic error as number of training examples increases. The generative model may also approach its asymptotic error with a number of training examples that is only logarithmic, rather than linear, in the number of parameters. This means that with smaller number of training examples, generative models may do better.

Sunday, 6 March 2011

Libraries needed for RoR development

For a RoR project that has a Gemfile, you can install all the required gems using the bundle command. You need to install bundler first. You may also install some other apps/libraries by using the following commands:
sudo apt-get install build-essential ruby1.8-dev
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
sudo apt-get install sqlite3 libsqlite3-dev
sudo gem update --system 
sudo gem install bundler

Saturday, 5 March 2011

Clutter

We made Clutter, a Chrome extension that allows you to view multiple websites in the same tab. You can find it in Google's webstore:  http://bit.ly/eBIPZW

We attended the Chrome hackathon on February 19 at HubSpot's office in Cambridge. Jan Kleinert from Google gave us a tutorial on Chrome extension and then we began the hacking.

We decided what extension to make before the hackathon. Victor came up with the idea and it was inspired by the small hack he did during the IAP. During our Battlecode hacking, he made a split-pane display to show three websites (Pandora, google doc, and IRC chat) in the same tab as a dashboard and projected it. This is especially useful for the Chrome notebook because all it has is a browser window, and you cannot have multiple windows.

The one he made was a static layout, what we added, in addition to making it a Chrome extension, is allowing adding and removing panes at whatever position you want. We won the hackathon in the end and Jan wrote a blog post about this event as well.

Friday, 4 March 2011

Command to remove all .svn folders

find ./ -name ".svn" | xargs rm -Rf
Explanations:
xargs is used to build and execute command lines from standard input. It breaks list of arguments into sublists small enough to be acceptable.

Monday, 28 February 2011

User Study

I'm reading a CHI paper recently and noticed some techniques and terminologies in it that may be useful for my future user studies.

Counterbalancing
Definition: a within-subjects design involves changing the order in which treatment conditions are administered from one participant to anther so that the treatment conditions are matched with respect to time. The goal is to use very possible order of treatments with an equal number of individuals participating in each sequence. The purpose of counterbalancing is to eliminate the potential for confounding by disrupting any systematic relationship between the order of treatments and time-related factors [1].

Sources:
1. Gravetter. F., and Forzano L.. Research Methods for the Behavioral Science. 259.

Sunday, 27 February 2011

祝爸爸生日快乐!

今天(苏州是昨天)是爸爸60岁大寿,我做了可爱的兔子,马和猪(我们一家三口,muhaha)还有寿桃为爸爸祝寿。马比较难做,只能发挥想像了。用牙签做的4条腿是Victor的主意,因为马的腿比兔子和猪要长的多,所以可以突出这点来区分他们。还是比较成功的,站得也挺稳。马的头上还有鬃毛,是木耳。

这是做生日快乐字样的模板,这比做latte art简单多了,不需要手上的技巧,但是也挺好看的。:)

爸爸妈妈自己也小小庆祝了一下,天梭的表是我送给爸爸的生日礼物,去年十一月回去的时候带回去的。


Sunday, 20 February 2011

CSS Layout: Positioning

Yesterday, during the Google Chrome Hackathon, I was trying to replace the text on a button with an image, for example, replacing "Go" in the button below with an arrow image.


I can certainly add a background image for the button, but the text will still be seen above the background. Due to the lack of time, I just deleted the text in the html file. However, I feel that replacing the text with an image is really a styling choice rather than semantic.

Today, I started to read the book "Pro CSS and HTML Design Patterns" to improve my css skills. It actually mentions about the Text Replacement design pattern in the first chapter. It requires the use of css layout positioning to achieve the effect.

First, a recap on the positioning models:
  • Position an element by setting position to something other than static.
  • Use left, right, top and bottom to change the default position.
  • You can use position: static to "unposition" an element.
position 
In flow 
Positioning
static
yes
according to the flow
relative 
ghost
relative to the flow position 
absolute 
no
offset from its nearest positioned ancestor     
fixed
no
screen coordinate space

Text Replacement

Replace "Go" with this image:

Result:


Method: (Taken from p209 of the book.)
HTML
 TEXT 
CSS
#UNIQUE-ID { 
  position:relative; 
  padding:0; 
  overflow:hidden;
  width:IMAGE_WIDTH;
  height:IMAGE_HEIGHT; 
}
#UNIQUE-ID span { 
  position:absolute; 
  left:0; 
  top:0; 
  margin:0;
  width:IMAGE_WIDTH;
  height:IMAGE_HEIGHT;
  background-image:url("FILE.EXT");
  background-repeat:no-repeat; 
}

Initially, when I was testing with this, I found that the Chrome browser includes the border width in the height and width of the content size. By inspecting the element, I found that box-sizing is set to border-box. By setting it back to content-box, it behaves normally.