Scala code (written for a data mining class)