Data Quality – Here Come The Outliers

[Reading time: 5mn]

We’re at a point where playing with our first outlier detection functions become interesting: it start generating ideas. This is mainly due to the fact that we have used Clojure to do these experiments.

As a functional programming language, Clojure puts functions first, allows for abstraction through composition and offers a dynamic and fun approach to developing using a REPL.
I know, it’s Lispy – and this is precisely the point. Code as data (or is it the reverse), and laziness (meaning lazy evaluation) provides tremendous opportunities when it comes to data analytics and data quality investigations.

Continue reading “Data Quality – Here Come The Outliers”

Rails – How to sort a model on a virtual attribute

[Reading time: 2mn]

Setting
Ruby 1.9.2-p180
Rails 3.0.4

The Problem
So you have a Product model with a couple of virtual attributes like user rating which depends on some clever calculation. It is declared as an instance def in the model, a.k.a: a virtual attribute (ps: remember that class defs – e.g.: def self.do_something – apply to the records as a whole, whereas instance defs – e.g.: def do_something – apply to the current record). But I digress.
Actually you want to sort the products on this user rating but you know that scopes only work at the database level.

Continue reading “Rails – How to sort a model on a virtual attribute”