在OCaml或Haskell中进行机器学习? [英] Machine learning in OCaml or Haskell?

查看:194
本文介绍了在OCaml或Haskell中进行机器学习?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在一个新项目上使用Haskell或OCaml,因为R太慢了。我需要能够使用支持矢量机器,理想地分离每个执行并行运行。我想用一种功能性语言,我觉得这两种方式在性能和优雅方面都是最好的(我喜欢Clojure,但在短期测试中速度并不快)。我倾向于OCaml,因为似乎有更多的支持与其他语言的集成,所以从长远来看它可能更适合(例如

有人知道这种分析的好教程,或者是代码示例, Haskell或OCaml?

Hal Daume 在博士期间已经写了几种主要的机器学习算法。 (现在他是机器学习社区的助理教授和后起之秀)

在他的网页上,有一个SVM,一个简单的决策树和一个逻辑回归OCaml的。通过阅读这些代码,您可以感受到OCaml如何实现机器学习模型。



我还想提及F#,一种类似于OCaml的新.Net语言。以下是因素图模型 F#分析国际象棋比赛数据。这项研究还有一份NIPS出版物。

虽然FP适用于实现机器学习和数据挖掘模型。但是,你可以在这里得到的最不是性能。 FP支持并行计算比命令式语言更好,比如C#或Java。但是实施并行支持向量机或决策树与语言无关!平行是平行的。机器学习和数据挖掘背后的数值优化通常是必不可少的,纯粹功能性地编写它们通常很困难而且效率较低。使这些复杂的算法并行在算法级别是非常困难的任务,而不是在语言级别。如果你想并行运行100个SVM,FP在这里有帮助。但我没有看到在C ++中运行100个libsvm并行的困难,而不是认为单线程libsvm比未经过良好测试的haskell svm包更有效。

那么FP语言,如F#,OCaml,Haskell会给出什么?


  1. 轻松测试您的代码。 FP语言通常具有顶级解释器,您可以即时测试您的功能。

  2. 几乎没有可变的状态。这意味着将相同的参数传递给一个函数,这个函数总是给出相同的结果,因此调试在FP中很容易。
  3. 代码是简洁的。类型推理,模式匹配,闭包等。您更关注领域逻辑,更少关注语言部分。所以当你编写代码时,你的思想主要是想着编程逻辑本身。


  4. 在FP中编写代码很有趣。

    I'm hoping to use either Haskell or OCaml on a new project because R is too slow. I need to be able to use support vectory machines, ideally separating out each execution to run in parallel. I want to use a functional language and I have the feeling that these two are the best so far as performance and elegance are concerned (I like Clojure, but it wasn't as fast in a short test). I am leaning towards OCaml because there appears to be more support for integration with other languages so it could be a better fit in the long run (e.g. OCaml-R).

    Does anyone know of a good tutorial for this kind of analysis, or a code example, in either Haskell or OCaml?

    解决方案

    Hal Daume has written several major machine learning algorithms during his Ph.D. (now he is an assistant professor and rising star in machine learning community)

    On his web page, there are a SVM, a simple decision tree and a logistic regression all in OCaml. By reading these code, you can have a feeling how machine learning models are implemented in OCaml.

    I'd also like to mention F#, a new .Net language similar to OCaml. Here's a factor graph model written in F# analyzing Chess play data. This research also has a NIPS publication.

    While FP is suitable for implementing machine learning and data mining models. But what you can get here most is NOT performance. It is right that FP supports parallel computing better than imperative languages, like C# or Java. But implementing a parallel SVM, or decision tree, has very little relation to do with the language! Parallel is parallel. The numerical optimizations behind machine learning and data mining are usually imperative, writing them pure-functionally is usually hard and less efficient. Making these sophisticated algorithms parallel is very hard task in the algorithm level, not in the language level. If you want to run 100 SVM in parallel, FP helps here. But I don't see the difficulty running 100 libsvm parallel in C++, not to consider that the single thread libsvm is more efficient than a not-well-tested haskell svm package.

    Then what do FP languages, like F#, OCaml, Haskell, give?

    1. Easy to test your code. FP languages usually have a top-level interpreter, you can test your functions on the fly.

    2. Few mutable states. This means that passing the same parameter to a function, this function always gives the same result, thus debugging is easy in FPs.

    3. Code is succinct. Type inference, pattern matching, closures, etc. You focus more on the domain logic, and less on the language part. So when you write the code, your mind is mainly thinking about the programming logic itself.

    4. Writing code in FPs is fun.

    这篇关于在OCaml或Haskell中进行机器学习?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