Steve Jenson's blog

Weighted Slope One in Scala

Weighted Slope One in Scala

Here's a basic procedural version of Weighted Slope One in Scala. It's pretty much a direct port of the Python version. It's about 15 lines longer due to curly braces and Map syntax in Scala not having a few niceties that Python dictionaries have.

Next I'm going to convert it to take advantage of Scala's powerful functional abilities. I'm going to take a stab to see if it lends itself to being a map and reduce. If that fails, I will fall back to good 'ol fold. The goal will be for those for-comprehensions to vanish and reveal an algorithm that's more parallelizable and then to run it on multiple cpus.

# — 15 August, 2007