引言
在学习Scala的过程中,我发现其在构建大规模分布式计算系统上有与生俱来的特质。其丰富的类型系统可以帮助编程设计提供很好的信息隐藏和抽象,其monoids和monads概念利用Scala高阶函数实现计算并行和数据处理流水线,其Actor系统帮助编写可伸缩性的应用程序,其实现特定领域语言的优势帮助开发用户很好克服不同语言的障碍。
虽然以上Scala优点说起来不会感同身受,但这可以作为我学习的一大动力,让我开始尝试编写并行机器学习系统。
在学习过程中,我主要参考《Scala for Machine Learning》一书和相关网上的资料。希望这些分享能帮助自己学习,也更好的服务有兴趣的读者。
为何使用Scala构建机器学习系统
抽象
Monoids和Monads是函数式编程的重要概念。
Monoids定义了在具有闭包性质(property of closure)的数据集上的二元操作op,恒等操作(identity operation)和结合性(associativity)。
下面是代码描述:
trait Monoid[T] {
def zero: T
def op(a: T, b: T): T