mars-earth 1.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mars_earth-1.0.1/LICENSE +198 -0
- mars_earth-1.0.1/MANIFEST.in +1 -0
- mars_earth-1.0.1/PKG-INFO +240 -0
- mars_earth-1.0.1/README.md +174 -0
- mars_earth-1.0.1/mars_earth.egg-info/PKG-INFO +240 -0
- mars_earth-1.0.1/mars_earth.egg-info/SOURCES.txt +59 -0
- mars_earth-1.0.1/mars_earth.egg-info/dependency_links.txt +1 -0
- mars_earth-1.0.1/mars_earth.egg-info/entry_points.txt +2 -0
- mars_earth-1.0.1/mars_earth.egg-info/requires.txt +39 -0
- mars_earth-1.0.1/mars_earth.egg-info/top_level.txt +1 -0
- mars_earth-1.0.1/pymars/__init__.py +39 -0
- mars_earth-1.0.1/pymars/_basis.py +577 -0
- mars_earth-1.0.1/pymars/_categorical.py +61 -0
- mars_earth-1.0.1/pymars/_forward.py +603 -0
- mars_earth-1.0.1/pymars/_missing.py +192 -0
- mars_earth-1.0.1/pymars/_pruning.py +315 -0
- mars_earth-1.0.1/pymars/_record.py +112 -0
- mars_earth-1.0.1/pymars/_sklearn_compat.py +617 -0
- mars_earth-1.0.1/pymars/_util.py +121 -0
- mars_earth-1.0.1/pymars/cli.py +157 -0
- mars_earth-1.0.1/pymars/cv.py +15 -0
- mars_earth-1.0.1/pymars/demos/__init__.py +6 -0
- mars_earth-1.0.1/pymars/demos/advanced_example.py +138 -0
- mars_earth-1.0.1/pymars/demos/basic_classification_demo.py +51 -0
- mars_earth-1.0.1/pymars/demos/basic_regression_demo.py +50 -0
- mars_earth-1.0.1/pymars/earth.py +881 -0
- mars_earth-1.0.1/pymars/explain.py +316 -0
- mars_earth-1.0.1/pymars/glm.py +32 -0
- mars_earth-1.0.1/pymars/plot.py +22 -0
- mars_earth-1.0.1/pyproject.toml +299 -0
- mars_earth-1.0.1/setup.cfg +19 -0
- mars_earth-1.0.1/tests/test_basis.py +290 -0
- mars_earth-1.0.1/tests/test_benchmark.py +164 -0
- mars_earth-1.0.1/tests/test_categorical.py +89 -0
- mars_earth-1.0.1/tests/test_earth.py +732 -0
- mars_earth-1.0.1/tests/test_forward.py +920 -0
- mars_earth-1.0.1/tests/test_glm_and_cv.py +54 -0
- mars_earth-1.0.1/tests/test_property.py +126 -0
- mars_earth-1.0.1/tests/test_pruning.py +311 -0
- mars_earth-1.0.1/tests/test_sklearn_compat.py +368 -0
- mars_earth-1.0.1/tests/test_util.py +164 -0
mars_earth-1.0.1/LICENSE
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any nature whatsoever resulting
|
|
159
|
+
from Your use of this software, even if such Contributor has been
|
|
160
|
+
advised of the possibility of such damages.
|
|
161
|
+
|
|
162
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
163
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
164
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
165
|
+
or other liability obligations and/or rights consistent with this
|
|
166
|
+
License. However, in accepting such obligations, You may act only
|
|
167
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
168
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
169
|
+
defend, and hold each Contributor harmless for any liability
|
|
170
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
171
|
+
of your accepting any such warranty or additional liability.
|
|
172
|
+
|
|
173
|
+
END OF TERMS AND CONDITIONS
|
|
174
|
+
|
|
175
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
176
|
+
|
|
177
|
+
To apply the Apache License to your work, attach the following
|
|
178
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
179
|
+
replaced with your own identifying information. (Don't include
|
|
180
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
181
|
+
comment syntax for the file format. We also recommend that a
|
|
182
|
+
file or class name and description of purpose be included on the
|
|
183
|
+
same "printed page" as the copyright notice for easier
|
|
184
|
+
identification within third-party archives.
|
|
185
|
+
|
|
186
|
+
Copyright 2025 Dylan A Mordaunt
|
|
187
|
+
|
|
188
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
189
|
+
you may not use this file except in compliance with the License.
|
|
190
|
+
You may obtain a copy of the License at
|
|
191
|
+
|
|
192
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
193
|
+
|
|
194
|
+
Unless required by applicable law or agreed to in writing, software
|
|
195
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
196
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
197
|
+
See the License for the specific language governing permissions and
|
|
198
|
+
limitations under the License.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include README.md
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mars-earth
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: A Pure Python Implementation of Multivariate Adaptive Regression Splines
|
|
5
|
+
Author-email: Dylan A Mordaunt <dylan@mordaunt.dev>
|
|
6
|
+
Maintainer-email: Dylan A Mordaunt <dylan@mordaunt.dev>
|
|
7
|
+
License: Apache-2.0
|
|
8
|
+
Project-URL: Homepage, https://github.com/edithatogo/mars
|
|
9
|
+
Project-URL: Documentation, https://edithatogo.github.io/mars/
|
|
10
|
+
Project-URL: Repository, https://github.com/edithatogo/mars
|
|
11
|
+
Project-URL: Changelog, https://github.com/edithatogo/mars/blob/main/CHANGELOG.md
|
|
12
|
+
Project-URL: Bug Tracker, https://github.com/edithatogo/mars/issues
|
|
13
|
+
Keywords: mars,multivariate adaptive regression splines,machine learning,scikit-learn,regression,classification
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Science/Research
|
|
17
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
|
+
Requires-Python: >=3.9
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
License-File: LICENSE
|
|
30
|
+
Requires-Dist: numpy>=1.20.0
|
|
31
|
+
Requires-Dist: scikit-learn>=1.0.0
|
|
32
|
+
Requires-Dist: matplotlib>=3.4.0
|
|
33
|
+
Provides-Extra: pandas
|
|
34
|
+
Requires-Dist: pandas>=1.3.0; extra == "pandas"
|
|
35
|
+
Provides-Extra: cli
|
|
36
|
+
Requires-Dist: pandas>=1.3.0; extra == "cli"
|
|
37
|
+
Requires-Dist: click>=8.0.0; extra == "cli"
|
|
38
|
+
Requires-Dist: rich>=12.0.0; extra == "cli"
|
|
39
|
+
Provides-Extra: profiling
|
|
40
|
+
Requires-Dist: scalene>=1.5.0; extra == "profiling"
|
|
41
|
+
Requires-Dist: py-spy>=0.3.0; extra == "profiling"
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: uv>=0.1.0; extra == "dev"
|
|
44
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
46
|
+
Requires-Dist: pytest-xdist>=3.0.0; extra == "dev"
|
|
47
|
+
Requires-Dist: pytest-benchmark>=4.0.0; extra == "dev"
|
|
48
|
+
Requires-Dist: pytest-sugar>=0.9.0; extra == "dev"
|
|
49
|
+
Requires-Dist: hypothesis>=6.90.0; extra == "dev"
|
|
50
|
+
Requires-Dist: mutmut>=2.4.0; extra == "dev"
|
|
51
|
+
Requires-Dist: nbmake>=1.4.0; extra == "dev"
|
|
52
|
+
Requires-Dist: diff-cover>=8.0.0; extra == "dev"
|
|
53
|
+
Requires-Dist: ruff>=0.4.0; extra == "dev"
|
|
54
|
+
Requires-Dist: mypy>=1.8.0; extra == "dev"
|
|
55
|
+
Requires-Dist: pre-commit>=3.6.0; extra == "dev"
|
|
56
|
+
Requires-Dist: bandit>=1.7.6; extra == "dev"
|
|
57
|
+
Requires-Dist: safety>=2.4.0; extra == "dev"
|
|
58
|
+
Requires-Dist: mkdocs>=1.5.0; extra == "dev"
|
|
59
|
+
Requires-Dist: mkdocs-material>=9.5.0; extra == "dev"
|
|
60
|
+
Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "dev"
|
|
61
|
+
Requires-Dist: mike>=2.0.0; extra == "dev"
|
|
62
|
+
Requires-Dist: python-semantic-release>=9.0.0; extra == "dev"
|
|
63
|
+
Requires-Dist: pandas>=1.3.0; extra == "dev"
|
|
64
|
+
Requires-Dist: tox>=4.11.0; extra == "dev"
|
|
65
|
+
Dynamic: license-file
|
|
66
|
+
|
|
67
|
+
# mars: A Pure Python Implementation of Multivariate Adaptive Regression Splines (formerly pymars)
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+

|
|
71
|
+

|
|
72
|
+

|
|
73
|
+

|
|
74
|
+

|
|
75
|
+

|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
**mars** (formerly **pymars**) is a pure Python implementation of Multivariate Adaptive Regression Splines (MARS), inspired by the popular `py-earth` library by Jason Friedman and an R package `earth` by Stephen Milborrow. The goal of **mars** is to provide an easy-to-install, scikit-learn compatible version of the MARS algorithm without C/Cython dependencies.
|
|
79
|
+
|
|
80
|
+
## Documentation
|
|
81
|
+
|
|
82
|
+
Complete documentation is available at: [https://edithatogo.github.io/mars/](https://edithatogo.github.io/mars/) (once GitHub Pages is configured)
|
|
83
|
+
|
|
84
|
+
## Key Features
|
|
85
|
+
|
|
86
|
+
- **Pure Python:** Easy to install and use across different platforms.
|
|
87
|
+
- **Scikit-learn Compatible:** Integrates with the scikit-learn ecosystem (estimators, pipelines, model selection tools).
|
|
88
|
+
- **MARS Algorithm:** Implements the core MARS fitting procedure, including:
|
|
89
|
+
- Forward pass to select basis functions (both hinge and linear terms).
|
|
90
|
+
- Pruning pass using Generalized Cross-Validation (GCV) to prevent overfitting.
|
|
91
|
+
- Support for interaction terms (including interactions involving linear terms).
|
|
92
|
+
- Refined `minspan` and `endspan` controls for knot placement, aligning more closely with `py-earth` behavior (e.g., `minspan` as a cooldown period).
|
|
93
|
+
- **Feature Importance:** Calculation of feature importances using methods like 'nb_subsets' (number of subsets in pruning trace), 'gcv' (GCV improvement), and 'rss' (RSS reduction).
|
|
94
|
+
- **Regression and Classification:** Provides `EarthRegressor` and `EarthClassifier` classes.
|
|
95
|
+
- **Generalized Linear Models:** The `GLMEarth` subclass fits logistic or Poisson models.
|
|
96
|
+
- **Cross‑Validation Helper:** The `EarthCV` class integrates with scikit‑learn's model selection utilities.
|
|
97
|
+
- **Plotting Utilities:** Simple diagnostics built on `matplotlib`.
|
|
98
|
+
- **Advanced Interpretability:** Partial dependence plots, Individual Conditional Expectation (ICE) plots, and model explanation tools.
|
|
99
|
+
- **Comprehensive CLI:** Command-line interface for model fitting, prediction, and evaluation.
|
|
100
|
+
|
|
101
|
+
## Key Features
|
|
102
|
+
|
|
103
|
+
- **Pure Python:** Easy to install and use across different platforms.
|
|
104
|
+
- **Scikit-learn Compatible:** Integrates with the scikit-learn ecosystem (estimators, pipelines, model selection tools).
|
|
105
|
+
- **MARS Algorithm:** Implements the core MARS fitting procedure, including:
|
|
106
|
+
- Forward pass to select basis functions (both hinge and linear terms).
|
|
107
|
+
- Pruning pass using Generalized Cross-Validation (GCV) to prevent overfitting.
|
|
108
|
+
- Support for interaction terms (including interactions involving linear terms).
|
|
109
|
+
- Refined `minspan` and `endspan` controls for knot placement, aligning more closely with `py-earth` behavior (e.g., `minspan` as a cooldown period).
|
|
110
|
+
- **Feature Importance:** Calculation of feature importances using methods like 'nb_subsets' (number of subsets in pruning trace), 'gcv' (GCV improvement), and 'rss' (RSS reduction).
|
|
111
|
+
- **Regression and Classification:** Provides `EarthRegressor` and `EarthClassifier` classes.
|
|
112
|
+
- **Generalized Linear Models:** The `GLMEarth` subclass fits logistic or Poisson models.
|
|
113
|
+
- **Cross‑Validation Helper:** The `EarthCV` class integrates with scikit‑learn's model selection utilities.
|
|
114
|
+
- **Plotting Utilities:** Simple diagnostics built on `matplotlib`.
|
|
115
|
+
- **Advanced Interpretability:** Partial dependence plots, Individual Conditional Expectation (ICE) plots, and model explanation tools.
|
|
116
|
+
- **Comprehensive CLI:** Command-line interface for model fitting, prediction, and evaluation.
|
|
117
|
+
|
|
118
|
+
## Project Status
|
|
119
|
+
|
|
120
|
+
This project is currently in the initial development phase. The core algorithm and scikit-learn compatibility are being built. See `ROADMAP.md` and `TODO.md` for more details on the development plan and progress.
|
|
121
|
+
|
|
122
|
+
## Installation
|
|
123
|
+
|
|
124
|
+
**Note:** Install `mars` inside a Python virtual environment to silence `pip` warnings about running as root.
|
|
125
|
+
|
|
126
|
+
`mars` can be installed from TestPyPI:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pip install mars
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
To work with the latest source, clone the repository and install it in editable mode:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/edithatogo/mars.git
|
|
136
|
+
cd mars
|
|
137
|
+
pip install -e .
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
If you need to run scikit-learn's full estimator checks, install the optional
|
|
141
|
+
pandas dependency:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
pip install "mars[pandas]"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
After installation you can check the installed version:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
mars --version
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Running Tests
|
|
154
|
+
|
|
155
|
+
Install the dependencies listed in `requirements.txt` before running the test
|
|
156
|
+
suite. A small helper script is provided:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Option 1: directly with pip
|
|
160
|
+
pip install -r requirements.txt
|
|
161
|
+
|
|
162
|
+
# To run the full scikit-learn estimator checks, install the optional pandas
|
|
163
|
+
# dependency as well:
|
|
164
|
+
pip install "mars[pandas]"
|
|
165
|
+
|
|
166
|
+
# Option 2: using the helper script
|
|
167
|
+
bash scripts/setup_tests.sh
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
After the dependencies are installed, run the tests with:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
pytest
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Usage
|
|
178
|
+
|
|
179
|
+
### Quick demos
|
|
180
|
+
|
|
181
|
+
Run the included demo scripts to see `mars` in action:
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
python -m mars.demos.basic_regression_demo
|
|
185
|
+
python -m mars.demos.basic_classification_demo
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Basic API
|
|
189
|
+
|
|
190
|
+
```python
|
|
191
|
+
import numpy as np
|
|
192
|
+
import mars as earth
|
|
193
|
+
|
|
194
|
+
X = np.random.rand(100, 3)
|
|
195
|
+
y = np.sin(X[:, 0]) + X[:, 1]
|
|
196
|
+
|
|
197
|
+
model = earth.Earth(max_degree=1, penalty=3.0)
|
|
198
|
+
model.fit(X, y)
|
|
199
|
+
predictions = model.predict(X)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Documentation
|
|
203
|
+
|
|
204
|
+
The mars project uses a multi-branch documentation approach:
|
|
205
|
+
|
|
206
|
+
- **Code Documentation**: API and development documentation is available in the [docs branch](https://github.com/edithatogo/mars/tree/docs)
|
|
207
|
+
- **Research Paper**: The academic paper describing mars is available in the [paper branch](https://github.com/edithatogo/mars/tree/paper)
|
|
208
|
+
|
|
209
|
+
For usage examples and tutorials, check the [examples directory](examples/) in this main branch.
|
|
210
|
+
|
|
211
|
+
## Contributing
|
|
212
|
+
|
|
213
|
+
Contributions are welcome! Please see `CONTRIBUTING.md` and `AGENTS.md` for guidelines.
|
|
214
|
+
|
|
215
|
+
## Citing mars
|
|
216
|
+
|
|
217
|
+
If you use mars in your research, please cite it as follows:
|
|
218
|
+
|
|
219
|
+
```bibtex
|
|
220
|
+
@software{mars2026,
|
|
221
|
+
author = {Mordaunt, Dylan A.},
|
|
222
|
+
title = {mars: A Pure Python Implementation of Multivariate Adaptive Regression Splines},
|
|
223
|
+
year = {2026},
|
|
224
|
+
url = {https://github.com/edithatogo/mars},
|
|
225
|
+
version = {1.0.1},
|
|
226
|
+
license = {Apache-2.0},
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
A `CITATION.cff` file is also included in the repository for easy citation management.
|
|
231
|
+
|
|
232
|
+
## License
|
|
233
|
+
|
|
234
|
+
This project is licensed under the [Apache 2.0 License](LICENSE).
|
|
235
|
+
|
|
236
|
+
## Acknowledgements
|
|
237
|
+
|
|
238
|
+
- Based on the work of Jerome H. Friedman on MARS.
|
|
239
|
+
- Inspired by the `py-earth` library (scikit-learn-contrib).
|
|
240
|
+
- Inspired by the R `earth` package.
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# mars: A Pure Python Implementation of Multivariate Adaptive Regression Splines (formerly pymars)
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
**mars** (formerly **pymars**) is a pure Python implementation of Multivariate Adaptive Regression Splines (MARS), inspired by the popular `py-earth` library by Jason Friedman and an R package `earth` by Stephen Milborrow. The goal of **mars** is to provide an easy-to-install, scikit-learn compatible version of the MARS algorithm without C/Cython dependencies.
|
|
13
|
+
|
|
14
|
+
## Documentation
|
|
15
|
+
|
|
16
|
+
Complete documentation is available at: [https://edithatogo.github.io/mars/](https://edithatogo.github.io/mars/) (once GitHub Pages is configured)
|
|
17
|
+
|
|
18
|
+
## Key Features
|
|
19
|
+
|
|
20
|
+
- **Pure Python:** Easy to install and use across different platforms.
|
|
21
|
+
- **Scikit-learn Compatible:** Integrates with the scikit-learn ecosystem (estimators, pipelines, model selection tools).
|
|
22
|
+
- **MARS Algorithm:** Implements the core MARS fitting procedure, including:
|
|
23
|
+
- Forward pass to select basis functions (both hinge and linear terms).
|
|
24
|
+
- Pruning pass using Generalized Cross-Validation (GCV) to prevent overfitting.
|
|
25
|
+
- Support for interaction terms (including interactions involving linear terms).
|
|
26
|
+
- Refined `minspan` and `endspan` controls for knot placement, aligning more closely with `py-earth` behavior (e.g., `minspan` as a cooldown period).
|
|
27
|
+
- **Feature Importance:** Calculation of feature importances using methods like 'nb_subsets' (number of subsets in pruning trace), 'gcv' (GCV improvement), and 'rss' (RSS reduction).
|
|
28
|
+
- **Regression and Classification:** Provides `EarthRegressor` and `EarthClassifier` classes.
|
|
29
|
+
- **Generalized Linear Models:** The `GLMEarth` subclass fits logistic or Poisson models.
|
|
30
|
+
- **Cross‑Validation Helper:** The `EarthCV` class integrates with scikit‑learn's model selection utilities.
|
|
31
|
+
- **Plotting Utilities:** Simple diagnostics built on `matplotlib`.
|
|
32
|
+
- **Advanced Interpretability:** Partial dependence plots, Individual Conditional Expectation (ICE) plots, and model explanation tools.
|
|
33
|
+
- **Comprehensive CLI:** Command-line interface for model fitting, prediction, and evaluation.
|
|
34
|
+
|
|
35
|
+
## Key Features
|
|
36
|
+
|
|
37
|
+
- **Pure Python:** Easy to install and use across different platforms.
|
|
38
|
+
- **Scikit-learn Compatible:** Integrates with the scikit-learn ecosystem (estimators, pipelines, model selection tools).
|
|
39
|
+
- **MARS Algorithm:** Implements the core MARS fitting procedure, including:
|
|
40
|
+
- Forward pass to select basis functions (both hinge and linear terms).
|
|
41
|
+
- Pruning pass using Generalized Cross-Validation (GCV) to prevent overfitting.
|
|
42
|
+
- Support for interaction terms (including interactions involving linear terms).
|
|
43
|
+
- Refined `minspan` and `endspan` controls for knot placement, aligning more closely with `py-earth` behavior (e.g., `minspan` as a cooldown period).
|
|
44
|
+
- **Feature Importance:** Calculation of feature importances using methods like 'nb_subsets' (number of subsets in pruning trace), 'gcv' (GCV improvement), and 'rss' (RSS reduction).
|
|
45
|
+
- **Regression and Classification:** Provides `EarthRegressor` and `EarthClassifier` classes.
|
|
46
|
+
- **Generalized Linear Models:** The `GLMEarth` subclass fits logistic or Poisson models.
|
|
47
|
+
- **Cross‑Validation Helper:** The `EarthCV` class integrates with scikit‑learn's model selection utilities.
|
|
48
|
+
- **Plotting Utilities:** Simple diagnostics built on `matplotlib`.
|
|
49
|
+
- **Advanced Interpretability:** Partial dependence plots, Individual Conditional Expectation (ICE) plots, and model explanation tools.
|
|
50
|
+
- **Comprehensive CLI:** Command-line interface for model fitting, prediction, and evaluation.
|
|
51
|
+
|
|
52
|
+
## Project Status
|
|
53
|
+
|
|
54
|
+
This project is currently in the initial development phase. The core algorithm and scikit-learn compatibility are being built. See `ROADMAP.md` and `TODO.md` for more details on the development plan and progress.
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
**Note:** Install `mars` inside a Python virtual environment to silence `pip` warnings about running as root.
|
|
59
|
+
|
|
60
|
+
`mars` can be installed from TestPyPI:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pip install mars
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
To work with the latest source, clone the repository and install it in editable mode:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
git clone https://github.com/edithatogo/mars.git
|
|
70
|
+
cd mars
|
|
71
|
+
pip install -e .
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
If you need to run scikit-learn's full estimator checks, install the optional
|
|
75
|
+
pandas dependency:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install "mars[pandas]"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
After installation you can check the installed version:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mars --version
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Running Tests
|
|
88
|
+
|
|
89
|
+
Install the dependencies listed in `requirements.txt` before running the test
|
|
90
|
+
suite. A small helper script is provided:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# Option 1: directly with pip
|
|
94
|
+
pip install -r requirements.txt
|
|
95
|
+
|
|
96
|
+
# To run the full scikit-learn estimator checks, install the optional pandas
|
|
97
|
+
# dependency as well:
|
|
98
|
+
pip install "mars[pandas]"
|
|
99
|
+
|
|
100
|
+
# Option 2: using the helper script
|
|
101
|
+
bash scripts/setup_tests.sh
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
After the dependencies are installed, run the tests with:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
pytest
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Usage
|
|
112
|
+
|
|
113
|
+
### Quick demos
|
|
114
|
+
|
|
115
|
+
Run the included demo scripts to see `mars` in action:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
python -m mars.demos.basic_regression_demo
|
|
119
|
+
python -m mars.demos.basic_classification_demo
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Basic API
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
import numpy as np
|
|
126
|
+
import mars as earth
|
|
127
|
+
|
|
128
|
+
X = np.random.rand(100, 3)
|
|
129
|
+
y = np.sin(X[:, 0]) + X[:, 1]
|
|
130
|
+
|
|
131
|
+
model = earth.Earth(max_degree=1, penalty=3.0)
|
|
132
|
+
model.fit(X, y)
|
|
133
|
+
predictions = model.predict(X)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Documentation
|
|
137
|
+
|
|
138
|
+
The mars project uses a multi-branch documentation approach:
|
|
139
|
+
|
|
140
|
+
- **Code Documentation**: API and development documentation is available in the [docs branch](https://github.com/edithatogo/mars/tree/docs)
|
|
141
|
+
- **Research Paper**: The academic paper describing mars is available in the [paper branch](https://github.com/edithatogo/mars/tree/paper)
|
|
142
|
+
|
|
143
|
+
For usage examples and tutorials, check the [examples directory](examples/) in this main branch.
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
Contributions are welcome! Please see `CONTRIBUTING.md` and `AGENTS.md` for guidelines.
|
|
148
|
+
|
|
149
|
+
## Citing mars
|
|
150
|
+
|
|
151
|
+
If you use mars in your research, please cite it as follows:
|
|
152
|
+
|
|
153
|
+
```bibtex
|
|
154
|
+
@software{mars2026,
|
|
155
|
+
author = {Mordaunt, Dylan A.},
|
|
156
|
+
title = {mars: A Pure Python Implementation of Multivariate Adaptive Regression Splines},
|
|
157
|
+
year = {2026},
|
|
158
|
+
url = {https://github.com/edithatogo/mars},
|
|
159
|
+
version = {1.0.1},
|
|
160
|
+
license = {Apache-2.0},
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
A `CITATION.cff` file is also included in the repository for easy citation management.
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
This project is licensed under the [Apache 2.0 License](LICENSE).
|
|
169
|
+
|
|
170
|
+
## Acknowledgements
|
|
171
|
+
|
|
172
|
+
- Based on the work of Jerome H. Friedman on MARS.
|
|
173
|
+
- Inspired by the `py-earth` library (scikit-learn-contrib).
|
|
174
|
+
- Inspired by the R `earth` package.
|