spark.mllib (RDD-based API)
| Developer | Apache Software Foundation (Apache Spark project) |
|---|---|
| Initial release | Spark 0.8.0 (as MLlib) |
| Latest release | Spark 4.3.0 (2026-10-30) |
| Written in | Scala, with Python and Java APIs |
| Type | Machine learning API (RDD-based) |
| License | Apache License 2.0 |
| Website | MLlib: RDD-based API guide |
| Repository | github.com/apache/spark (mllib/.../mllib) |
| Related | MLlib, RDD, Spark Connect |
spark.ml API of MLlib instead. Only bug fixes are accepted. The package as a whole is not deprecated in any release up to 4.3.0 and is still included.[1][2]spark.mllib is the original, RDD-based API of MLlib, the machine learning library of Apache Spark, found in the org.apache.spark.mllib package in Scala and Java and pyspark.mllib in Python.[3] Since Spark 2.0 it has been in maintenance mode: it receives bug fixes but no new features, and the DataFrame-based spark.ml package is the primary machine learning API.[1][2] The MLlib guide states that neither API is deprecated; spark.mllib is still part of Spark 4.3.0, but it cannot be used from a Spark Connect client.[1][4]
Status
Is spark.mllib deprecated? No, as a package it is in maintenance mode, not deprecated.
- Maintenance mode since 2.0. The Spark 2.0.0 release notes say the DataFrame-based API became the primary API and the RDD-based API entered maintenance mode.[2] The MLlib guide at v4.3.0 says that MLlib still supports the RDD-based API with bug fixes and will not add new features to it.[1] The Python package docstring says the same for
pyspark.mllib.[5] - Planned removal that did not happen. The MLlib guide in Spark 2.0.0 through 2.4.0 said the RDD-based API was "expected to be removed in Spark 3.0".[6] The guide update for the 3.0 release removed that sentence, and the package was not removed. The package's Scala documentation at v4.3.0 still says the package "will be deprecated" once the DataFrame-based API reaches feature parity, while the MLlib guide says that parity was reached in the Spark 2.x releases; no release has deprecated it.[7][1][8]
- Individual APIs deprecated and removed. Some classes and methods in the package were deprecated and later removed. Spark 3.0 removed, among others, the Scala classes
LogisticRegressionWithSGD,LinearRegressionWithSGD,LassoWithSGDandRidgeRegressionWithSGD(deprecated in 2.0), and therunsparameter ofKMeans.train(deprecated in 2.1).[9] For the SGD classes, removal meant the public API: at v4.3.0 the Scala classes remain with constructors private to themllibpackage, used by the PySpark wrappers.[10] Those PySpark wrappers are still public in 4.3.0, marked deprecated since 2.0.0, and emit aFutureWarning.[11] - No Spark Connect. The Spark Connect documentation lists RDD and
SparkContextas unsupported, so spark.mllib code needs a classic Spark application.[4] The DataFrame-basedpyspark.mlAPI works on Spark Connect from Spark 4.0.0.[12]
What the package contains
The RDD-based guide at v4.3.0 covers data types (local vectors and matrices, LabeledPoint, distributed matrices), basic statistics, linear models, naive Bayes, decision trees and tree ensembles, isotonic regression, alternating least squares, clustering (including streaming k-means), dimensionality reduction (SVD and PCA), feature extraction, frequent pattern mining (FP-growth, association rules, PrefixSpan), evaluation metrics, PMML model export and low-level optimization (SGD and L-BFGS).[3] Export to the Predictive Model Markup Language (PMML) is documented for spark.mllib models.[13]
spark.mllib compared with spark.ml
| spark.mllib | spark.ml | |
|---|---|---|
| Input | RDD of LabeledPoint or vectors
|
DataFrame with a vector column |
| Training call | Static train methods on algorithm objects
|
Estimator.fit, usually inside a Pipeline
|
| Vector type | org.apache.spark.mllib.linalg.Vector
|
org.apache.spark.ml.linalg.Vector
|
| New features | None (maintenance mode) | Yes |
| Spark Connect | Not supported | Supported from Spark 4.0.0 (Python) |
The two vector types are separate since Spark 2.0; the RDD-based API still depends on spark.mllib.linalg. To move data between them, the migration guide points to asML on an mllib vector or matrix, Vectors.fromML and Matrices.fromML, and the column converters in MLUtils.[9]
Migrating to spark.ml
The Spark 3.0 entries in the migration guide name replacements for the removed classes: for example, org.apache.spark.ml.classification.LogisticRegression (or LogisticRegressionWithLBFGS) instead of LogisticRegressionWithSGD, and org.apache.spark.ml.regression.LinearRegression with elasticNetParam set to 1.0 instead of LassoWithSGD. The guide notes that default regularization differs: regParam was 0.01 for LassoWithSGD and RidgeRegressionWithSGD, but is 0.0 for LinearRegression.[9]
Example
The same logistic regression in both APIs, in a classic PySpark session where spark is the SparkSession:
# spark.mllib (RDD-based): classic mode only
from pyspark.mllib.classification import LogisticRegressionWithLBFGS
from pyspark.mllib.regression import LabeledPoint
rdd = spark.sparkContext.parallelize([
LabeledPoint(0.0, [1.1, 0.1]), LabeledPoint(1.0, [2.0, 1.0]),
LabeledPoint(0.0, [1.3, -0.5]), LabeledPoint(1.0, [2.2, 1.5])])
old_model = LogisticRegressionWithLBFGS.train(rdd, iterations=10)
# spark.ml (DataFrame-based): also runs on Spark Connect from 4.0.0
from pyspark.ml.classification import LogisticRegression
from pyspark.ml.linalg import Vectors
df = spark.createDataFrame([
(0.0, Vectors.dense(1.1, 0.1)), (1.0, Vectors.dense(2.0, 1.0)),
(0.0, Vectors.dense(1.3, -0.5)), (1.0, Vectors.dense(2.2, 1.5))],
["label", "features"])
new_model = LogisticRegression(maxIter=10).fit(df)
See also
References
- ↑ 1.0 1.1 1.2 1.3 1.4 MLlib: Main Guide (docs/ml-guide.md at v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 2.0 2.1 2.2 Spark Release 2.0.0. Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 3.0 3.1 MLlib: RDD-based API (docs/mllib-guide.md at v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ 4.0 4.1 Spark Connect Overview (Spark 4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ python/pyspark/mllib/__init__.py (v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ MLlib: Main Guide (docs/ml-guide.md at v2.4.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ mllib/package.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ SPARK-30934: ML, GraphX 3.0 QA: Programming guide update and migration guide. Apache Software Foundation JIRA.Retrieved 2026-11-22.
- ↑ 9.0 9.1 9.2 Migration Guide: MLlib (docs/ml-migration-guide.md at v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ PythonMLLibAPI.scala (v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ python/pyspark/mllib/classification.py (v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.
- ↑ SPARK-50812: Support pyspark.ml on Connect. Apache Software Foundation JIRA.Retrieved 2026-11-22.
- ↑ PMML model export (docs/mllib-pmml-model-export.md at v4.3.0). Apache Software Foundation.Retrieved 2026-11-22.