pretab 0.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.
Files changed (47) hide show
  1. pretab-0.0.1/LICENSE +21 -0
  2. pretab-0.0.1/MANIFEST.in +3 -0
  3. pretab-0.0.1/PKG-INFO +202 -0
  4. pretab-0.0.1/README.md +187 -0
  5. pretab-0.0.1/pretab/__init__.py +3 -0
  6. pretab-0.0.1/pretab/__version__.py +4 -0
  7. pretab-0.0.1/pretab/preprocessor.py +532 -0
  8. pretab-0.0.1/pretab/transformers/__init__.py +41 -0
  9. pretab-0.0.1/pretab/transformers/binning/__init__.py +3 -0
  10. pretab-0.0.1/pretab/transformers/binning/binning.py +98 -0
  11. pretab-0.0.1/pretab/transformers/embeddings/__init__.py +3 -0
  12. pretab-0.0.1/pretab/transformers/embeddings/language_transformer.py +58 -0
  13. pretab-0.0.1/pretab/transformers/feature_maps/__init__.py +11 -0
  14. pretab-0.0.1/pretab/transformers/feature_maps/rbf.py +123 -0
  15. pretab-0.0.1/pretab/transformers/feature_maps/relu.py +113 -0
  16. pretab-0.0.1/pretab/transformers/feature_maps/sigmoid.py +122 -0
  17. pretab-0.0.1/pretab/transformers/feature_maps/tanh.py +116 -0
  18. pretab-0.0.1/pretab/transformers/onehot/__init__.py +3 -0
  19. pretab-0.0.1/pretab/transformers/onehot/onehot.py +67 -0
  20. pretab-0.0.1/pretab/transformers/ple/__init__.py +3 -0
  21. pretab-0.0.1/pretab/transformers/ple/ple.py +145 -0
  22. pretab-0.0.1/pretab/transformers/ple/tree_to_code.py +59 -0
  23. pretab-0.0.1/pretab/transformers/splines/__init__.py +13 -0
  24. pretab-0.0.1/pretab/transformers/splines/cubic.py +136 -0
  25. pretab-0.0.1/pretab/transformers/splines/integrated_spline.py +98 -0
  26. pretab-0.0.1/pretab/transformers/splines/natural_cubic.py +141 -0
  27. pretab-0.0.1/pretab/transformers/splines/p_spline.py +141 -0
  28. pretab-0.0.1/pretab/transformers/splines/tensor_product.py +170 -0
  29. pretab-0.0.1/pretab/transformers/splines/thinplate_spline.py +130 -0
  30. pretab-0.0.1/pretab/transformers/temporal/__init__.py +9 -0
  31. pretab-0.0.1/pretab/transformers/temporal/cyclic.py +29 -0
  32. pretab-0.0.1/pretab/transformers/temporal/lag.py +31 -0
  33. pretab-0.0.1/pretab/transformers/temporal/rolling_stats.py +47 -0
  34. pretab-0.0.1/pretab/transformers/utils/__init__.py +0 -0
  35. pretab-0.0.1/pretab/transformers/utils/continuous_ordinal.py +67 -0
  36. pretab-0.0.1/pretab/transformers/utils/floats.py +63 -0
  37. pretab-0.0.1/pretab/transformers/utils/utils.py +24 -0
  38. pretab-0.0.1/pretab/utils/__init__.py +7 -0
  39. pretab-0.0.1/pretab/utils/get_categorical.py +46 -0
  40. pretab-0.0.1/pretab/utils/get_numerical.py +111 -0
  41. pretab-0.0.1/pretab.egg-info/PKG-INFO +202 -0
  42. pretab-0.0.1/pretab.egg-info/SOURCES.txt +45 -0
  43. pretab-0.0.1/pretab.egg-info/dependency_links.txt +1 -0
  44. pretab-0.0.1/pretab.egg-info/requires.txt +4 -0
  45. pretab-0.0.1/pretab.egg-info/top_level.txt +1 -0
  46. pretab-0.0.1/setup.cfg +4 -0
  47. pretab-0.0.1/setup.py +57 -0
