oikan 0.0.2.4__tar.gz → 0.0.3.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.
oikan-0.0.3.1/PKG-INFO ADDED
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: oikan
3
+ Version: 0.0.3.1
4
+ Summary: OIKAN: Neuro-Symbolic ML for Scientific Discovery
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
+ Requires-Dist: tqdm
17
+ Dynamic: license-file
18
+
19
+ <!-- logo in the center -->
20
+ <div align="center">
21
+ <img src="https://raw.githubusercontent.com/silvermete0r/oikan/main/docs/media/oikan_logo.png" alt="OIKAN Logo" width="200"/>
22
+
23
+ <h1>OIKAN: Neuro-Symbolic ML for Scientific Discovery</h1>
24
+ </div>
25
+
26
+ ## Overview
27
+
28
+ OIKAN is a neuro-symbolic machine learning framework inspired by Kolmogorov-Arnold representation theorem. It combines the power of modern neural networks with techniques for extracting clear, interpretable symbolic formulas from data. OIKAN is designed to make machine learning models both accurate and Interpretable.
29
+
30
+ [![PyPI version](https://badge.fury.io/py/oikan.svg)](https://badge.fury.io/py/oikan)
31
+ [![PyPI Downloads per month](https://img.shields.io/pypi/dm/oikan.svg)](https://pypistats.org/packages/oikan)
32
+ [![PyPI Total Downloads](https://static.pepy.tech/badge/oikan)](https://pepy.tech/projects/oikan)
33
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
34
+ [![GitHub issues](https://img.shields.io/github/issues/silvermete0r/OIKAN.svg)](https://github.com/silvermete0r/oikan/issues)
35
+ [![Docs](https://img.shields.io/badge/docs-passing-brightgreen)](https://silvermete0r.github.io/oikan/)
36
+
37
+ > **Important Disclaimer**: OIKAN is an experimental research project. It is not intended for production use or real-world applications. This framework is designed for research purposes, experimentation, and academic exploration of neuro-symbolic machine learning concepts.
38
+
39
+ ## Key Features
40
+ - 🧠 **Neuro-Symbolic ML**: Combines neural network learning with symbolic mathematics
41
+ - 📊 **Automatic Formula Extraction**: Generates human-readable mathematical expressions
42
+ - 🎯 **Scikit-learn Compatible**: Familiar `.fit()` and `.predict()` interface
43
+ - 🔬 **Research-Focused**: Designed for academic exploration and experimentation
44
+ - 📈 **Multi-Task**: Supports both regression and classification problems
45
+
46
+ ## Scientific Foundation
47
+
48
+ OIKAN implements a modern interpretation of the Kolmogorov-Arnold Representation Theorem through a hybrid neural architecture:
49
+
50
+ 1. **Theoretical Foundation**: The Kolmogorov-Arnold theorem states that any continuous n-dimensional function can be decomposed into a combination of single-variable functions:
51
+
52
+ ```
53
+ f(x₁,...,xₙ) = ∑(j=0 to 2n){ φⱼ( ∑(i=1 to n) ψᵢⱼ(xᵢ) ) }
54
+ ```
55
+
56
+ where φⱼ and ψᵢⱼ are continuous univariate functions.
57
+
58
+ 2. **Neural Implementation**: OIKAN uses a specialized architecture combining:
59
+ - Feature transformation layers with interpretable basis functions
60
+ - Symbolic regression for formula extraction
61
+ - Automatic pruning of insignificant terms
62
+
63
+ ```python
64
+ class OIKANRegressor:
65
+ def __init__(self, hidden_sizes=[64, 64], activation='relu',
66
+ polynomial_degree=2, alpha=0.1):
67
+ # Neural network for learning complex patterns
68
+ self.neural_net = TabularNet(input_size, hidden_sizes, activation)
69
+ # Symbolic regression for interpretable formulas
70
+ self.symbolic_model = None
71
+
72
+ ```
73
+
74
+ 3. **Basis Functions**: Core set of interpretable transformations:
75
+ ```python
76
+ SYMBOLIC_FUNCTIONS = {
77
+ 'linear': 'x', # Direct relationships
78
+ 'quadratic': 'x^2', # Non-linear patterns
79
+ 'interaction': 'x_i x_j', # Feature interactions
80
+ 'higher_order': 'x^n' # Polynomial terms
81
+ }
82
+ ```
83
+
84
+ 4. **Formula Extraction Process**:
85
+ - Train neural network on raw data
86
+ - Generate augmented samples for better coverage
87
+ - Perform L1-regularized symbolic regression
88
+ - Prune terms with coefficients below threshold
89
+ - Export human-readable mathematical expressions
90
+
91
+ ## Quick Start
92
+
93
+ ### Installation
94
+
95
+ #### Method 1: Via PyPI (Recommended)
96
+ ```bash
97
+ pip install -qU oikan
98
+ ```
99
+
100
+ #### Method 2: Local Development
101
+ ```bash
102
+ git clone https://github.com/silvermete0r/OIKAN.git
103
+ cd OIKAN
104
+ pip install -e . # Install in development mode
105
+ ```
106
+
107
+ ### Regression Example
108
+ ```python
109
+ from oikan.model import OIKANRegressor
110
+ from sklearn.metrics import mean_squared_error
111
+
112
+ # Initialize model
113
+ model = OIKANRegressor(
114
+ hidden_sizes=[32, 32], # Hidden layer sizes
115
+ activation='relu', # Activation function (other options: 'tanh', 'leaky_relu', 'elu', 'swish', 'gelu')
116
+ augmentation_factor=5, # Augmentation factor for data generation
117
+ polynomial_degree=2, # Degree of polynomial basis functions
118
+ alpha=0.1, # L1 regularization strength
119
+ sigma=0.1, # Standard deviation of Gaussian noise for data augmentation
120
+ epochs=100, # Number of training epochs
121
+ lr=0.001, # Learning rate
122
+ batch_size=32, # Batch size for training
123
+ verbose=True # Verbose output during training
124
+ )
125
+
126
+ # Fit the model
127
+ model.fit(X_train, y_train)
128
+
129
+ # Make predictions
130
+ y_pred = model.predict(X_test)
131
+
132
+ # Evaluate performance
133
+ mse = mean_squared_error(y_test, y_pred)
134
+ print("Mean Squared Error:", mse)
135
+
136
+ # Get symbolic formula
137
+ formula = model.get_formula()
138
+ print("Symbolic Formula:", formula)
139
+
140
+ # Get feature importances
141
+ importances = model.feature_importances()
142
+ print("Feature Importances:", importances)
143
+
144
+ # Save the model (optional)
145
+ model.save("outputs/model.json")
146
+
147
+ # Load the model (optional)
148
+ loaded_model = OIKANRegressor()
149
+ loaded_model.load("outputs/model.json")
150
+ ```
151
+
152
+ *Example of the saved symbolic formula (regression model): [outputs/california_housing_model.json](outputs/california_housing_model.json)*
153
+
154
+
155
+ ### Classification Example
156
+ ```python
157
+ from oikan.model import OIKANClassifier
158
+ from sklearn.metrics import accuracy_score
159
+
160
+ # Initialize model
161
+ model = OIKANClassifier(
162
+ hidden_sizes=[32, 32], # Hidden layer sizes
163
+ activation='relu', # Activation function (other options: 'tanh', 'leaky_relu', 'elu', 'swish', 'gelu')
164
+ augmentation_factor=10, # Augmentation factor for data generation
165
+ polynomial_degree=2, # Degree of polynomial basis functions
166
+ alpha=0.1, # L1 regularization strength
167
+ sigma=0.1, # Standard deviation of Gaussian noise for data augmentation
168
+ epochs=100, # # Number of training epochs
169
+ lr=0.001, # Learning rate
170
+ batch_size=32, # Batch size for training
171
+ verbose=True # Verbose output during training
172
+ )
173
+
174
+ # Fit the model
175
+ model.fit(X_train, y_train)
176
+
177
+ # Make predictions
178
+ y_pred = model.predict(X_test)
179
+
180
+ # Evaluate performance
181
+ accuracy = model.score(X_test, y_test)
182
+ print("Accuracy:", accuracy)
183
+
184
+ # Get symbolic formulas for each class
185
+ formulas = model.get_formula()
186
+ for i, formula in enumerate(formulas):
187
+ print(f"Class {i} Formula:", formula)
188
+
189
+ # Get feature importances
190
+ importances = model.feature_importances()
191
+ print("Feature Importances:", importances)
192
+
193
+ # Save the model (optional)
194
+ model.save("outputs/model.json")
195
+
196
+ # Load the model (optional)
197
+ loaded_model = OIKANClassifier()
198
+ loaded_model.load("outputs/model.json")
199
+ ```
200
+
201
+ *Example of the saved symbolic formula (classification model): [outputs/iris_model.json](outputs/iris_model.json)*
202
+
203
+ ### Architecture Diagram
204
+
205
+ *Will be updated soon..*
206
+
207
+ ## Contributing
208
+
209
+ We welcome contributions! Key areas of interest:
210
+
211
+ - Model architecture improvements
212
+ - Novel basis function implementations
213
+ - Improved symbolic extraction algorithms
214
+ - Real-world case studies and applications
215
+ - Performance optimizations
216
+
217
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
218
+
219
+ ## Citation
220
+
221
+ If you use OIKAN in your research, please cite:
222
+
223
+ ```bibtex
224
+ @software{oikan2025,
225
+ title = {OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks},
226
+ author = {Zhalgasbayev, Arman},
227
+ year = {2025},
228
+ url = {https://github.com/silvermete0r/OIKAN}
229
+ }
230
+ ```
231
+
232
+ ## License
233
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,215 @@
1
+ <!-- logo in the center -->
2
+ <div align="center">
3
+ <img src="https://raw.githubusercontent.com/silvermete0r/oikan/main/docs/media/oikan_logo.png" alt="OIKAN Logo" width="200"/>
4
+
5
+ <h1>OIKAN: Neuro-Symbolic ML for Scientific Discovery</h1>
6
+ </div>
7
+
8
+ ## Overview
9
+
10
+ OIKAN is a neuro-symbolic machine learning framework inspired by Kolmogorov-Arnold representation theorem. It combines the power of modern neural networks with techniques for extracting clear, interpretable symbolic formulas from data. OIKAN is designed to make machine learning models both accurate and Interpretable.
11
+
12
+ [![PyPI version](https://badge.fury.io/py/oikan.svg)](https://badge.fury.io/py/oikan)
13
+ [![PyPI Downloads per month](https://img.shields.io/pypi/dm/oikan.svg)](https://pypistats.org/packages/oikan)
14
+ [![PyPI Total Downloads](https://static.pepy.tech/badge/oikan)](https://pepy.tech/projects/oikan)
15
+ [![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
16
+ [![GitHub issues](https://img.shields.io/github/issues/silvermete0r/OIKAN.svg)](https://github.com/silvermete0r/oikan/issues)
17
+ [![Docs](https://img.shields.io/badge/docs-passing-brightgreen)](https://silvermete0r.github.io/oikan/)
18
+
19
+ > **Important Disclaimer**: OIKAN is an experimental research project. It is not intended for production use or real-world applications. This framework is designed for research purposes, experimentation, and academic exploration of neuro-symbolic machine learning concepts.
20
+
21
+ ## Key Features
22
+ - 🧠 **Neuro-Symbolic ML**: Combines neural network learning with symbolic mathematics
23
+ - 📊 **Automatic Formula Extraction**: Generates human-readable mathematical expressions
24
+ - 🎯 **Scikit-learn Compatible**: Familiar `.fit()` and `.predict()` interface
25
+ - 🔬 **Research-Focused**: Designed for academic exploration and experimentation
26
+ - 📈 **Multi-Task**: Supports both regression and classification problems
27
+
28
+ ## Scientific Foundation
29
+
30
+ OIKAN implements a modern interpretation of the Kolmogorov-Arnold Representation Theorem through a hybrid neural architecture:
31
+
32
+ 1. **Theoretical Foundation**: The Kolmogorov-Arnold theorem states that any continuous n-dimensional function can be decomposed into a combination of single-variable functions:
33
+
34
+ ```
35
+ f(x₁,...,xₙ) = ∑(j=0 to 2n){ φⱼ( ∑(i=1 to n) ψᵢⱼ(xᵢ) ) }
36
+ ```
37
+
38
+ where φⱼ and ψᵢⱼ are continuous univariate functions.
39
+
40
+ 2. **Neural Implementation**: OIKAN uses a specialized architecture combining:
41
+ - Feature transformation layers with interpretable basis functions
42
+ - Symbolic regression for formula extraction
43
+ - Automatic pruning of insignificant terms
44
+
45
+ ```python
46
+ class OIKANRegressor:
47
+ def __init__(self, hidden_sizes=[64, 64], activation='relu',
48
+ polynomial_degree=2, alpha=0.1):
49
+ # Neural network for learning complex patterns
50
+ self.neural_net = TabularNet(input_size, hidden_sizes, activation)
51
+ # Symbolic regression for interpretable formulas
52
+ self.symbolic_model = None
53
+
54
+ ```
55
+
56
+ 3. **Basis Functions**: Core set of interpretable transformations:
57
+ ```python
58
+ SYMBOLIC_FUNCTIONS = {
59
+ 'linear': 'x', # Direct relationships
60
+ 'quadratic': 'x^2', # Non-linear patterns
61
+ 'interaction': 'x_i x_j', # Feature interactions
62
+ 'higher_order': 'x^n' # Polynomial terms
63
+ }
64
+ ```
65
+
66
+ 4. **Formula Extraction Process**:
67
+ - Train neural network on raw data
68
+ - Generate augmented samples for better coverage
69
+ - Perform L1-regularized symbolic regression
70
+ - Prune terms with coefficients below threshold
71
+ - Export human-readable mathematical expressions
72
+
73
+ ## Quick Start
74
+
75
+ ### Installation
76
+
77
+ #### Method 1: Via PyPI (Recommended)
78
+ ```bash
79
+ pip install -qU oikan
80
+ ```
81
+
82
+ #### Method 2: Local Development
83
+ ```bash
84
+ git clone https://github.com/silvermete0r/OIKAN.git
85
+ cd OIKAN
86
+ pip install -e . # Install in development mode
87
+ ```
88
+
89
+ ### Regression Example
90
+ ```python
91
+ from oikan.model import OIKANRegressor
92
+ from sklearn.metrics import mean_squared_error
93
+
94
+ # Initialize model
95
+ model = OIKANRegressor(
96
+ hidden_sizes=[32, 32], # Hidden layer sizes
97
+ activation='relu', # Activation function (other options: 'tanh', 'leaky_relu', 'elu', 'swish', 'gelu')
98
+ augmentation_factor=5, # Augmentation factor for data generation
99
+ polynomial_degree=2, # Degree of polynomial basis functions
100
+ alpha=0.1, # L1 regularization strength
101
+ sigma=0.1, # Standard deviation of Gaussian noise for data augmentation
102
+ epochs=100, # Number of training epochs
103
+ lr=0.001, # Learning rate
104
+ batch_size=32, # Batch size for training
105
+ verbose=True # Verbose output during training
106
+ )
107
+
108
+ # Fit the model
109
+ model.fit(X_train, y_train)
110
+
111
+ # Make predictions
112
+ y_pred = model.predict(X_test)
113
+
114
+ # Evaluate performance
115
+ mse = mean_squared_error(y_test, y_pred)
116
+ print("Mean Squared Error:", mse)
117
+
118
+ # Get symbolic formula
119
+ formula = model.get_formula()
120
+ print("Symbolic Formula:", formula)
121
+
122
+ # Get feature importances
123
+ importances = model.feature_importances()
124
+ print("Feature Importances:", importances)
125
+
126
+ # Save the model (optional)
127
+ model.save("outputs/model.json")
128
+
129
+ # Load the model (optional)
130
+ loaded_model = OIKANRegressor()
131
+ loaded_model.load("outputs/model.json")
132
+ ```
133
+
134
+ *Example of the saved symbolic formula (regression model): [outputs/california_housing_model.json](outputs/california_housing_model.json)*
135
+
136
+
137
+ ### Classification Example
138
+ ```python
139
+ from oikan.model import OIKANClassifier
140
+ from sklearn.metrics import accuracy_score
141
+
142
+ # Initialize model
143
+ model = OIKANClassifier(
144
+ hidden_sizes=[32, 32], # Hidden layer sizes
145
+ activation='relu', # Activation function (other options: 'tanh', 'leaky_relu', 'elu', 'swish', 'gelu')
146
+ augmentation_factor=10, # Augmentation factor for data generation
147
+ polynomial_degree=2, # Degree of polynomial basis functions
148
+ alpha=0.1, # L1 regularization strength
149
+ sigma=0.1, # Standard deviation of Gaussian noise for data augmentation
150
+ epochs=100, # # Number of training epochs
151
+ lr=0.001, # Learning rate
152
+ batch_size=32, # Batch size for training
153
+ verbose=True # Verbose output during training
154
+ )
155
+
156
+ # Fit the model
157
+ model.fit(X_train, y_train)
158
+
159
+ # Make predictions
160
+ y_pred = model.predict(X_test)
161
+
162
+ # Evaluate performance
163
+ accuracy = model.score(X_test, y_test)
164
+ print("Accuracy:", accuracy)
165
+
166
+ # Get symbolic formulas for each class
167
+ formulas = model.get_formula()
168
+ for i, formula in enumerate(formulas):
169
+ print(f"Class {i} Formula:", formula)
170
+
171
+ # Get feature importances
172
+ importances = model.feature_importances()
173
+ print("Feature Importances:", importances)
174
+
175
+ # Save the model (optional)
176
+ model.save("outputs/model.json")
177
+
178
+ # Load the model (optional)
179
+ loaded_model = OIKANClassifier()
180
+ loaded_model.load("outputs/model.json")
181
+ ```
182
+
183
+ *Example of the saved symbolic formula (classification model): [outputs/iris_model.json](outputs/iris_model.json)*
184
+
185
+ ### Architecture Diagram
186
+
187
+ *Will be updated soon..*
188
+
189
+ ## Contributing
190
+
191
+ We welcome contributions! Key areas of interest:
192
+
193
+ - Model architecture improvements
194
+ - Novel basis function implementations
195
+ - Improved symbolic extraction algorithms
196
+ - Real-world case studies and applications
197
+ - Performance optimizations
198
+
199
+ Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
200
+
201
+ ## Citation
202
+
203
+ If you use OIKAN in your research, please cite:
204
+
205
+ ```bibtex
206
+ @software{oikan2025,
207
+ title = {OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks},
208
+ author = {Zhalgasbayev, Arman},
209
+ year = {2025},
210
+ url = {https://github.com/silvermete0r/OIKAN}
211
+ }
212
+ ```
213
+
214
+ ## License
215
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -0,0 +1,14 @@
1
+ '''
2
+ OIKAN v0.0.3 | 2025
3
+
4
+ OIKAN is a neuro-symbolic machine learning framework inspired by Kolmogorov-Arnold representation theory. It combines the power of modern neural networks with techniques for extracting clear, interpretable symbolic formulas from data. OIKAN is designed to make machine learning models both accurate and understandable.
5
+
6
+ GitHub: https://github.com/silvermete0r/oikan
7
+ PyPI: https://pypi.org/project/oikan/
8
+ Docs: https://silvermete0r.github.io/oikan/
9
+ '''
10
+
11
+ from .model import OIKAN, OIKANClassifier, OIKANRegressor
12
+
13
+ __all__ = ['OIKAN', 'OIKANClassifier', 'OIKANRegressor']
14
+ __version__ = '0.0.3'
@@ -0,0 +1,7 @@
1
+ class OIKANError(Exception):
2
+ """Base exception for OIKAN library."""
3
+ pass
4
+
5
+ class ModelNotFittedError(OIKANError):
6
+ """Raised when a method requires a fitted model."""
7
+ pass