spark1.1.0 Machine Learning Library (MLlib)

Machine Learning Library (MLlib)

MLlib is Spark’s scalable machine learning library consisting of common learning algorithms and utilities, including classification, regression, clustering, collaborative filtering, dimensionality reduction, as well as underlying optimization primitives, as outlined below:

MLlib is under active development. The APIs marked Experimental/DeveloperApi may change in future releases, and the migration guide below will explain all changes between releases.

Dependencies

MLlib uses the linear algebra package Breeze, which depends on netlib-java, and jblasnetlib-java and jblas depend on native Fortran routines. You need to install the gfortran runtime library if it is not already present on your nodes. MLlib will throw a linking error if it cannot detect these libraries automatically. Due to license issues, we do not include netlib-java’s native libraries in MLlib’s dependency set under default settings. If no native library is available at runtime, you will see a warning message. To use native libraries from netlib-java, please build Spark with -Pnetlib-lgpl or include com.github.fommil.netlib:all:1.1.2 as a dependency of your project. If you want to use optimized BLAS/LAPACK libraries such as OpenBLAS, please link its shared libraries to /usr/lib/libblas.so.3 and /usr/lib/liblapack.so.3, respectively. BLAS/LAPACK libraries on worker nodes should be built without multithreading.

To use MLlib in Python, you will need NumPy version 1.4 or newer.


Migration Guide

From 1.0 to 1.1

The only API changes in MLlib v1.1 are in DecisionTree, which continues to be an experimental API in MLlib 1.1:

  1. (Breaking change) The meaning of tree depth has been changed by 1 in order to match the implementations of trees in scikit-learn and inrpart. In MLlib v1.0, a depth-1 tree had 1 leaf node, and a depth-2 tree had 1 root node and 2 leaf nodes. In MLlib v1.1, a depth-0 tree has 1 leaf node, and a depth-1 tree has 1 root node and 2 leaf nodes. This depth is specified by the maxDepth parameter in Strategy or viaDecisionTree static trainClassifier and trainRegressor methods.

  2. (Non-breaking change) We recommend using the newly added trainClassifier and trainRegressor methods to build a DecisionTree, rather than using the old parameter class Strategy. These new training methods explicitly separate classification and regression, and they replace specialized parameter types with simple String types.

Examples of the new, recommended trainClassifier and trainRegressor are given in the Decision Trees Guide.

From 0.9 to 1.0

In MLlib v1.0, we support both dense and sparse input in a unified way, which introduces a few breaking changes. If your data is sparse, please store it in a sparse format instead of dense to take advantage of sparsity in both storage and computation. Details are described below.

We used to represent a feature vector by Array[Double], which is replaced by Vector in v1.0. Algorithms that used to accept RDD[Array[Double]]now take RDD[Vector]LabeledPoint is now a wrapper of (Double, Vector) instead of (Double, Array[Double]). Converting Array[Double] toVector is straightforward:

import org.apache.spark.mllib.linalg.{Vector, Vectors}

val array: Array[Double] = ... // a double array
val vector: Vector = Vectors.dense(array) // a dense vector

Vectors provides factory methods to create sparse vectors.

Note: Scala imports scala.collection.immutable.Vector by default, so you have to import org.apache.spark.mllib.linalg.Vector explicitly to use MLlib’s Vector.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值