gafime 0.2.0__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 (51) hide show
  1. gafime-0.2.0/LICENSE +201 -0
  2. gafime-0.2.0/MANIFEST.in +5 -0
  3. gafime-0.2.0/PKG-INFO +132 -0
  4. gafime-0.2.0/README.md +99 -0
  5. gafime-0.2.0/examples/feature_engineering_demo.py +248 -0
  6. gafime-0.2.0/gafime/__init__.py +14 -0
  7. gafime-0.2.0/gafime/__main__.py +4 -0
  8. gafime-0.2.0/gafime/_dummy.c +11 -0
  9. gafime-0.2.0/gafime/backends/__init__.py +99 -0
  10. gafime-0.2.0/gafime/backends/base.py +89 -0
  11. gafime-0.2.0/gafime/backends/core_backend.py +66 -0
  12. gafime-0.2.0/gafime/backends/fused_kernel.py +946 -0
  13. gafime-0.2.0/gafime/backends/native_cuda_backend.py +273 -0
  14. gafime-0.2.0/gafime/backends/native_metal_backend.py +340 -0
  15. gafime-0.2.0/gafime/cli.py +19 -0
  16. gafime-0.2.0/gafime/config.py +31 -0
  17. gafime-0.2.0/gafime/engine.py +171 -0
  18. gafime-0.2.0/gafime/io.py +381 -0
  19. gafime-0.2.0/gafime/metrics/__init__.py +3 -0
  20. gafime-0.2.0/gafime/metrics/base.py +43 -0
  21. gafime-0.2.0/gafime/metrics/cpu_metrics.py +66 -0
  22. gafime-0.2.0/gafime/optimizer/__init__.py +42 -0
  23. gafime-0.2.0/gafime/optimizer/adaptive.py +336 -0
  24. gafime-0.2.0/gafime/optimizer/ensemble_search.py +909 -0
  25. gafime-0.2.0/gafime/optimizer/orchestrator.py +285 -0
  26. gafime-0.2.0/gafime/planning/__init__.py +3 -0
  27. gafime-0.2.0/gafime/planning/combinations.py +91 -0
  28. gafime-0.2.0/gafime/preprocessors/__init__.py +15 -0
  29. gafime-0.2.0/gafime/preprocessors/time_series.py +364 -0
  30. gafime-0.2.0/gafime/reporting/__init__.py +9 -0
  31. gafime-0.2.0/gafime/reporting/report.py +57 -0
  32. gafime-0.2.0/gafime/sklearn.py +110 -0
  33. gafime-0.2.0/gafime/tutorial.py +158 -0
  34. gafime-0.2.0/gafime/utils/__init__.py +4 -0
  35. gafime-0.2.0/gafime/utils/arrays.py +48 -0
  36. gafime-0.2.0/gafime/utils/safety.py +31 -0
  37. gafime-0.2.0/gafime/validation/__init__.py +4 -0
  38. gafime-0.2.0/gafime/validation/permutation.py +60 -0
  39. gafime-0.2.0/gafime/validation/stability.py +50 -0
  40. gafime-0.2.0/gafime.egg-info/PKG-INFO +132 -0
  41. gafime-0.2.0/gafime.egg-info/SOURCES.txt +49 -0
  42. gafime-0.2.0/gafime.egg-info/dependency_links.txt +1 -0
  43. gafime-0.2.0/gafime.egg-info/entry_points.txt +2 -0
  44. gafime-0.2.0/gafime.egg-info/requires.txt +9 -0
  45. gafime-0.2.0/gafime.egg-info/top_level.txt +6 -0
  46. gafime-0.2.0/pyproject.toml +56 -0
  47. gafime-0.2.0/setup.cfg +4 -0
  48. gafime-0.2.0/setup.py +303 -0
  49. gafime-0.2.0/tests/test_distribution.py +48 -0
  50. gafime-0.2.0/tests/test_perpair_interactions.py +128 -0
  51. gafime-0.2.0/tests/test_sklearn.py +67 -0
