modelmatrix 0.1.0__py3-none-any.whl
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.
- modelmatrix/__init__.py +26 -0
- modelmatrix/_version.py +24 -0
- modelmatrix/columns.py +324 -0
- modelmatrix/model_spec.py +1710 -0
- modelmatrix/transforms.py +695 -0
- modelmatrix-0.1.0.dist-info/METADATA +72 -0
- modelmatrix-0.1.0.dist-info/RECORD +10 -0
- modelmatrix-0.1.0.dist-info/WHEEL +5 -0
- modelmatrix-0.1.0.dist-info/licenses/LICENSE +27 -0
- modelmatrix-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelmatrix
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Model matrices from tabular data, as scikit-learn transformers
|
|
5
|
+
Author-email: Jonathan Taylor <jonathan.taylor@stanford.edu>
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/intro-stat-learning/modelmatrix
|
|
8
|
+
Project-URL: Documentation, https://intro-stat-learning.github.io/modelmatrix
|
|
9
|
+
Project-URL: Changelog, https://github.com/intro-stat-learning/modelmatrix/blob/main/CHANGELOG.md
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Topic :: Scientific/Engineering
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: numpy>=1.7.1
|
|
17
|
+
Requires-Dist: pandas>=1.5
|
|
18
|
+
Requires-Dist: scipy>=0.9
|
|
19
|
+
Requires-Dist: scikit-learn>=1.2
|
|
20
|
+
Requires-Dist: narwhals>=1.26
|
|
21
|
+
Requires-Dist: joblib
|
|
22
|
+
Provides-Extra: doc
|
|
23
|
+
Requires-Dist: jupyter-book<3,>=2; extra == "doc"
|
|
24
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
25
|
+
Requires-Dist: sphinx-book-theme; extra == "doc"
|
|
26
|
+
Requires-Dist: statsmodels; extra == "doc"
|
|
27
|
+
Requires-Dist: patsy; extra == "doc"
|
|
28
|
+
Requires-Dist: formulaic; extra == "doc"
|
|
29
|
+
Requires-Dist: polars; extra == "doc"
|
|
30
|
+
Requires-Dist: rpy2; extra == "doc"
|
|
31
|
+
Requires-Dist: jupytext; extra == "doc"
|
|
32
|
+
Dynamic: license-file
|
|
33
|
+
|
|
34
|
+
# modelmatrix
|
|
35
|
+
|
|
36
|
+
Model matrices from tabular data, as scikit-learn transformers.
|
|
37
|
+
|
|
38
|
+
`ModelSpec` builds a design matrix from a `pd.DataFrame` (or a polars or
|
|
39
|
+
pyarrow frame, or an `np.ndarray`) from a list of terms: columns,
|
|
40
|
+
categorical encodings, polynomials, splines, principal components and
|
|
41
|
+
their interactions. It is a scikit-learn transformer, so it goes in a
|
|
42
|
+
`Pipeline`, is cloned and cross-validated, and the parameters of its
|
|
43
|
+
terms are tuned with `GridSearchCV`.
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from modelmatrix import ModelSpec, ns, poly
|
|
47
|
+
from sklearn.linear_model import LinearRegression
|
|
48
|
+
from sklearn.model_selection import GridSearchCV
|
|
49
|
+
from sklearn.pipeline import make_pipeline
|
|
50
|
+
|
|
51
|
+
spec = ModelSpec([ns('age', df=4), poly('year', 2), 'education',
|
|
52
|
+
('age', 'education')])
|
|
53
|
+
X = spec.fit_transform(Wage)
|
|
54
|
+
|
|
55
|
+
pipe = make_pipeline(spec, LinearRegression())
|
|
56
|
+
grid = GridSearchCV(pipe, {'modelspec__terms__0__df': [2, 4, 8]})
|
|
57
|
+
grid.fit(Wage, Wage['wage'])
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
`ModelSpec` was written for the labs of
|
|
61
|
+
[An Introduction to Statistical Learning with Python](https://www.statlearning.com),
|
|
62
|
+
and `from ISLP.models import ModelSpec` still works there.
|
|
63
|
+
|
|
64
|
+
Documentation: https://intro-stat-learning.github.io/modelmatrix
|
|
65
|
+
|
|
66
|
+
## Install
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
pip install modelmatrix
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Requires Python 3.11 or later. BSD licensed.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
modelmatrix/__init__.py,sha256=_ehqVU8zpPa1nnC58joTYSUq3RlIpmwouaR3xhCxryY,807
|
|
2
|
+
modelmatrix/_version.py,sha256=I6rv1yp3a0f8EjR9JVTZRwOCsbnytHkJ3uefdmKfjhM,528
|
|
3
|
+
modelmatrix/columns.py,sha256=sgT4yEgC8LMBXJ_5OEgi4ckiD2NO3jK7FTmNSb_1OmA,10965
|
|
4
|
+
modelmatrix/model_spec.py,sha256=-T0yfifwFLxjgMWQZpG7DDHzHev5aD1WOOAt_XtNiFQ,62351
|
|
5
|
+
modelmatrix/transforms.py,sha256=JEoJJ2304puJdLnE7PI6j9JwGPmXxXUuB6OfmM9CCQQ,20661
|
|
6
|
+
modelmatrix-0.1.0.dist-info/licenses/LICENSE,sha256=hJKSKWbd9nXFDDSUNROjb7KWIP2BXPglzTADNHum_CY,1373
|
|
7
|
+
modelmatrix-0.1.0.dist-info/METADATA,sha256=eticSoBUieK-TtugyC-NGHPj6sLJ7sMlRFope8bKJlo,2564
|
|
8
|
+
modelmatrix-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
modelmatrix-0.1.0.dist-info/top_level.txt,sha256=oWGNMLw7_LSI61SNOlcOTr6JM2YdLAhSH8ZBkrK2by8,12
|
|
10
|
+
modelmatrix-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Redistribution and use in source and binary forms, with or without
|
|
2
|
+
modification, are permitted provided that the following conditions are
|
|
3
|
+
met:
|
|
4
|
+
|
|
5
|
+
(1) Redistributions of source code must retain the above copyright
|
|
6
|
+
notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
(2) Redistributions in binary form must reproduce the above copyright
|
|
9
|
+
notice, this list of conditions and the following disclaimer in
|
|
10
|
+
the documentation and/or other materials provided with the
|
|
11
|
+
distribution.
|
|
12
|
+
|
|
13
|
+
(3)The name of the author may not be used to
|
|
14
|
+
endorse or promote products derived from this software without
|
|
15
|
+
specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
18
|
+
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
19
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
20
|
+
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
21
|
+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
22
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
23
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
24
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
25
|
+
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
26
|
+
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
modelmatrix
|