Machine Learning Library (MLlib) Guide

MLlib is Spark’s machine learning (ML) library. Its goal is to make practical machine learning scalable and easy. At a high level, it provides tools such as:

Announcement: DataFrame-based API is primary API

The MLlib RDD-based API is now in maintenance mode.

As of Spark 2.0, the RDD-based APIs in the spark.mllib package have entered maintenance mode. The primary Machine Learning API for Spark is now the DataFrame-based API in the package.

What are the implications?

Why is MLlib switching to the DataFrame-based API?

What is “Spark ML”?

Is MLlib deprecated?


MLlib uses linear algebra packages Breeze and dev.ludovic.netlib for optimised numerical processing1. Those packages may call native acceleration libraries such as Intel MKL or OpenBLAS if they are available as system libraries or in runtime library paths.

However, native acceleration libraries can’t be distributed with Spark. See MLlib Linear Algebra Acceleration Guide for how to enable accelerated linear algebra processing. If accelerated native libraries are not enabled, you will see a warning message like below and a pure JVM implementation will be used instead:

WARNING: Failed to load implementation from:dev.ludovic.netlib.blas.JNIBLAS

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

Highlights in 3.0

The list below highlights some of the new features and enhancements added to MLlib in the 3.0 release of Spark:

Migration Guide

The migration guide is now archived on this page.

  1. 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