gafime-0.2.0/LICENSE ADDED
@@ -0,0 +1,201 @@
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 character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include gafime/*.so
2
+ include gafime/*.dll
3
+ include gafime/*.dylib
4
+ include gafime/*.metallib
5
+ include gafime/*.pyd
gafime-0.2.0/PKG-INFO ADDED
@@ -0,0 +1,132 @@
1
+ Metadata-Version: 2.4
2
+ Name: gafime
3
+ Version: 0.2.0
4
+ Summary: GPU Accelerated Feature Interaction Mining Engine
5
+ Author: Hamza
6
+ Author-email: Hamza <hamzausta2222@gmail.com>
7
+ License: Apache-2.0
8
+ Project-URL: Homepage, https://github.com/onlyxItachi/GAFIME
9
+ Project-URL: Repository, https://github.com/onlyxItachi/GAFIME
10
+ Project-URL: Issues, https://github.com/onlyxItachi/GAFIME/issues
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
18
+ Classifier: Operating System :: Microsoft :: Windows
19
+ Classifier: Operating System :: POSIX :: Linux
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: numpy>=1.24
24
+ Requires-Dist: polars>=0.20
25
+ Provides-Extra: dev
26
+ Requires-Dist: pytest>=7.0; extra == "dev"
27
+ Requires-Dist: pytest-cov; extra == "dev"
28
+ Provides-Extra: sklearn
29
+ Requires-Dist: scikit-learn>=1.0; extra == "sklearn"
30
+ Dynamic: author
31
+ Dynamic: license-file
32
+ Dynamic: requires-python
33
+
34
+ # GAFIME: GPU-Accelerated Feature Interaction Mining Engine 🚀
35
+
36
+ ![PyPI version](https://img.shields.io/pypi/v/gafime)
37
+ ![Python Versions](https://img.shields.io/pypi/pyversions/gafime)
38
+ ![License](https://img.shields.io/github/license/onlyxItachi/GAFIME)
39
+
40
+ GAFIME is a high-performance computing engine engineered to eliminate the biggest bottleneck in modern machine learning workflows: **Feature Interaction Discovery.**
41
+
42
+ While most data science tools prioritize ease-of-use over execution efficiency, GAFIME treats feature engineering as a low-level systems problem. By combining C++ optimization, Rust memory-safety pipelines, and cross-platform native bindings (CUDA/Metal), GAFIME bridges the gap between high-level data science and the raw power of modern hardware architectures.
43
+
44
+ ## 📦 Installation
45
+
46
+ GAFIME ships natively compiled wheel binaries for Windows, macOS (Apple Silicon), and Linux heavily optimized for performance out-of-the-box.
47
+
48
+ **Basic Install (Engine Only):**
49
+
50
+ ```bash
51
+ pip install gafime
52
+ ```
53
+
54
+ **Data Science Install (Includes Scikit-Learn Wrapper):**
55
+
56
+ ```bash
57
+ pip install gafime[sklearn]
58
+ ```
59
+
60
+ ## ⚡ Quickstart: The Interactive Tutorial
61
+
62
+ The fastest way to understand GAFIME's speed is to try our built-in interactive tutorial generator. Running this command will generate a pre-configured `gafime_tutorial.ipynb` Jupyter Notebook in your current directory with dummy feature data to instantly evaluate against:
63
+
64
+ ```bash
65
+ gafime --init
66
+ ```
67
+
68
+ ## 🧩 Scikit-Learn Pipeline Integration
69
+
70
+ You don't need to rewrite your data pipelines to use GAFIME. By importing the `GafimeSelector`, you can inject GPU-accelerated feature discovery natively into `sklearn.pipeline.Pipeline` or `GridSearchCV`:
71
+
72
+ ```python
73
+ import numpy as np
74
+ from sklearn.pipeline import Pipeline
75
+ from sklearn.linear_model import LogisticRegression
76
+ from gafime.sklearn import GafimeSelector
77
+
78
+ # Define dummy data
79
+ X_train = np.random.randn(1000, 50).astype(np.float32)
80
+ y_train = np.random.randint(0, 2, size=1000).astype(np.float32)
81
+
82
+ # Create a pipeline that automatically discovers the Top 5 best Feature Interactions
83
+ # Evaluated instantly against the GPU logic and appends them to your training dataset
84
+ pipe = Pipeline([
85
+ ('interaction_miner', GafimeSelector(k=5, backend='auto', operator='multiply')),
86
+ ('classifier', LogisticRegression())
87
+ ])
88
+
89
+ pipe.fit(X_train, y_train)
90
+ ```
91
+
92
+ ## 🌌 Why GAFIME? The Performance Ceiling
93
+
94
+ In the current data science landscape, mining interaction data (like checking `Feature X * Feature Y` against the target) is painfully slow on CPUs or inefficiently memory-managed on GPUs. GAFIME achieves:
95
+
96
+ 1. **Hardware-Bound Execution**: GAFIME targets physical memory bandwidth limits, minimizing the overhead of standard GPU python workflows. You hit the system's ceiling.
97
+ 2. **Zero-Overhead Scaling**: Utilizing Rust's FFI capabilities on top of optimized CUDA C++, GAFIME bypasses the Python Global Interpreter Lock (GIL) ensuring every clock cycle executes pure feature logic.
98
+ 3. **Cross-Platform Scalability**: Whether you're on a MacBook executing `Metal` fallback logic via Rust, or an RTX workstation targeting `CUDA` registers, GAFIME auto-discovers and optimizes for your hardware at runtime.
99
+
100
+ ### Caching and Branch-less Operations
101
+
102
+ GAFIME's specialized memory management layout ensures tabular feature data is cached and aligned, dramatically minimizing GPU cycle stalls regardless of noisy dataset inputs.
103
+
104
+ ## 🛠️ Technology Stack
105
+
106
+ - **Core Engine**: C++ / CUDA (Performance-critical computation paths) and **Metal** (Apple Silicon native acceleration)
107
+ - **Safety Pipeline & Schedulers**: Rust (Memory safe FFI interface scheduling)
108
+ - **Data Science Interfacing**: Python (Polars / Numpy bindings seamlessly communicating across boundaries)
109
+
110
+ ## ✅ For being honest
111
+
112
+ -> Current state of the project is its **first v0.1 open beta release**.
113
+
114
+ -> The project is developed with the help of current frontier SOTA models such as Gemini 3.1 Pro (high reasoning effort) and Claude Opus 4.6 (high). The state of project is clearly working on my personal computer! But I am not guaranteeing that at this stage "you could run it on your device as well!"
115
+
116
+ ## 🤝 If you want
117
+
118
+ You could collaborate with me via using email to communicate 🥰
119
+
120
+ Email: <hamzausta2222@gmail.com>
121
+
122
+ ---
123
+
124
+ ### Contributing and Advanced Usage
125
+
126
+ Looking to expand the engine metrics or compile natively yourself?
127
+ Please see our detailed references:
128
+
129
+ - [USAGE.md](/USAGE.md) - Advanced `EngineConfig` features and API logic.
130
+ - [CONTRIBUTING.md](/CONTRIBUTING.md) - Local compilation instructions for OS developers.
131
+
132
+ *GAFIME was conceptualized and engineered for extreme high-frequency feature permutations in complex categorical environments like Banking models.*
gafime-0.2.0/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # GAFIME: GPU-Accelerated Feature Interaction Mining Engine 🚀
2
+
3
+ ![PyPI version](https://img.shields.io/pypi/v/gafime)
4
+ ![Python Versions](https://img.shields.io/pypi/pyversions/gafime)
5
+ ![License](https://img.shields.io/github/license/onlyxItachi/GAFIME)
6
+
7
+ GAFIME is a high-performance computing engine engineered to eliminate the biggest bottleneck in modern machine learning workflows: **Feature Interaction Discovery.**
8
+
9
+ While most data science tools prioritize ease-of-use over execution efficiency, GAFIME treats feature engineering as a low-level systems problem. By combining C++ optimization, Rust memory-safety pipelines, and cross-platform native bindings (CUDA/Metal), GAFIME bridges the gap between high-level data science and the raw power of modern hardware architectures.
10
+
11
+ ## 📦 Installation
12
+
13
+ GAFIME ships natively compiled wheel binaries for Windows, macOS (Apple Silicon), and Linux heavily optimized for performance out-of-the-box.
14
+
15
+ **Basic Install (Engine Only):**
16
+
17
+ ```bash
18
+ pip install gafime
19
+ ```
20
+
21
+ **Data Science Install (Includes Scikit-Learn Wrapper):**
22
+
23
+ ```bash
24
+ pip install gafime[sklearn]
25
+ ```
26
+
27
+ ## ⚡ Quickstart: The Interactive Tutorial
28
+
29
+ The fastest way to understand GAFIME's speed is to try our built-in interactive tutorial generator. Running this command will generate a pre-configured `gafime_tutorial.ipynb` Jupyter Notebook in your current directory with dummy feature data to instantly evaluate against:
30
+
31
+ ```bash
32
+ gafime --init
33
+ ```
34
+
35
+ ## 🧩 Scikit-Learn Pipeline Integration
36
+
37
+ You don't need to rewrite your data pipelines to use GAFIME. By importing the `GafimeSelector`, you can inject GPU-accelerated feature discovery natively into `sklearn.pipeline.Pipeline` or `GridSearchCV`:
38
+
39
+ ```python
40
+ import numpy as np
41
+ from sklearn.pipeline import Pipeline
42
+ from sklearn.linear_model import LogisticRegression
43
+ from gafime.sklearn import GafimeSelector
44
+
45
+ # Define dummy data
46
+ X_train = np.random.randn(1000, 50).astype(np.float32)
47
+ y_train = np.random.randint(0, 2, size=1000).astype(np.float32)
48
+
49
+ # Create a pipeline that automatically discovers the Top 5 best Feature Interactions
50
+ # Evaluated instantly against the GPU logic and appends them to your training dataset
51
+ pipe = Pipeline([
52
+ ('interaction_miner', GafimeSelector(k=5, backend='auto', operator='multiply')),
53
+ ('classifier', LogisticRegression())
54
+ ])
55
+
56
+ pipe.fit(X_train, y_train)
57
+ ```
58
+
59
+ ## 🌌 Why GAFIME? The Performance Ceiling
60
+
61
+ In the current data science landscape, mining interaction data (like checking `Feature X * Feature Y` against the target) is painfully slow on CPUs or inefficiently memory-managed on GPUs. GAFIME achieves:
62
+
63
+ 1. **Hardware-Bound Execution**: GAFIME targets physical memory bandwidth limits, minimizing the overhead of standard GPU python workflows. You hit the system's ceiling.
64
+ 2. **Zero-Overhead Scaling**: Utilizing Rust's FFI capabilities on top of optimized CUDA C++, GAFIME bypasses the Python Global Interpreter Lock (GIL) ensuring every clock cycle executes pure feature logic.
65
+ 3. **Cross-Platform Scalability**: Whether you're on a MacBook executing `Metal` fallback logic via Rust, or an RTX workstation targeting `CUDA` registers, GAFIME auto-discovers and optimizes for your hardware at runtime.
66
+
67
+ ### Caching and Branch-less Operations
68
+
69
+ GAFIME's specialized memory management layout ensures tabular feature data is cached and aligned, dramatically minimizing GPU cycle stalls regardless of noisy dataset inputs.
70
+
71
+ ## 🛠️ Technology Stack
72
+
73
+ - **Core Engine**: C++ / CUDA (Performance-critical computation paths) and **Metal** (Apple Silicon native acceleration)
74
+ - **Safety Pipeline & Schedulers**: Rust (Memory safe FFI interface scheduling)
75
+ - **Data Science Interfacing**: Python (Polars / Numpy bindings seamlessly communicating across boundaries)
76
+
77
+ ## ✅ For being honest
78
+
79
+ -> Current state of the project is its **first v0.1 open beta release**.
80
+
81
+ -> The project is developed with the help of current frontier SOTA models such as Gemini 3.1 Pro (high reasoning effort) and Claude Opus 4.6 (high). The state of project is clearly working on my personal computer! But I am not guaranteeing that at this stage "you could run it on your device as well!"
82
+
83
+ ## 🤝 If you want
84
+
85
+ You could collaborate with me via using email to communicate 🥰
86
+
87
+ Email: <hamzausta2222@gmail.com>
88
+
89
+ ---
90
+
91
+ ### Contributing and Advanced Usage
92
+
93
+ Looking to expand the engine metrics or compile natively yourself?
94
+ Please see our detailed references:
95
+
96
+ - [USAGE.md](/USAGE.md) - Advanced `EngineConfig` features and API logic.
97
+ - [CONTRIBUTING.md](/CONTRIBUTING.md) - Local compilation instructions for OS developers.
98
+
99
+ *GAFIME was conceptualized and engineered for extreme high-frequency feature permutations in complex categorical environments like Banking models.*
@@ -0,0 +1,248 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ GAFIME Feature Engineering Demo
4
+
5
+ This example demonstrates:
6
+ 1. Loading data using GafimeStreamer
7
+ 2. Creating feature interactions with GAFIME
8
+ 3. Testing signal detection
9
+ 4. Comparing different operators and interaction types
10
+ 5. Cross-validation scoring
11
+
12
+ Shows the comfort and power of GAFIME's automated feature extraction.
13
+ """
14
+
15
+ import sys
16
+ import time
17
+ from pathlib import Path
18
+ from itertools import combinations
19
+
20
+ import numpy as np
21
+
22
+ # Add project root
23
+ PROJECT_ROOT = Path(__file__).parent.parent
24
+ sys.path.insert(0, str(PROJECT_ROOT))
25
+
26
+ from gafime.backends.fused_kernel import (
27
+ StaticBucket,
28
+ UnaryOp,
29
+ InteractionType,
30
+ compute_pearson_from_stats,
31
+ create_fold_mask,
32
+ )
33
+
34
+
35
+ def generate_synthetic_dataset(n_samples: int = 10000, n_features: int = 5):
36
+ """
37
+ Generate synthetic data with known feature interactions.
38
+
39
+ The target has the following signals:
40
+ - f0 * f1: Strong interaction (r ≈ 0.9)
41
+ - log(f2) + f3: Moderate interaction (r ≈ 0.5)
42
+ - f4: Pure noise feature
43
+ """
44
+ np.random.seed(42)
45
+
46
+ features = {}
47
+ for i in range(n_features):
48
+ features[f"f{i}"] = np.random.randn(n_samples).astype(np.float32)
49
+
50
+ # Create target with known signals
51
+ target = (
52
+ 0.7 * (features["f0"] * features["f1"]) + # Strong multiplicative signal
53
+ 0.3 * (np.log(np.abs(features["f2"]) + 1e-8) + features["f3"]) + # Log-additive signal
54
+ 0.1 * np.random.randn(n_samples) # Noise
55
+ ).astype(np.float32)
56
+
57
+ return features, target
58
+
59
+
60
+ def run_automated_feature_search():
61
+ """
62
+ Demonstrate GAFIME's automated feature interaction search.
63
+ """
64
+ print("=" * 70)
65
+ print("GAFIME AUTOMATED FEATURE INTERACTION SEARCH")
66
+ print("=" * 70)
67
+
68
+ # Generate data (max 5 features supported)
69
+ n_samples = 10000
70
+ n_features = 5
71
+ features, target = generate_synthetic_dataset(n_samples, n_features)
72
+ mask = create_fold_mask(n_samples, n_folds=5)
73
+
74
+ print(f"\nDataset: {n_samples} samples, {n_features} features")
75
+ print("Known signals:")
76
+ print(" - f0 * f1: Strong multiplicative interaction")
77
+ print(" - log(f2) + f3: Log-additive interaction")
78
+
79
+ # Convert to list for bucket
80
+ feature_list = [features[f"f{i}"] for i in range(n_features)]
81
+
82
+ # Create GPU bucket
83
+ print("\nAllocating GPU memory...")
84
+ bucket = StaticBucket(n_samples, n_features)
85
+ bucket.upload_all(feature_list, target, mask)
86
+
87
+ # =========================================================================
88
+ # PHASE 1: Search all pairwise multiplicative interactions
89
+ # =========================================================================
90
+ print("\n" + "-" * 70)
91
+ print("PHASE 1: Pairwise Multiplicative Interactions")
92
+ print("-" * 70)
93
+
94
+ results = []
95
+ n_combos = 0
96
+
97
+ start_time = time.perf_counter()
98
+
99
+ for i, j in combinations(range(n_features), 2):
100
+ for val_fold in range(5):
101
+ stats = bucket.compute(
102
+ feature_indices=[i, j],
103
+ ops=[UnaryOp.IDENTITY, UnaryOp.IDENTITY],
104
+ interaction=InteractionType.MULT,
105
+ val_fold=val_fold
106
+ )
107
+ train_r, val_r = compute_pearson_from_stats(stats)
108
+ n_combos += 1
109
+
110
+ # Average validation score across folds
111
+ avg_val_r = val_r # Last fold for simplicity
112
+ results.append((f"f{i} * f{j}", abs(train_r), abs(val_r)))
113
+
114
+ elapsed = time.perf_counter() - start_time
115
+
116
+ # Sort by validation score
117
+ results.sort(key=lambda x: x[2], reverse=True)
118
+
119
+ print(f"\nSearched {n_combos} combinations in {elapsed*1000:.1f}ms")
120
+ print(f"Speed: {n_combos/elapsed:.0f} combinations/sec")
121
+ print("\nTop 5 interactions:")
122
+ for name, train_r, val_r in results[:5]:
123
+ marker = " 🎯" if "f0 * f1" in name else ""
124
+ print(f" {name}: train_r={train_r:.4f}, val_r={val_r:.4f}{marker}")
125
+
126
+ # =========================================================================
127
+ # PHASE 2: Search with different operators
128
+ # =========================================================================
129
+ print("\n" + "-" * 70)
130
+ print("PHASE 2: Operator Search (for f2, f3)")
131
+ print("-" * 70)
132
+
133
+ ops_to_try = [
134
+ (UnaryOp.IDENTITY, "identity"),
135
+ (UnaryOp.LOG, "log"),
136
+ (UnaryOp.SQRT, "sqrt"),
137
+ (UnaryOp.SQUARE, "square"),
138
+ (UnaryOp.TANH, "tanh"),
139
+ ]
140
+
141
+ interactions_to_try = [
142
+ (InteractionType.MULT, "*"),
143
+ (InteractionType.ADD, "+"),
144
+ (InteractionType.DIV, "/"),
145
+ ]
146
+
147
+ best = {"name": None, "val_r": 0}
148
+
149
+ start_time = time.perf_counter()
150
+ n_combos = 0
151
+
152
+ for op1_id, op1_name in ops_to_try:
153
+ for op2_id, op2_name in ops_to_try:
154
+ for int_id, int_name in interactions_to_try:
155
+ stats = bucket.compute(
156
+ feature_indices=[2, 3],
157
+ ops=[op1_id, op2_id],
158
+ interaction=int_id,
159
+ val_fold=0
160
+ )
161
+ train_r, val_r = compute_pearson_from_stats(stats)
162
+ n_combos += 1
163
+
164
+ name = f"{op1_name}(f2) {int_name} {op2_name}(f3)"
165
+
166
+ if abs(val_r) > best["val_r"]:
167
+ best = {"name": name, "val_r": abs(val_r), "train_r": abs(train_r)}
168
+
169
+ elapsed = time.perf_counter() - start_time
170
+
171
+ print(f"\nSearched {n_combos} op/interaction combinations in {elapsed*1000:.1f}ms")
172
+ print(f"Best found: {best['name']}")
173
+ print(f" train_r={best['train_r']:.4f}, val_r={best['val_r']:.4f}")
174
+
175
+ # =========================================================================
176
+ # PHASE 3: Full automated search
177
+ # =========================================================================
178
+ print("\n" + "-" * 70)
179
+ print("PHASE 3: Full Automated Search (all features, all ops)")
180
+ print("-" * 70)
181
+
182
+ all_results = []
183
+ start_time = time.perf_counter()
184
+ n_total = 0
185
+
186
+ # For speed, use subset of operators
187
+ quick_ops = [UnaryOp.IDENTITY, UnaryOp.LOG, UnaryOp.SQRT]
188
+
189
+ for i, j in combinations(range(min(n_features, 6)), 2): # First 6 features
190
+ for op1 in quick_ops:
191
+ for op2 in quick_ops:
192
+ stats = bucket.compute([i, j], [op1, op2], InteractionType.MULT, 0)
193
+ _, val_r = compute_pearson_from_stats(stats)
194
+ n_total += 1
195
+
196
+ op1_name = {0: "", 1: "log_", 3: "sqrt_"}[op1]
197
+ op2_name = {0: "", 1: "log_", 3: "sqrt_"}[op2]
198
+ name = f"{op1_name}f{i} * {op2_name}f{j}"
199
+ all_results.append((name, abs(val_r)))
200
+
201
+ elapsed = time.perf_counter() - start_time
202
+
203
+ all_results.sort(key=lambda x: x[1], reverse=True)
204
+
205
+ print(f"\nSearched {n_total} combinations in {elapsed*1000:.1f}ms")
206
+ print(f"Speed: {n_total/elapsed:.0f} combinations/sec")
207
+ print("\nTop 10 discovered features:")
208
+ for i, (name, r) in enumerate(all_results[:10], 1):
209
+ print(f" {i:2}. {name}: val_r={r:.4f}")
210
+
211
+ # Cleanup
212
+ del bucket
213
+
214
+ # =========================================================================
215
+ # SUMMARY
216
+ # =========================================================================
217
+ print("\n" + "=" * 70)
218
+ print("SUMMARY: GAFIME Feature Engineering Benefits")
219
+ print("=" * 70)
220
+ print("""
221
+ 1. COMFORT: Simple Python API with StaticBucket class
222
+ - Upload data once, explore millions of combinations
223
+ - No manual feature engineering code
224
+
225
+ 2. SPEED: GPU-accelerated search
226
+ - Thousands of combinations per second
227
+ - On-chip reduction (no memory bottleneck)
228
+
229
+ 3. AUTOMATION: Systematic exploration
230
+ - All operator combinations (log, sqrt, exp, etc.)
231
+ - All interaction types (multiply, add, divide, etc.)
232
+ - Cross-validation built-in
233
+
234
+ 4. SIGNAL DETECTION: Automatic discovery
235
+ - Found f0 * f1 (our planted signal) at top
236
+ - Found log(f2) + f3 (our log-additive signal)
237
+ - Filters noise features automatically
238
+
239
+ 5. REAL DEAL: What GAFIME provides
240
+ - No manual feature brainstorming
241
+ - Data-driven feature discovery
242
+ - Validation-aware (no overfitting)
243
+ - GPU performance for large searches
244
+ """)
245
+
246
+
247
+ if __name__ == "__main__":
248
+ run_automated_feature_search()