oikan 0.0.3.6__py3-none-any.whl → 0.0.3.7__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 +55 -21
- {oikan-0.0.3.6.dist-info → oikan-0.0.3.7.dist-info}/METADATA +1 -1
- oikan-0.0.3.7.dist-info/RECORD +10 -0
- oikan-0.0.3.6.dist-info/RECORD +0 -10
- {oikan-0.0.3.6.dist-info → oikan-0.0.3.7.dist-info}/WHEEL +0 -0
- {oikan-0.0.3.6.dist-info → oikan-0.0.3.7.dist-info}/licenses/LICENSE +0 -0
- {oikan-0.0.3.6.dist-info → oikan-0.0.3.7.dist-info}/top_level.txt +0 -0
oikan/model.py
CHANGED
@@ -319,11 +319,15 @@ class OIKAN(ABC):
|
|
319
319
|
|
320
320
|
def _generate_augmented_data(self, X):
|
321
321
|
"""Generates augmented data by adding Gaussian noise."""
|
322
|
+
if self.augmentation_factor == 1:
|
323
|
+
return np.array([]).reshape(0, X.shape[1])
|
324
|
+
|
322
325
|
X_aug = []
|
323
|
-
for _ in range(self.augmentation_factor):
|
326
|
+
for _ in range(self.augmentation_factor - 1):
|
324
327
|
noise = np.random.normal(0, self.sigma, X.shape)
|
325
328
|
X_perturbed = X + noise
|
326
329
|
X_aug.append(X_perturbed)
|
330
|
+
|
327
331
|
return np.vstack(X_aug)
|
328
332
|
|
329
333
|
def _perform_symbolic_regression(self, X, y):
|
@@ -445,16 +449,31 @@ class OIKANRegressor(OIKAN):
|
|
445
449
|
"""
|
446
450
|
X = np.asarray(X)
|
447
451
|
y = np.asarray(y).reshape(-1, 1)
|
448
|
-
|
449
|
-
if self.
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
452
|
+
|
453
|
+
if self.augmentation_factor > 1:
|
454
|
+
self._train_neural_net(X, y, output_size=1, loss_fn=nn.MSELoss())
|
455
|
+
|
456
|
+
if self.verbose:
|
457
|
+
print(f"Original data: features shape: {X.shape} | target shape: {y.shape}")
|
458
|
+
|
459
|
+
X_aug = self._generate_augmented_data(X)
|
460
|
+
|
461
|
+
self.neural_net.eval()
|
462
|
+
with torch.no_grad():
|
463
|
+
y_aug = self.neural_net(torch.tensor(X_aug, dtype=torch.float32)).detach().numpy()
|
464
|
+
|
465
|
+
if self.verbose:
|
466
|
+
print(f"Augmented data: features shape: {X_aug.shape} | target shape: {y_aug.shape}")
|
467
|
+
|
468
|
+
X_combined = np.vstack([X, X_aug])
|
469
|
+
y_combined = np.vstack([y, y_aug])
|
470
|
+
else:
|
471
|
+
if self.verbose:
|
472
|
+
print("Skipping neural network training (augmentation_factor=1)")
|
473
|
+
X_combined = X
|
474
|
+
y_combined = y
|
475
|
+
|
476
|
+
self._perform_symbolic_regression(X_combined, y_combined)
|
458
477
|
if self.verbose:
|
459
478
|
print("OIKANRegressor model training completed successfully!")
|
460
479
|
|
@@ -499,16 +518,31 @@ class OIKANClassifier(OIKAN):
|
|
499
518
|
self.classes_ = le.classes_
|
500
519
|
n_classes = len(self.classes_)
|
501
520
|
y_onehot = nn.functional.one_hot(torch.tensor(y_encoded), num_classes=n_classes).float()
|
502
|
-
|
503
|
-
if self.
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
521
|
+
|
522
|
+
if self.augmentation_factor > 1:
|
523
|
+
self._train_neural_net(X, y_onehot, output_size=n_classes, loss_fn=nn.CrossEntropyLoss())
|
524
|
+
|
525
|
+
if self.verbose:
|
526
|
+
print(f"Original data: features shape: {X.shape} | target shape: {y.shape}")
|
527
|
+
|
528
|
+
X_aug = self._generate_augmented_data(X)
|
529
|
+
|
530
|
+
self.neural_net.eval()
|
531
|
+
with torch.no_grad():
|
532
|
+
logits_aug = self.neural_net(torch.tensor(X_aug, dtype=torch.float32)).detach().numpy()
|
533
|
+
|
534
|
+
if self.verbose:
|
535
|
+
print(f"Augmented data: features shape: {X_aug.shape} | target shape: {logits_aug.shape}")
|
536
|
+
|
537
|
+
X_combined = np.vstack([X, X_aug])
|
538
|
+
y_combined = np.vstack([y_onehot.numpy(), logits_aug])
|
539
|
+
else:
|
540
|
+
if self.verbose:
|
541
|
+
print("Skipping neural network training (augmentation_factor=1)")
|
542
|
+
X_combined = X
|
543
|
+
y_combined = y_onehot.numpy()
|
544
|
+
|
545
|
+
self._perform_symbolic_regression(X_combined, y_combined)
|
512
546
|
if self.verbose:
|
513
547
|
print("OIKANClassifier model training completed successfully!")
|
514
548
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
oikan/__init__.py,sha256=zEzhm1GYLT4vNaIQ4CgZcNpUk3uo8SWnoaHYtHW_XSQ,628
|
2
|
+
oikan/exceptions.py,sha256=GhHWqy2Q5LVBcteTy4ngnqxr7FOoLNyD8dNt1kfRXyw,901
|
3
|
+
oikan/model.py,sha256=TC2-R00GOjFb7ePzKTqeYkOiVlqUK7KP0mXsnJhg9ik,24736
|
4
|
+
oikan/neural.py,sha256=PZjaffSuABuCNxu-7PinU1GR6ji0Y6xRgSQ3n5HRDxI,1572
|
5
|
+
oikan/utils.py,sha256=7UCm9obO-8Q2zhetdAkukMDOZvGSBWUL_dSF04XqM7k,8808
|
6
|
+
oikan-0.0.3.7.dist-info/licenses/LICENSE,sha256=75ASVmU-XIpN-M4LbVmJ_ibgbzbvRLVti8FhnR0BTf8,1096
|
7
|
+
oikan-0.0.3.7.dist-info/METADATA,sha256=nrel6O7TXdbtJHSNCzvqPq_IELeQWx0azfrU4Jq6sps,12749
|
8
|
+
oikan-0.0.3.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
9
|
+
oikan-0.0.3.7.dist-info/top_level.txt,sha256=XwnwKwTJddZwIvtrUsAz-l-58BJRj6HjAGWrfYi_3QY,6
|
10
|
+
oikan-0.0.3.7.dist-info/RECORD,,
|
oikan-0.0.3.6.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=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,,
|
File without changes
|
File without changes
|
File without changes
|