oikan 0.0.3.4__py3-none-any.whl → 0.0.3.6__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.
- oikan/model.py +17 -6
- oikan/neural.py +1 -0
- {oikan-0.0.3.4.dist-info → oikan-0.0.3.6.dist-info}/METADATA +40 -15
- oikan-0.0.3.6.dist-info/RECORD +10 -0
- {oikan-0.0.3.4.dist-info → oikan-0.0.3.6.dist-info}/WHEEL +1 -1
- oikan-0.0.3.4.dist-info/RECORD +0 -10
- {oikan-0.0.3.4.dist-info → oikan-0.0.3.6.dist-info}/licenses/LICENSE +0 -0
- {oikan-0.0.3.4.dist-info → oikan-0.0.3.6.dist-info}/top_level.txt +0 -0
oikan/model.py
CHANGED
@@ -41,10 +41,12 @@ class OIKAN(ABC):
|
|
41
41
|
Whether to display training progress.
|
42
42
|
evaluate_nn : bool, optional (default=False)
|
43
43
|
Whether to evaluate neural network performance before full training.
|
44
|
+
random_state: int, optional (default=None)
|
45
|
+
Random seed for reproducibility.
|
44
46
|
"""
|
45
47
|
def __init__(self, hidden_sizes=[64, 64], activation='relu', augmentation_factor=10,
|
46
48
|
alpha=0.1, sigma=0.1, epochs=100, lr=0.001, batch_size=32,
|
47
|
-
verbose=False, evaluate_nn=False, top_k=5):
|
49
|
+
verbose=False, evaluate_nn=False, top_k=5, random_state=None):
|
48
50
|
if not isinstance(hidden_sizes, list) or not all(isinstance(x, int) and x > 0 for x in hidden_sizes):
|
49
51
|
raise InvalidParameterError("hidden_sizes must be a list of positive integers")
|
50
52
|
if activation not in ['relu', 'tanh', 'leaky_relu', 'elu', 'swish', 'gelu']:
|
@@ -78,6 +80,11 @@ class OIKAN(ABC):
|
|
78
80
|
self.neural_net = None
|
79
81
|
self.symbolic_model = None
|
80
82
|
self.evaluation_done = False
|
83
|
+
self.random_state = random_state
|
84
|
+
|
85
|
+
if self.random_state is not None:
|
86
|
+
torch.manual_seed(self.random_state)
|
87
|
+
np.random.seed(self.random_state)
|
81
88
|
|
82
89
|
@abstractmethod
|
83
90
|
def fit(self, X, y):
|
@@ -93,11 +100,11 @@ class OIKAN(ABC):
|
|
93
100
|
|
94
101
|
Parameter:
|
95
102
|
--------
|
96
|
-
type : str, optional (default='original') other options: '
|
97
|
-
'original' returns the original formula with coefficients, '
|
103
|
+
type : str, optional (default='original') other options: 'sympy', 'latex'
|
104
|
+
'original' returns the original formula with coefficients, 'sympy' returns sympy simplified formula.
|
98
105
|
"""
|
99
|
-
if type.lower() not in ['original', '
|
100
|
-
raise InvalidParameterError("Invalid type. Choose 'original', '
|
106
|
+
if type.lower() not in ['original', 'sympy', 'latex']:
|
107
|
+
raise InvalidParameterError("Invalid type. Choose 'original', 'sympy', 'latex'.")
|
101
108
|
if self.symbolic_model is None:
|
102
109
|
raise ValueError("Model not fitted yet.")
|
103
110
|
basis_functions = self.symbolic_model['basis_functions']
|
@@ -114,7 +121,7 @@ class OIKAN(ABC):
|
|
114
121
|
for i in range(len(coef)) if coef[i] != 0])
|
115
122
|
formulas.append(f"Class {self.classes_[c]}: {formula if formula else '0'}")
|
116
123
|
return formulas
|
117
|
-
elif type.lower() == '
|
124
|
+
elif type.lower() == 'sympy':
|
118
125
|
if 'coefficients' in self.symbolic_model:
|
119
126
|
formula = sympify_formula(self.symbolic_model['basis_functions'], self.symbolic_model['coefficients'], self.symbolic_model['n_features'])
|
120
127
|
return formula
|
@@ -448,6 +455,8 @@ class OIKANRegressor(OIKAN):
|
|
448
455
|
if self.verbose:
|
449
456
|
print(f"Augmented data: features shape: {X_aug.shape} | target shape: {y_aug.shape}")
|
450
457
|
self._perform_symbolic_regression(X_aug, y_aug)
|
458
|
+
if self.verbose:
|
459
|
+
print("OIKANRegressor model training completed successfully!")
|
451
460
|
|
452
461
|
def predict(self, X):
|
453
462
|
"""
|
@@ -500,6 +509,8 @@ class OIKANClassifier(OIKAN):
|
|
500
509
|
if self.verbose:
|
501
510
|
print(f"Augmented data: features shape: {X_aug.shape} | target shape: {logits_aug.shape}")
|
502
511
|
self._perform_symbolic_regression(X_aug, logits_aug)
|
512
|
+
if self.verbose:
|
513
|
+
print("OIKANClassifier model training completed successfully!")
|
503
514
|
|
504
515
|
def predict(self, X):
|
505
516
|
"""
|
oikan/neural.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: oikan
|
3
|
-
Version: 0.0.3.
|
3
|
+
Version: 0.0.3.6
|
4
4
|
Summary: OIKAN: Neuro-Symbolic ML for Scientific Discovery
|
5
5
|
Author: Arman Zhalgasbayev
|
6
6
|
License: MIT
|
@@ -35,6 +35,11 @@ OIKAN is a neuro-symbolic machine learning framework inspired by Kolmogorov-Arno
|
|
35
35
|
[](https://github.com/silvermete0r/oikan/issues)
|
36
36
|
[](https://silvermete0r.github.io/oikan/)
|
37
37
|
|
38
|
+
[](https://deepwiki.com/silvermete0r/oikan)
|
39
|
+
[](https://colab.research.google.com/github/silvermete0r/oikan/blob/main/examples/oikan-v0-0-3-get-started-template-notebook.ipynb)
|
40
|
+
[](https://www.kaggle.com/code/armanzhalgasbayev/oikan-v0-0-3-get-started-template-notebook)
|
41
|
+
[](https://github.com/silvermete0r/awesome-oikan)
|
42
|
+
|
38
43
|
> **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.
|
39
44
|
|
40
45
|
## Key Features
|
@@ -62,14 +67,15 @@ OIKAN implements a modern interpretation of the Kolmogorov-Arnold Representation
|
|
62
67
|
- Automatic pruning of insignificant terms
|
63
68
|
|
64
69
|
```python
|
65
|
-
|
66
|
-
|
70
|
+
class OIKAN:
|
71
|
+
def __init__(self, hidden_sizes=[64, 64], activation='relu',
|
67
72
|
polynomial_degree=2, alpha=0.1):
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
+
# Neural network for learning complex patterns
|
74
|
+
self.neural_net = TabularNet(input_size, hidden_sizes, activation)
|
75
|
+
# Data augmentation for better coverage
|
76
|
+
self.augmented_data = self.augment_data(X, y, augmentation_factor=5)
|
77
|
+
# Symbolic regression for interpretable formulas
|
78
|
+
self.symbolic_regression = SymbolicRegression(alpha=alpha)
|
73
79
|
```
|
74
80
|
|
75
81
|
3. **Basis Functions**: Core set of interpretable transformations:
|
@@ -109,9 +115,20 @@ cd OIKAN
|
|
109
115
|
pip install -e . # Install in development mode
|
110
116
|
```
|
111
117
|
|
118
|
+
#### System Requirements
|
119
|
+
|
120
|
+
| Requirement | Details |
|
121
|
+
|-------------------|--------------------------------------|
|
122
|
+
| Python | Version 3.7 or higher |
|
123
|
+
| Operating System | Platform independent (Windows/macOS/Linux) |
|
124
|
+
| Memory | Recommended minimum 4GB RAM |
|
125
|
+
| Disk Space | ~100MB for installation (including dependencies) |
|
126
|
+
| GPU | Optional (for faster training) |
|
127
|
+
| Dependencies | torch, numpy, scikit-learn, sympy, tqdm |
|
128
|
+
|
112
129
|
### Regression Example
|
113
130
|
```python
|
114
|
-
from oikan
|
131
|
+
from oikan import OIKANRegressor
|
115
132
|
from sklearn.metrics import mean_squared_error
|
116
133
|
|
117
134
|
# Initialize model
|
@@ -126,7 +143,8 @@ model = OIKANRegressor(
|
|
126
143
|
lr=0.001, # Learning rate
|
127
144
|
batch_size=32, # Batch size for training
|
128
145
|
verbose=True, # Verbose output during training
|
129
|
-
evaluate_nn=True # Validate neural network performance before full process
|
146
|
+
evaluate_nn=True, # Validate neural network performance before full process
|
147
|
+
random_state=42 # Random seed for reproducibility
|
130
148
|
)
|
131
149
|
|
132
150
|
# Fit the model
|
@@ -140,7 +158,7 @@ mse = mean_squared_error(y_test, y_pred)
|
|
140
158
|
print("Mean Squared Error:", mse)
|
141
159
|
|
142
160
|
# Get symbolic formula
|
143
|
-
formula = model.get_formula() # default: type='original' -> returns all formula without pruning | other options: '
|
161
|
+
formula = model.get_formula() # default: type='original' -> returns all formula without pruning | other options: 'sympy' -> simplified formula using sympy; 'latex' -> LaTeX format
|
144
162
|
print("Symbolic Formula:", formula)
|
145
163
|
|
146
164
|
# Get feature importances
|
@@ -160,7 +178,7 @@ loaded_model.load("outputs/model.json")
|
|
160
178
|
|
161
179
|
### Classification Example
|
162
180
|
```python
|
163
|
-
from oikan
|
181
|
+
from oikan import OIKANClassifier
|
164
182
|
from sklearn.metrics import accuracy_score
|
165
183
|
|
166
184
|
# Initialize model
|
@@ -175,7 +193,8 @@ model = OIKANClassifier(
|
|
175
193
|
lr=0.001, # Learning rate
|
176
194
|
batch_size=32, # Batch size for training
|
177
195
|
verbose=True, # Verbose output during training
|
178
|
-
evaluate_nn=True # Validate neural network performance before full process
|
196
|
+
evaluate_nn=True, # Validate neural network performance before full process
|
197
|
+
random_state=42 # Random seed for reproducibility
|
179
198
|
)
|
180
199
|
|
181
200
|
# Fit the model
|
@@ -189,7 +208,7 @@ accuracy = model.score(X_test, y_test)
|
|
189
208
|
print("Accuracy:", accuracy)
|
190
209
|
|
191
210
|
# Get symbolic formulas for each class
|
192
|
-
formulas = model.get_formula() # default: type='original' -> returns all formula without pruning | other options: '
|
211
|
+
formulas = model.get_formula() # default: type='original' -> returns all formula without pruning | other options: 'sympy' -> simplified formula using sympy; 'latex' -> LaTeX format
|
193
212
|
for i, formula in enumerate(formulas):
|
194
213
|
print(f"Class {i} Formula:", formula)
|
195
214
|
|
@@ -209,7 +228,13 @@ loaded_model.load("outputs/model.json")
|
|
209
228
|
|
210
229
|
### Architecture Diagram
|
211
230
|
|
212
|
-
|
231
|
+
#### High-Level Architecture:
|
232
|
+
|
233
|
+

|
234
|
+
|
235
|
+
#### UML Diagram:
|
236
|
+
|
237
|
+
-architecture-oop.png)
|
213
238
|
|
214
239
|
## OIKAN Symbolic Model Compilers
|
215
240
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
oikan/__init__.py,sha256=zEzhm1GYLT4vNaIQ4CgZcNpUk3uo8SWnoaHYtHW_XSQ,628
|
2
|
+
oikan/exceptions.py,sha256=GhHWqy2Q5LVBcteTy4ngnqxr7FOoLNyD8dNt1kfRXyw,901
|
3
|
+
oikan/model.py,sha256=vnn5THWhndj5-P2Vsa78CErsT24LVmjMd8CnWeW09Kg,23663
|
4
|
+
oikan/neural.py,sha256=PZjaffSuABuCNxu-7PinU1GR6ji0Y6xRgSQ3n5HRDxI,1572
|
5
|
+
oikan/utils.py,sha256=7UCm9obO-8Q2zhetdAkukMDOZvGSBWUL_dSF04XqM7k,8808
|
6
|
+
oikan-0.0.3.6.dist-info/licenses/LICENSE,sha256=75ASVmU-XIpN-M4LbVmJ_ibgbzbvRLVti8FhnR0BTf8,1096
|
7
|
+
oikan-0.0.3.6.dist-info/METADATA,sha256=P-07jTsmYsaANnQOjh_mzmjLk1Q9rqN665CBp_FKYjU,12749
|
8
|
+
oikan-0.0.3.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
oikan-0.0.3.6.dist-info/top_level.txt,sha256=XwnwKwTJddZwIvtrUsAz-l-58BJRj6HjAGWrfYi_3QY,6
|
10
|
+
oikan-0.0.3.6.dist-info/RECORD,,
|
oikan-0.0.3.4.dist-info/RECORD
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
oikan/__init__.py,sha256=zEzhm1GYLT4vNaIQ4CgZcNpUk3uo8SWnoaHYtHW_XSQ,628
|
2
|
-
oikan/exceptions.py,sha256=GhHWqy2Q5LVBcteTy4ngnqxr7FOoLNyD8dNt1kfRXyw,901
|
3
|
-
oikan/model.py,sha256=-EqCxTMeejdOCh2T08ibc87YIDYWUvybFe7jfb1XYbA,23167
|
4
|
-
oikan/neural.py,sha256=wxmGgzmtpwJ3lvH6u6D4i4BiAzg018czrIdw49phSCY,1558
|
5
|
-
oikan/utils.py,sha256=7UCm9obO-8Q2zhetdAkukMDOZvGSBWUL_dSF04XqM7k,8808
|
6
|
-
oikan-0.0.3.4.dist-info/licenses/LICENSE,sha256=75ASVmU-XIpN-M4LbVmJ_ibgbzbvRLVti8FhnR0BTf8,1096
|
7
|
-
oikan-0.0.3.4.dist-info/METADATA,sha256=P-2T0xtWDyTNhfZYknMK0TPm9EcvCUBD-O2bdfCwpFc,11138
|
8
|
-
oikan-0.0.3.4.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
|
9
|
-
oikan-0.0.3.4.dist-info/top_level.txt,sha256=XwnwKwTJddZwIvtrUsAz-l-58BJRj6HjAGWrfYi_3QY,6
|
10
|
-
oikan-0.0.3.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|