pretab-0.0.1/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Anton Frederik Thielmann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ include README.md
2
+ include LICENSE
3
+ recursive-include pretab *.py
pretab-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,202 @@
1
+ Metadata-Version: 2.1
2
+ Name: pretab
3
+ Version: 0.0.1
4
+ Summary: A python package for preprocessing tabular data
5
+ Home-page: https://github.com/OpenTabular/PreTab
6
+ Author: Anton Thielmann
7
+ Author-email: antonthielmann@t-online.de.de
8
+ License: MIT
9
+ Description: # πŸ“¦ pretab
10
+
11
+ **pretab** is a modular, extensible, and `scikit-learn`-compatible preprocessing library for tabular data. It supports **all `sklearn` transformers** out of the box, and extends functionality with a rich set of custom encoders, splines, and neural basis expansions.
12
+
13
+ ---
14
+
15
+ ## ✨ Features
16
+
17
+ - πŸ”’ **Numerical preprocessing** via:
18
+ - Polynomial and spline expansions: `B-splines`, `natural cubic splines`, `thin plate splines`, `tensor product splines`, `P-splines`
19
+ - Neural-inspired basis: `RBF`, `ReLU`, `Sigmoid`, `Tanh`
20
+ - Custom binning: rule-based or tree-based
21
+ - Piecewise Linear Encoding (`PLE`)
22
+
23
+ - 🌀 **Categorical preprocessing**:
24
+ - Ordinal encodings
25
+ - One-hot encodings
26
+ - Language embeddings (`pretrained vectorizers`)
27
+ - Custom encoders like `OneHotFromOrdinalTransformer`
28
+
29
+ - πŸ”§ **Composable pipeline interface**:
30
+ - Fully compatible with `sklearn.pipeline.Pipeline` and `sklearn.compose.ColumnTransformer`
31
+ - Accepts all sklearn-native transformers and parameters seamlessly
32
+
33
+ - 🧠 **Smart preprocessing**:
34
+ - Automatically detects feature types (categorical vs numerical)
35
+ - Supports both `pandas.DataFrame` and `numpy.ndarray` inputs
36
+
37
+ - πŸ§ͺ Comprehensive test coverage
38
+
39
+ - 🀝 Community-driven and open to contributions
40
+
41
+ ---
42
+
43
+ ## πŸ’  Installation
44
+
45
+ Install via pip:
46
+
47
+ ```bash
48
+ pip install pretab
49
+ ```
50
+
51
+ Or install in editable mode for development:
52
+
53
+ ```bash
54
+ git clone https://github.com/OpenTabular/pretab.git
55
+ cd pretab
56
+ pip install -e .
57
+ ```
58
+
59
+ ---
60
+
61
+ ## πŸš€ Quickstart
62
+
63
+ ```python
64
+ import pandas as pd
65
+ from pretab import Preprocessor
66
+
67
+ df = pd.DataFrame({
68
+ "age": [22, 35, 46, 59],
69
+ "income": [40000, 52000, 98000, 87000],
70
+ "job": ["nurse", "engineer", "scientist", "teacher"]
71
+ })
72
+
73
+ # Optional feature-specific config
74
+ config = {
75
+ "age": "ple",
76
+ "income": "rbf",
77
+ "job": "one-hot"
78
+ }
79
+
80
+ preprocessor = Preprocessor(
81
+ feature_preprocessing=config,
82
+ task="regression"
83
+ )
84
+
85
+ # Fit and transform
86
+ X_dict = preprocessor.fit_transform(df)
87
+
88
+ # Optionally get stacked array
89
+ X_array = preprocessor.transform(df, return_dict=False)
90
+
91
+ # Get feature info
92
+ preprocessor.get_feature_info()
93
+ ```
94
+
95
+ ---
96
+
97
+ ## πŸͺ° Included Transformers
98
+
99
+ pretab includes both sklearn-native and custom-built transformers:
100
+
101
+ ### 🌈 Splines
102
+ - `CubicSplineTransformer`
103
+ - `NaturalCubicSplineTransformer`
104
+ - `PSplineTransformer`
105
+ - `TensorProductSplineTransformer`
106
+ - `ThinPlateSplineTransformer`
107
+
108
+ ### 🧠 Feature Maps
109
+ - `RBFExpansionTransformer`
110
+ - `ReLUExpansionTransformer`
111
+ - `SigmoidExpansionTransformer`
112
+ - `TanhExpansionTransformer`
113
+
114
+ ### πŸ“Š Encodings and Binning
115
+ - `PLETransformer`
116
+ - `CustomBinTransformer`
117
+ - `OneHotFromOrdinalTransformer`
118
+ - `ContinuousOrdinalTransformer`
119
+ - `LanguageEmbeddingTransformer`
120
+
121
+ ### πŸ”§ Utilities
122
+ - `NoTransformer`
123
+ - `ToFloatTransformer`
124
+
125
+ > Plus: **any `sklearn` transformer** can be passed directly with full support for hyperparameters.
126
+
127
+ ### Using Transformers
128
+ Using the transformers follows the standard sklearn.preprocessing steps. I.e. using PLE
129
+ ```python
130
+ import numpy as np
131
+ from pretab.transformers import PLETransformer
132
+
133
+ x = np.random.randn(100, 1)
134
+ y = np.random.randn(100, 1)
135
+
136
+ x_ple = PLETransformer(n_bins=15, task="regression").fit_transform(x, y)
137
+
138
+ assert x_ple.shape[1] == 15
139
+ ```
140
+
141
+ For splines, the penalty matrices can be extracted via `.get_penalty_matrix()`
142
+
143
+ ```python
144
+ import numpy as np
145
+ from pretab.transformers import ThinPlateSplineTransformer
146
+
147
+ x = np.random.randn(100, 1)
148
+
149
+ tp = ThinPlateSplineTransformer(n_basis=15)
150
+
151
+ x_tp = tp.fit_transform(x)
152
+
153
+ assert x_tp.shape[1] == 15
154
+
155
+ penalty = tp.get_penalty_matrix()
156
+ ```
157
+
158
+ ---
159
+
160
+ ## πŸ§ͺ Running Tests
161
+
162
+ ```bash
163
+ pytest --maxfail=2 --disable-warnings -v
164
+ ```
165
+
166
+ ---
167
+
168
+ ## 🀝 Contributing
169
+
170
+ pretab is community-driven! Whether you’re fixing bugs, adding new encoders, or improving the docs β€” contributions are welcome.
171
+
172
+ ```bash
173
+ git clone https://github.com/OpenTabular/pretab.git
174
+ cd pretab
175
+ pip install -e ".[dev]"
176
+ ```
177
+
178
+ Then create a pull request πŸš€
179
+
180
+ ---
181
+
182
+ ## πŸ“„ License
183
+
184
+ MIT License. See [LICENSE](./LICENSE) for details.
185
+
186
+ ---
187
+
188
+ ## ❀️ Acknowledgements
189
+
190
+ pretab builds on the strengths of:
191
+ - [`scikit-learn`](https://scikit-learn.org)
192
+
193
+ ---
194
+
195
+
196
+
197
+ Platform: UNKNOWN
198
+ Classifier: Programming Language :: Python :: 3
199
+ Classifier: License :: OSI Approved :: MIT License
200
+ Classifier: Operating System :: OS Independent
201
+ Requires-Python: >=3.6
202
+ Description-Content-Type: text/markdown
pretab-0.0.1/README.md ADDED
@@ -0,0 +1,187 @@
1
+ # πŸ“¦ pretab
2
+
3
+ **pretab** is a modular, extensible, and `scikit-learn`-compatible preprocessing library for tabular data. It supports **all `sklearn` transformers** out of the box, and extends functionality with a rich set of custom encoders, splines, and neural basis expansions.
4
+
5
+ ---
6
+
7
+ ## ✨ Features
8
+
9
+ - πŸ”’ **Numerical preprocessing** via:
10
+ - Polynomial and spline expansions: `B-splines`, `natural cubic splines`, `thin plate splines`, `tensor product splines`, `P-splines`
11
+ - Neural-inspired basis: `RBF`, `ReLU`, `Sigmoid`, `Tanh`
12
+ - Custom binning: rule-based or tree-based
13
+ - Piecewise Linear Encoding (`PLE`)
14
+
15
+ - 🌀 **Categorical preprocessing**:
16
+ - Ordinal encodings
17
+ - One-hot encodings
18
+ - Language embeddings (`pretrained vectorizers`)
19
+ - Custom encoders like `OneHotFromOrdinalTransformer`
20
+
21
+ - πŸ”§ **Composable pipeline interface**:
22
+ - Fully compatible with `sklearn.pipeline.Pipeline` and `sklearn.compose.ColumnTransformer`
23
+ - Accepts all sklearn-native transformers and parameters seamlessly
24
+
25
+ - 🧠 **Smart preprocessing**:
26
+ - Automatically detects feature types (categorical vs numerical)
27
+ - Supports both `pandas.DataFrame` and `numpy.ndarray` inputs
28
+
29
+ - πŸ§ͺ Comprehensive test coverage
30
+
31
+ - 🀝 Community-driven and open to contributions
32
+
33
+ ---
34
+
35
+ ## πŸ’  Installation
36
+
37
+ Install via pip:
38
+
39
+ ```bash
40
+ pip install pretab
41
+ ```
42
+
43
+ Or install in editable mode for development:
44
+
45
+ ```bash
46
+ git clone https://github.com/OpenTabular/pretab.git
47
+ cd pretab
48
+ pip install -e .
49
+ ```
50
+
51
+ ---
52
+
53
+ ## πŸš€ Quickstart
54
+
55
+ ```python
56
+ import pandas as pd
57
+ from pretab import Preprocessor
58
+
59
+ df = pd.DataFrame({
60
+ "age": [22, 35, 46, 59],
61
+ "income": [40000, 52000, 98000, 87000],
62
+ "job": ["nurse", "engineer", "scientist", "teacher"]
63
+ })
64
+
65
+ # Optional feature-specific config
66
+ config = {
67
+ "age": "ple",
68
+ "income": "rbf",
69
+ "job": "one-hot"
70
+ }
71
+
72
+ preprocessor = Preprocessor(
73
+ feature_preprocessing=config,
74
+ task="regression"
75
+ )
76
+
77
+ # Fit and transform
78
+ X_dict = preprocessor.fit_transform(df)
79
+
80
+ # Optionally get stacked array
81
+ X_array = preprocessor.transform(df, return_dict=False)
82
+
83
+ # Get feature info
84
+ preprocessor.get_feature_info()
85
+ ```
86
+
87
+ ---
88
+
89
+ ## πŸͺ° Included Transformers
90
+
91
+ pretab includes both sklearn-native and custom-built transformers:
92
+
93
+ ### 🌈 Splines
94
+ - `CubicSplineTransformer`
95
+ - `NaturalCubicSplineTransformer`
96
+ - `PSplineTransformer`
97
+ - `TensorProductSplineTransformer`
98
+ - `ThinPlateSplineTransformer`
99
+
100
+ ### 🧠 Feature Maps
101
+ - `RBFExpansionTransformer`
102
+ - `ReLUExpansionTransformer`
103
+ - `SigmoidExpansionTransformer`
104
+ - `TanhExpansionTransformer`
105
+
106
+ ### πŸ“Š Encodings and Binning
107
+ - `PLETransformer`
108
+ - `CustomBinTransformer`
109
+ - `OneHotFromOrdinalTransformer`
110
+ - `ContinuousOrdinalTransformer`
111
+ - `LanguageEmbeddingTransformer`
112
+
113
+ ### πŸ”§ Utilities
114
+ - `NoTransformer`
115
+ - `ToFloatTransformer`
116
+
117
+ > Plus: **any `sklearn` transformer** can be passed directly with full support for hyperparameters.
118
+
119
+ ### Using Transformers
120
+ Using the transformers follows the standard sklearn.preprocessing steps. I.e. using PLE
121
+ ```python
122
+ import numpy as np
123
+ from pretab.transformers import PLETransformer
124
+
125
+ x = np.random.randn(100, 1)
126
+ y = np.random.randn(100, 1)
127
+
128
+ x_ple = PLETransformer(n_bins=15, task="regression").fit_transform(x, y)
129
+
130
+ assert x_ple.shape[1] == 15
131
+ ```
132
+
133
+ For splines, the penalty matrices can be extracted via `.get_penalty_matrix()`
134
+
135
+ ```python
136
+ import numpy as np
137
+ from pretab.transformers import ThinPlateSplineTransformer
138
+
139
+ x = np.random.randn(100, 1)
140
+
141
+ tp = ThinPlateSplineTransformer(n_basis=15)
142
+
143
+ x_tp = tp.fit_transform(x)
144
+
145
+ assert x_tp.shape[1] == 15
146
+
147
+ penalty = tp.get_penalty_matrix()
148
+ ```
149
+
150
+ ---
151
+
152
+ ## πŸ§ͺ Running Tests
153
+
154
+ ```bash
155
+ pytest --maxfail=2 --disable-warnings -v
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 🀝 Contributing
161
+
162
+ pretab is community-driven! Whether you’re fixing bugs, adding new encoders, or improving the docs β€” contributions are welcome.
163
+
164
+ ```bash
165
+ git clone https://github.com/OpenTabular/pretab.git
166
+ cd pretab
167
+ pip install -e ".[dev]"
168
+ ```
169
+
170
+ Then create a pull request πŸš€
171
+
172
+ ---
173
+
174
+ ## πŸ“„ License
175
+
176
+ MIT License. See [LICENSE](./LICENSE) for details.
177
+
178
+ ---
179
+
180
+ ## ❀️ Acknowledgements
181
+
182
+ pretab builds on the strengths of:
183
+ - [`scikit-learn`](https://scikit-learn.org)
184
+
185
+ ---
186
+
187
+
@@ -0,0 +1,3 @@
1
+ from .__version__ import __version__ # noqa: F401
2
+
3
+ __all__ = ["__version__"]
@@ -0,0 +1,4 @@
1
+ """Version information."""
2
+
3
+ # The following line *must* be the last in the module, exactly as formatted:
4
+ __version__ = "0.0.1"