Skip to content
A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines
Branch: master
Clone or download
Latest commit b209d19 Dec 28, 2017
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc The output of the sympy example `` was not Sep 1, 2016
examples lots - working to get lambdify working (need a custom printer) Aug 17, 2016
pyearth Fix deprecation warning. Aug 19, 2017
.gitattributes User versioneer for versioning Apr 16, 2017
.gitignore Added auto-examples to gitignore May 23, 2015
.travis.yml Attempt to fix travis build for python 3.4. Not sure why it isn't wor… Sep 28, 2016
CHANGES.txt First pages commit Jul 14, 2013
LICENSE.txt User versioneer for versioning Apr 16, 2017
Makefile add conda recipe Apr 16, 2016 Update Apr 17, 2017
setup.cfg Fix for pypi Dec 28, 2017

py-earth Build Status

A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines algorithm, in the style of scikit-learn. The py-earth package implements Multivariate Adaptive Regression Splines using Cython and provides an interface that is compatible with scikit-learn's Estimator, Predictor, Transformer, and Model interfaces. For more information about Multivariate Adaptive Regression Splines, see the references below.

Now With Missing Data Support!

The py-earth package now supports missingness in its predictors. Just set allow_missing=True when constructing an Earth object.

Requesting Feedback

If there are other features or improvements you'd like to see in py-earth, please send me an email or open or comment on an issue. In particular, please let me know if any of the following are important to you:

  1. Improved speed
  2. Exporting models to additional formats
  3. Support for shared memory multiprocessing during fitting
  4. Support for cyclic predictors (such as time of day)
  5. Better support for categorical predictors
  6. Better support for large data sets
  7. Iterative reweighting during fitting


Make sure you have numpy and scikit-learn installed. Then do the following:

git clone git://
cd py-earth
sudo python install


import numpy
from pyearth import Earth
from matplotlib import pyplot
#Create some fake data
m = 1000
n = 10
X = 80*numpy.random.uniform(size=(m,n)) - 40
y = numpy.abs(X[:,6] - 4.0) + 1*numpy.random.normal(size=m)
#Fit an Earth model
model = Earth(),y)
#Print the model
#Plot the model
y_hat = model.predict(X)
pyplot.title('Simple Earth Example')

Other Implementations

I am aware of the following implementations of Multivariate Adaptive Regression Splines:

  1. The R package earth (coded in C by Stephen Millborrow):
  2. The R package mda (coded in Fortran by Trevor Hastie and Robert Tibshirani):
  3. The Orange data mining library for Python (uses the C code from 1):
  4. The xtal package (uses Fortran code written in 1991 by Jerome Friedman):
  5. MARSplines by StatSoft:
  6. MARS by Salford Systems (also uses Friedman's code):
  7. ARESLab (written in Matlab by Gints Jekabsons):

The R package earth was most useful to me in understanding the algorithm, particularly because of Stephen Milborrow's thorough and easy to read vignette (


  1. Friedman, J. (1991). Multivariate adaptive regression splines. The annals of statistics, 19(1), 1–67.
  2. Stephen Milborrow. Derived from mda:mars by Trevor Hastie and Rob Tibshirani. (2012). earth: Multivariate Adaptive Regression Spline Models. R package version 3.2-3.
  3. Friedman, J. (1993). Fast MARS. Stanford University Department of Statistics, Technical Report No 110.
  4. Friedman, J. (1991). Estimating functions of mixed ordinal and categorical variables using adaptive splines. Stanford University Department of Statistics, Technical Report No 108.
  5. Stewart, G.W. Matrix Algorithms, Volume 1: Basic Decompositions. (1998). Society for Industrial and Applied Mathematics.
  6. Bjorck, A. Numerical Methods for Least Squares Problems. (1996). Society for Industrial and Applied Mathematics.
  7. Hastie, T., Tibshirani, R., & Friedman, J. The Elements of Statistical Learning (2nd Edition). (2009).
    Springer Series in Statistics
  8. Golub, G., & Van Loan, C. Matrix Computations (3rd Edition). (1996). Johns Hopkins University Press.

References 7, 2, 1, 3, and 4 contain discussions likely to be useful to users of py-earth. References 1, 2, 6, 5, 8, 3, and 4 were useful during the implementation process.

You can’t perform that action at this time.