The Meta-Algorithm

Little background intro

The Bayesian filters, decision trees, neural networks, genetic algorithms, support vector machine are Algorithms that all work by reading data (that comes in 2 parts: input and result) and figures out a formula ( f(x) ). This formula, when is given the input can calculate the result. See figure 1.

Figure 1

All these algorithms originate from different fields, like artificial intelligence, math, databases, general computer science, and they are even influenced by biology(genetic algorithms) or even how the brain works(neural algorithms), so happens that from times to times there's some new ideas and progress, means also there's some room to grow and explore.

Example Applications:

The filters on your email. Suppose that one day you get in your inbox an email that offers to see some "magic pills" (input part) so you identify it as being spam(result part), the filter learns(builds the formula), so next time same style of email arrives in your inbox, the filter is able to identify it as spam.

Another common use is to identify fraud, these algorithms will look into past details(input part) of committed frauds(result part), learn from them(build the formula) and next time they can help in predicting fraud.

And final example application is to help avoid churn(customers leaving your service), works by looking at the characteristics(input part) of the customers that already churned(result part) and figure out a formula that predicts users with higher probability of churning. So you can run this formula over your current customers base to get aware of the ones that might be churning soon so you can act on it, to try avoid the churn.


The meta-algorithm

Now notice that all these Algorithms output a formula( f(x) ), which is essentially also an algorithm, both are a series of ordered instructions to perform a task. So extending this idea, why can't we have a meta-algorithm that outputs the algorithm?

Note that the current Algorithm job is to figure out the formula that given the input will output the result, so, using the same reasoning, the meta-algorithm job is to figure out an Algorithm that given the input and result will output the formula( f(x) ). See figure 2.

The Story of Stuff



"Externalized costs of production: you don't pay the real value of the thing..."

"Loads of waste..."

Estonian Wildlife Live Stream

See here and look for links that say striim.

I know of these 2:
  • Wild Pig: mms://tv.eenet.ee/siga
  • Eagles: mms://tv.eenet.ee/kotkas
Maybe cameras won't stay for long... but see these pictures my Dad made just yesterday:

AST, Javascript and the logging framework

Was recently looking to the ruby abstract syntax tree capabilities, after seeing this. The AST's is a tree representation of the structure of source code, normally created by the compiler/interpreter, as an intermediate step of executing your code. Having access to this allows you to do some heavy transformations, that normally the default language does not allow. So much power comes with a price, the language safety sandboxes go away, so handle with care.

When looking at this I found that Javascript, the super widespread browser language, also has couple capabilities in this field, directly from the the core language.

Specifically with the:
- toString() - creates a string with the body of a method (except the ones defined natively in C on the browser)
- eval(); - executes the code passed as a string.

Try in the Firebug console:


var one = function()
{
/* some logic */
return 1;
}

/* the function code */
console.log(one.toString());
// > "function () { return 1; }"

/* get the code of method and update it, adding a log message to top */
eval("var one = "+ one.toString().replace("{", "{ console.log(\"method one called\");"));

one();
// > method one called



See that the method "one" got re-defined with the eval, and we added a "console.log()" for debugging purposes. This can be useful to add debugging code without having to edit the original code.


Extending this idea, imagine a logging framework where instead of having your code explicitly calling logging methods from within your code, thus having your code sprinkled everywhere with alien logging code like it is usual, this framework would know how to attach itself onto your code and do the logging by itself.

And this is useful for all languages not only for Javascript.

Sending emails with Ruby using Gmail

I was looking for this some time ago, so posting here in case someone else finds it useful also.
I use it normally as an alert sender for automation's scripts.


Works naturally with regular ruby(1.8), but apparently also works with JRuby.

Depends on openssl gem. See at the end of code for command line commands to install it.

Code:

JRuby, Rails and Clojure

Found this funny comment at the end of a tutorial for JRuby + Rails + Clojure:

"If you’ve made it this far, congratulations! You’ve now combined an hugely practical webframework(RAILS) with a incredibly powerful language(LISP) running in the same enterprise-proof super-fast VM (JVM). The world lies at your feet."

The fun world of the Abstract Syntax Tree

Another nice post from igvita.com, this time on playing with the ruby AST tools.

Ever wanted to build a Ruby to Lolcode translator? (example)

re-Painting Mona Lisa

genetic algorithms re-painting pictures

The goal is to get an image represented as a collection of overlapping polygons of various colors and transparencies.
We start from random 50 polygons that are invisible. In each optimization step we randomly modify one parameter (like color components or polygon vertices) and check whether such new variant looks more like the original image. If it is, we keep it, and continue to mutate this one instead.

Fitness is a sum of pixel-by-pixel differences from the original image. Lower number is better.

Every check has a cost

Talks about the price of overdoingn procedures and processes in big company's.

Paul Graham: The Other Half of "Artists Ship"

Gotta to Keep It Simple!

Textmate

10 Productivity Tips