oikan 0.0.1.11__tar.gz → 0.0.2.2__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.
oikan-0.0.2.2/PKG-INFO ADDED
@@ -0,0 +1,223 @@
1
+ Metadata-Version: 2.4
2
+ Name: oikan
3
+ Version: 0.0.2.2
4
+ Summary: OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks
5
+ Author: Arman Zhalgasbayev
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Requires-Python: >=3.7
11
+ Description-Content-Type: text/markdown
12
+ License-File: LICENSE
13
+ Requires-Dist: torch
14
+ Requires-Dist: numpy
15
+ Requires-Dist: scikit-learn
16
+ Dynamic: license-file
17
+
18
+ <!-- logo in the center -->
19
+ <div align="center">
20
+ <img src="docs/media/oikan_logo.png" alt="OIKAN Logo" width="200"/>
21
+
22
+ <h1>OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks</h1>
23
+ </div>
24
+
25
+ ## Overview
26
+ OIKAN (Optimized Interpretable Kolmogorov-Arnold Networks) is a neuro-symbolic ML framework that combines modern neural networks with classical Kolmogorov-Arnold representation theory. It provides interpretable machine learning solutions through automatic extraction of symbolic mathematical formulas from trained models.
27
+
28
+ [![PyPI version](https://badge.fury.io/py/oikan.svg)](https://badge.fury.io/py/oikan)
29
+ [![PyPI Downloads per month](https://img.shields.io/pypi/dm/oikan.svg)](https://pypistats.org/packages/oikan)
30
+ [![PyPI Total Downloads](https://static.pepy.tech/badge/oikan)](https://pepy.tech/projects/oikan)
31
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
32
+ [![GitHub issues](https://img.shields.io/github/issues/silvermete0r/OIKAN.svg)](https://github.com/silvermete0r/oikan/issues)
33
+ [![Docs](https://img.shields.io/badge/docs-passing-brightgreen)](https://silvermete0r.github.io/oikan/)
34
+
35
+ ## Key Features
36
+ - 🧠 **Neuro-Symbolic ML**: Combines neural network learning with symbolic mathematics
37
+ - 📊 **Automatic Formula Extraction**: Generates human-readable mathematical expressions
38
+ - 🎯 **Scikit-learn Compatible**: Familiar `.fit()` and `.predict()` interface
39
+ - 🚀 **Production-Ready**: Export symbolic formulas for lightweight deployment
40
+ - 📈 **Multi-Task**: Supports both regression and classification problems
41
+
42
+ ## Scientific Foundation
43
+
44
+ OIKAN is based on Kolmogorov's superposition theorem, which states that any multivariate continuous function can be represented as a composition of single-variable functions. We leverage this theory by:
45
+
46
+ 1. Using neural networks to learn optimal basis functions through interpretable edge transformations
47
+ 2. Combining transformed features using learnable weights
48
+ 3. Automatically extracting human-readable symbolic formulas
49
+
50
+ ## Quick Start
51
+
52
+ ### Installation
53
+
54
+ #### Method 1: Via PyPI (Recommended)
55
+ ```bash
56
+ pip install -qU oikan
57
+ ```
58
+
59
+ #### Method 2: Local Development
60
+ ```bash
61
+ git clone https://github.com/silvermete0r/OIKAN.git
62
+ cd OIKAN
63
+ pip install -e . # Install in development mode
64
+ ```
65
+
66
+ ### Regression Example
67
+ ```python
68
+ from oikan.model import OIKANRegressor
69
+ from sklearn.model_selection import train_test_split
70
+
71
+ # Initialize model with optimal architecture
72
+ model = OIKANRegressor(
73
+ hidden_dims=[16, 8], # Network architecture
74
+ num_basis=10, # Number of basis functions
75
+ degree=3, # Polynomial degree
76
+ dropout=0.1 # Regularization
77
+ )
78
+
79
+ # Fit model (sklearn-style)
80
+ model.fit(X_train, y_train, epochs=200, lr=0.01)
81
+
82
+ # Get predictions
83
+ y_pred = model.predict(X_test)
84
+
85
+ # Save interpretable formula to file with auto-generated guidelines
86
+ # The output file will contain:
87
+ # - Detailed symbolic formulas for each feature
88
+ # - Instructions for practical implementation
89
+ # - Recommendations for production deployment
90
+ model.save_symbolic_formula("regression_formula.txt")
91
+ ```
92
+
93
+ *Example of the saved symbolic formula instructions: [outputs/regression_symbolic_formula.txt](outputs/regression_symbolic_formula.txt)*
94
+
95
+
96
+ ### Classification Example
97
+ ```python
98
+ from oikan.model import OIKANClassifier
99
+
100
+ # Similar sklearn-style interface for classification
101
+ model = OIKANClassifier(hidden_dims=[16, 8])
102
+ model.fit(X_train, y_train)
103
+ probas = model.predict_proba(X_test)
104
+
105
+ # Save classification formulas with implementation guidelines
106
+ # The output file will contain:
107
+ # - Decision boundary formulas for each class
108
+ # - Softmax application instructions
109
+ # - Production deployment recommendations
110
+ model.save_symbolic_formula("classification_formula.txt")
111
+ ```
112
+
113
+ *Example of the saved symbolic formula instructions: [outputs/classification_symbolic_formula.txt](outputs/classification_symbolic_formula.txt)*
114
+
115
+ ## Architecture Details
116
+
117
+ OIKAN implements a novel neuro-symbolic architecture based on Kolmogorov-Arnold representation theory through three specialized components:
118
+
119
+ 1. **Edge Symbolic Layer**: Learns interpretable single-variable transformations
120
+ - Adaptive basis function composition using 9 core functions:
121
+ ```python
122
+ ADVANCED_LIB = {
123
+ 'x': ('x', lambda x: x),
124
+ 'x^2': ('x^2', lambda x: x**2),
125
+ 'x^3': ('x^3', lambda x: x**3),
126
+ 'exp': ('exp(x)', lambda x: np.exp(x)),
127
+ 'log': ('log(x)', lambda x: np.log(abs(x) + 1)),
128
+ 'sqrt': ('sqrt(x)', lambda x: np.sqrt(abs(x))),
129
+ 'tanh': ('tanh(x)', lambda x: np.tanh(x)),
130
+ 'sin': ('sin(x)', lambda x: np.sin(x)),
131
+ 'abs': ('abs(x)', lambda x: np.abs(x))
132
+ }
133
+ ```
134
+ - Each input feature is transformed through these basis functions
135
+ - Learnable weights determine the optimal combination
136
+
137
+ 2. **Neural Composition Layer**: Multi-layer feature aggregation
138
+ - Direct feature-to-feature connections through KAN layers
139
+ - Dropout regularization (p=0.1 default) for robust learning
140
+ - Gradient clipping (max_norm=1.0) for stable training
141
+ - User-configurable hidden layer dimensions
142
+
143
+ 3. **Symbolic Extraction Layer**: Generates production-ready formulas
144
+ - Weight-based term pruning (threshold=1e-4)
145
+ - Automatic coefficient optimization
146
+ - Human-readable mathematical expressions
147
+ - Exportable to lightweight production code
148
+
149
+ ### Architecture Diagram
150
+
151
+ ![Architecture Diagram](docs/media/oikan_model_architecture_v0.0.2.2.png)
152
+
153
+ ### Key Design Principles
154
+
155
+ 1. **Interpretability First**: All transformations maintain clear mathematical meaning
156
+ 2. **Scikit-learn Compatibility**: Familiar `.fit()` and `.predict()` interface
157
+ 3. **Production Ready**: Export formulas as lightweight mathematical expressions
158
+ 4. **Automatic Simplification**: Remove insignificant terms (|w| < 1e-4)
159
+
160
+ ## Model Components
161
+
162
+ 1. **Symbolic Edge Functions**
163
+ ```python
164
+ class EdgeActivation(nn.Module):
165
+ """Learnable edge activation with basis functions"""
166
+ def forward(self, x):
167
+ return sum(self.weights[i] * basis[i](x) for i in range(self.num_basis))
168
+ ```
169
+
170
+ 2. **KAN Layer Implementation**
171
+ ```python
172
+ class KANLayer(nn.Module):
173
+ """Kolmogorov-Arnold Network layer"""
174
+ def forward(self, x):
175
+ edge_outputs = [self.edges[i](x[:,i]) for i in range(self.input_dim)]
176
+ return self.combine(edge_outputs)
177
+ ```
178
+
179
+ 3. **Formula Extraction**
180
+ ```python
181
+ def get_symbolic_formula(self):
182
+ """Extract interpretable mathematical expression"""
183
+ terms = []
184
+ for i, edge in enumerate(self.edges):
185
+ if abs(self.weights[i]) > threshold:
186
+ terms.append(f"{self.weights[i]:.4f} * {edge.formula}")
187
+ return " + ".join(terms)
188
+ ```
189
+
190
+ ### Key Design Principles
191
+
192
+ - **Modular Architecture**: Each component is independent and replaceable
193
+ - **Interpretability First**: All transformations maintain symbolic representations
194
+ - **Automatic Simplification**: Removes insignificant terms and combines similar expressions
195
+ - **Production Ready**: Export formulas for lightweight deployment
196
+
197
+ ## Contributing
198
+
199
+ We welcome contributions! Key areas of interest:
200
+
201
+ - Model architecture improvements
202
+ - Novel basis function implementations
203
+ - Improved symbolic extraction algorithms
204
+ - Real-world case studies and applications
205
+ - Performance optimizations
206
+
207
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
208
+
209
+ ## Citation
210
+
211
+ If you use OIKAN in your research, please cite:
212
+
213
+ ```bibtex
214
+ @software{oikan2025,
215
+ title = {OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks},
216
+ author = {Zhalgasbayev, Arman},
217
+ year = {2025},
218
+ url = {https://github.com/silvermete0r/OIKAN}
219
+ }
220
+ ```
221
+
222
+ ## License
223
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,206 @@
1
+ <!-- logo in the center -->
2
+ <div align="center">
3
+ <img src="docs/media/oikan_logo.png" alt="OIKAN Logo" width="200"/>
4
+
5
+ <h1>OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks</h1>
6
+ </div>
7
+
8
+ ## Overview
9
+ OIKAN (Optimized Interpretable Kolmogorov-Arnold Networks) is a neuro-symbolic ML framework that combines modern neural networks with classical Kolmogorov-Arnold representation theory. It provides interpretable machine learning solutions through automatic extraction of symbolic mathematical formulas from trained models.
10
+
11
+ [![PyPI version](https://badge.fury.io/py/oikan.svg)](https://badge.fury.io/py/oikan)
12
+ [![PyPI Downloads per month](https://img.shields.io/pypi/dm/oikan.svg)](https://pypistats.org/packages/oikan)
13
+ [![PyPI Total Downloads](https://static.pepy.tech/badge/oikan)](https://pepy.tech/projects/oikan)
14
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
15
+ [![GitHub issues](https://img.shields.io/github/issues/silvermete0r/OIKAN.svg)](https://github.com/silvermete0r/oikan/issues)
16
+ [![Docs](https://img.shields.io/badge/docs-passing-brightgreen)](https://silvermete0r.github.io/oikan/)
17
+
18
+ ## Key Features
19
+ - 🧠 **Neuro-Symbolic ML**: Combines neural network learning with symbolic mathematics
20
+ - 📊 **Automatic Formula Extraction**: Generates human-readable mathematical expressions
21
+ - 🎯 **Scikit-learn Compatible**: Familiar `.fit()` and `.predict()` interface
22
+ - 🚀 **Production-Ready**: Export symbolic formulas for lightweight deployment
23
+ - 📈 **Multi-Task**: Supports both regression and classification problems
24
+
25
+ ## Scientific Foundation
26
+
27
+ OIKAN is based on Kolmogorov's superposition theorem, which states that any multivariate continuous function can be represented as a composition of single-variable functions. We leverage this theory by:
28
+
29
+ 1. Using neural networks to learn optimal basis functions through interpretable edge transformations
30
+ 2. Combining transformed features using learnable weights
31
+ 3. Automatically extracting human-readable symbolic formulas
32
+
33
+ ## Quick Start
34
+
35
+ ### Installation
36
+
37
+ #### Method 1: Via PyPI (Recommended)
38
+ ```bash
39
+ pip install -qU oikan
40
+ ```
41
+
42
+ #### Method 2: Local Development
43
+ ```bash
44
+ git clone https://github.com/silvermete0r/OIKAN.git
45
+ cd OIKAN
46
+ pip install -e . # Install in development mode
47
+ ```
48
+
49
+ ### Regression Example
50
+ ```python
51
+ from oikan.model import OIKANRegressor
52
+ from sklearn.model_selection import train_test_split
53
+
54
+ # Initialize model with optimal architecture
55
+ model = OIKANRegressor(
56
+ hidden_dims=[16, 8], # Network architecture
57
+ num_basis=10, # Number of basis functions
58
+ degree=3, # Polynomial degree
59
+ dropout=0.1 # Regularization
60
+ )
61
+
62
+ # Fit model (sklearn-style)
63
+ model.fit(X_train, y_train, epochs=200, lr=0.01)
64
+
65
+ # Get predictions
66
+ y_pred = model.predict(X_test)
67
+
68
+ # Save interpretable formula to file with auto-generated guidelines
69
+ # The output file will contain:
70
+ # - Detailed symbolic formulas for each feature
71
+ # - Instructions for practical implementation
72
+ # - Recommendations for production deployment
73
+ model.save_symbolic_formula("regression_formula.txt")
74
+ ```
75
+
76
+ *Example of the saved symbolic formula instructions: [outputs/regression_symbolic_formula.txt](outputs/regression_symbolic_formula.txt)*
77
+
78
+
79
+ ### Classification Example
80
+ ```python
81
+ from oikan.model import OIKANClassifier
82
+
83
+ # Similar sklearn-style interface for classification
84
+ model = OIKANClassifier(hidden_dims=[16, 8])
85
+ model.fit(X_train, y_train)
86
+ probas = model.predict_proba(X_test)
87
+
88
+ # Save classification formulas with implementation guidelines
89
+ # The output file will contain:
90
+ # - Decision boundary formulas for each class
91
+ # - Softmax application instructions
92
+ # - Production deployment recommendations
93
+ model.save_symbolic_formula("classification_formula.txt")
94
+ ```
95
+
96
+ *Example of the saved symbolic formula instructions: [outputs/classification_symbolic_formula.txt](outputs/classification_symbolic_formula.txt)*
97
+
98
+ ## Architecture Details
99
+
100
+ OIKAN implements a novel neuro-symbolic architecture based on Kolmogorov-Arnold representation theory through three specialized components:
101
+
102
+ 1. **Edge Symbolic Layer**: Learns interpretable single-variable transformations
103
+ - Adaptive basis function composition using 9 core functions:
104
+ ```python
105
+ ADVANCED_LIB = {
106
+ 'x': ('x', lambda x: x),
107
+ 'x^2': ('x^2', lambda x: x**2),
108
+ 'x^3': ('x^3', lambda x: x**3),
109
+ 'exp': ('exp(x)', lambda x: np.exp(x)),
110
+ 'log': ('log(x)', lambda x: np.log(abs(x) + 1)),
111
+ 'sqrt': ('sqrt(x)', lambda x: np.sqrt(abs(x))),
112
+ 'tanh': ('tanh(x)', lambda x: np.tanh(x)),
113
+ 'sin': ('sin(x)', lambda x: np.sin(x)),
114
+ 'abs': ('abs(x)', lambda x: np.abs(x))
115
+ }
116
+ ```
117
+ - Each input feature is transformed through these basis functions
118
+ - Learnable weights determine the optimal combination
119
+
120
+ 2. **Neural Composition Layer**: Multi-layer feature aggregation
121
+ - Direct feature-to-feature connections through KAN layers
122
+ - Dropout regularization (p=0.1 default) for robust learning
123
+ - Gradient clipping (max_norm=1.0) for stable training
124
+ - User-configurable hidden layer dimensions
125
+
126
+ 3. **Symbolic Extraction Layer**: Generates production-ready formulas
127
+ - Weight-based term pruning (threshold=1e-4)
128
+ - Automatic coefficient optimization
129
+ - Human-readable mathematical expressions
130
+ - Exportable to lightweight production code
131
+
132
+ ### Architecture Diagram
133
+
134
+ ![Architecture Diagram](docs/media/oikan_model_architecture_v0.0.2.2.png)
135
+
136
+ ### Key Design Principles
137
+
138
+ 1. **Interpretability First**: All transformations maintain clear mathematical meaning
139
+ 2. **Scikit-learn Compatibility**: Familiar `.fit()` and `.predict()` interface
140
+ 3. **Production Ready**: Export formulas as lightweight mathematical expressions
141
+ 4. **Automatic Simplification**: Remove insignificant terms (|w| < 1e-4)
142
+
143
+ ## Model Components
144
+
145
+ 1. **Symbolic Edge Functions**
146
+ ```python
147
+ class EdgeActivation(nn.Module):
148
+ """Learnable edge activation with basis functions"""
149
+ def forward(self, x):
150
+ return sum(self.weights[i] * basis[i](x) for i in range(self.num_basis))
151
+ ```
152
+
153
+ 2. **KAN Layer Implementation**
154
+ ```python
155
+ class KANLayer(nn.Module):
156
+ """Kolmogorov-Arnold Network layer"""
157
+ def forward(self, x):
158
+ edge_outputs = [self.edges[i](x[:,i]) for i in range(self.input_dim)]
159
+ return self.combine(edge_outputs)
160
+ ```
161
+
162
+ 3. **Formula Extraction**
163
+ ```python
164
+ def get_symbolic_formula(self):
165
+ """Extract interpretable mathematical expression"""
166
+ terms = []
167
+ for i, edge in enumerate(self.edges):
168
+ if abs(self.weights[i]) > threshold:
169
+ terms.append(f"{self.weights[i]:.4f} * {edge.formula}")
170
+ return " + ".join(terms)
171
+ ```
172
+
173
+ ### Key Design Principles
174
+
175
+ - **Modular Architecture**: Each component is independent and replaceable
176
+ - **Interpretability First**: All transformations maintain symbolic representations
177
+ - **Automatic Simplification**: Removes insignificant terms and combines similar expressions
178
+ - **Production Ready**: Export formulas for lightweight deployment
179
+
180
+ ## Contributing
181
+
182
+ We welcome contributions! Key areas of interest:
183
+
184
+ - Model architecture improvements
185
+ - Novel basis function implementations
186
+ - Improved symbolic extraction algorithms
187
+ - Real-world case studies and applications
188
+ - Performance optimizations
189
+
190
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
191
+
192
+ ## Citation
193
+
194
+ If you use OIKAN in your research, please cite:
195
+
196
+ ```bibtex
197
+ @software{oikan2025,
198
+ title = {OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks},
199
+ author = {Zhalgasbayev, Arman},
200
+ year = {2025},
201
+ url = {https://github.com/silvermete0r/OIKAN}
202
+ }
203
+ ```
204
+
205
+ ## License
206
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,15 @@
1
+ class OikanError(Exception):
2
+ """Base exception class for OIKAN"""
3
+ pass
4
+
5
+ class NotFittedError(OikanError):
6
+ """Raised when prediction is attempted on unfitted model"""
7
+ pass
8
+
9
+ class DataError(OikanError):
10
+ """Raised when there are issues with input data"""
11
+ pass
12
+
13
+ class InitializationError(OikanError):
14
+ """Raised when model initialization fails"""
15
+ pass