Machine Learning Library (MLlib) Guide

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. Guides for individual algorithms are listed below.

The API is divided into 2 parts:

We list major functionality from both below, with links to detailed guides.

MLlib types, algorithms and utilities

This lists functionality included in spark.mllib, the main MLlib API.

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. high-level APIs for ML pipelines

Spark 1.2 introduced a new package called, which aims to provide a uniform set of high-level APIs that help users create and tune practical machine learning pipelines.

Graduated from Alpha! The Pipelines API is no longer an alpha component, although many elements of it are still Experimental or DeveloperApi.

Note that we will keep supporting and adding features to spark.mllib along with the development of Users should be comfortable using spark.mllib features and expect more features coming. Developers should contribute new algorithms to spark.mllib and can optionally contribute to

More detailed guides for include:


MLlib uses the linear algebra package Breeze, which depends on netlib-java for optimised numerical processing. If natives are not available at runtime, you will see a warning message and a pure JVM implementation will be used instead.

To learn more about the benefits and background of system optimised natives, you may wish to watch Sam Halliday’s ScalaX talk on High Performance Linear Algebra in Scala).

Due to licensing issues with runtime proprietary binaries, we do not include netlib-java’s native proxies by default. To configure netlib-java / Breeze to use system optimised binaries, include com.github.fommil.netlib:all:1.1.2 (or build Spark with -Pnetlib-lgpl) as a dependency of your project and read the netlib-java documentation for your platform’s additional installation instructions.

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

Migration Guide

For the package, please see the Migration Guide.

From 1.3 to 1.4

In the spark.mllib package, there were several breaking changes, but all in DeveloperApi or Experimental APIs:

Previous Spark Versions

Earlier migration guides are archived on this page.