mars

mars: Pure Python Earth (Multivariate Adaptive Regression Splines)

CI Security Code Quality Documentation Code Coverage PyPI Python Version License

Overview

mars is a pure Python implementation of Multivariate Adaptive Regression Splines (MARS), also known as Earth. The goal is to provide an easy-to-install, scikit-learn compatible version without C/Cython dependencies.

MARS is a non-parametric regression technique that automatically models nonlinearities and interactions between variables. The method works by creating a piecewise linear model with basis functions that can capture non-linear relationships and interactions automatically.

Key Features

Motivation

mars was developed to address specific needs in health economic outcomes research, particularly in the analysis of complex health system reforms such as New Zealand’s Pae Ora (Healthy Futures) Act 2022. The analysis of such reforms is complicated by the presence of multiple confounding factors, including COVID-19 pandemic effects, systemic changes, and dozens of concurrent policy modifications.

Traditional approaches focusing solely on dates for intervention analysis were insufficient; instead, changepoint detection methods were required to identify significant shifts in health outcomes and utilization patterns. The MARS approach of auto-fitting knots and optimizing to a specific number of knots proved particularly useful for health economic analysis.

The journey toward mars began with the R implementation of MARS (“earth”), but the author’s primary workflow was in Python with scikit-learn. The existing Python implementation “py-earth” by Jason Friedman had limitations including Python 2 compatibility issues and difficulty integrating into automated machine learning tools. These practical challenges motivated the development of mars as a pure Python implementation maintaining full scikit-learn compatibility.

Health Economic Applications

mars is particularly valuable for health economic outcomes research where understanding complex relationships between health outcomes, costs, and utilization patterns is crucial. The automatic identification of non-linearities and interactions makes MARS particularly well-suited for health economic applications where:

Getting Started

For installation instructions, see the Installation page. For usage examples, see the Usage page.

Contributing

We welcome contributions to mars! Please see our contributing guidelines in the repository.

License

This project is licensed under the MIT License - see the LICENSE file for details.