layout: global title: “MLlib: Main Guide” displayTitle: “Machine Learning Library (MLlib) Guide” license: | Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
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:
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 spark.ml
package.
What are the implications?
spark.mllib
with bug fixes.Why is MLlib switching to the DataFrame-based API?
What is “Spark ML”?
org.apache.spark.ml
Scala package name used by the DataFrame-based API, and the “Spark ML Pipelines” term we used initially to emphasize the pipeline concept.Is MLlib deprecated?
MLlib uses linear algebra packages Breeze and dev.ludovic.netlib for optimised numerical processing[^1]. 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.
[^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.
The list below highlights some of the new features and enhancements added to MLlib in the 3.0
release of Spark:
Binarizer
(SPARK-23578), StringIndexer
(SPARK-11215), StopWordsRemover
(SPARK-29808) and PySpark QuantileDiscretizer
(SPARK-22796).MultilabelClassificationEvaluator
(SPARK-16692) and RankingEvaluator
(SPARK-28045) were added.DecisionTreeClassifier/Regressor
(SPARK-19591), RandomForestClassifier/Regressor
(SPARK-9478), GBTClassifier/Regressor
(SPARK-9612), MulticlassClassificationEvaluator
(SPARK-24101), RegressionEvaluator
(SPARK-24102), BinaryClassificationEvaluator
(SPARK-24103), BisectingKMeans
(SPARK-30351), KMeans
(SPARK-29967) and GaussianMixture
(SPARK-30102).PowerIterationClustering
was added (SPARK-19827).RobustScaler
transformer was added (SPARK-28399).Factorization Machines
classifier and regressor were added (SPARK-29224).predictRaw
is made public in all the Classification models. predictProbability
is made public in all the Classification models except LinearSVCModel
(SPARK-30358).The migration guide is now archived on this page.