oikan 0.0.1.4__tar.gz → 0.0.1.6__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.1.6/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Arman Zhalgasbayev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: oikan
3
- Version: 0.0.1.4
3
+ Version: 0.0.1.6
4
4
  Summary: OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks
5
5
  Author: Arman Zhalgasbayev
6
6
  License: MIT
@@ -9,6 +9,7 @@ Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
+ License-File: LICENSE
12
13
  Requires-Dist: torch
13
14
  Requires-Dist: numpy
14
15
  Requires-Dist: sympy
@@ -49,8 +50,16 @@ from oikan.symbolic import extract_symbolic_formula
49
50
 
50
51
  model = OIKAN(input_dim=2, output_dim=1)
51
52
  train(model, (X_train, y_train))
53
+
54
+ visualize_regression(model, X, y)
55
+
52
56
  formula = extract_symbolic_formula(model, X_test, mode='regression')
53
57
  print("Extracted formula:", formula)
58
+
59
+ plot_symbolic_formula(model, X_test, mode='regression')
60
+
61
+ latex_formula = extract_latex_formula(model, X_test, mode='regression')
62
+ print("LaTeX:", latex_formula)
54
63
  ```
55
64
 
56
65
  ### Classification Example
@@ -62,10 +71,14 @@ from oikan.symbolic import extract_symbolic_formula, plot_symbolic_formula, extr
62
71
 
63
72
  model = OIKAN(input_dim=2, output_dim=2)
64
73
  train_classification(model, (X_train, y_train))
74
+
65
75
  visualize_classification(model, X_test, y_test)
76
+
66
77
  formula = extract_symbolic_formula(model, X_test, mode='classification')
67
78
  print("Extracted formula:", formula)
79
+
68
80
  plot_symbolic_formula(model, X_test, mode='classification')
81
+
69
82
  latex_formula = extract_latex_formula(model, X_test, mode='classification')
70
83
  print("LaTeX:", latex_formula)
71
84
  ```
@@ -32,8 +32,16 @@ from oikan.symbolic import extract_symbolic_formula
32
32
 
33
33
  model = OIKAN(input_dim=2, output_dim=1)
34
34
  train(model, (X_train, y_train))
35
+
36
+ visualize_regression(model, X, y)
37
+
35
38
  formula = extract_symbolic_formula(model, X_test, mode='regression')
36
39
  print("Extracted formula:", formula)
40
+
41
+ plot_symbolic_formula(model, X_test, mode='regression')
42
+
43
+ latex_formula = extract_latex_formula(model, X_test, mode='regression')
44
+ print("LaTeX:", latex_formula)
37
45
  ```
38
46
 
39
47
  ### Classification Example
@@ -45,10 +53,14 @@ from oikan.symbolic import extract_symbolic_formula, plot_symbolic_formula, extr
45
53
 
46
54
  model = OIKAN(input_dim=2, output_dim=2)
47
55
  train_classification(model, (X_train, y_train))
56
+
48
57
  visualize_classification(model, X_test, y_test)
58
+
49
59
  formula = extract_symbolic_formula(model, X_test, mode='classification')
50
60
  print("Extracted formula:", formula)
61
+
51
62
  plot_symbolic_formula(model, X_test, mode='classification')
63
+
52
64
  latex_formula = extract_latex_formula(model, X_test, mode='classification')
53
65
  print("LaTeX:", latex_formula)
54
66
  ```
@@ -0,0 +1,69 @@
1
+ import numpy as np
2
+ import matplotlib.pyplot as plt
3
+ import torch
4
+
5
+ def visualize_regression(model, X, y):
6
+ model.eval()
7
+ with torch.no_grad():
8
+ X_tensor = torch.FloatTensor(X)
9
+ y_pred = model(X_tensor).numpy()
10
+
11
+ plt.figure(figsize=(10, 6))
12
+ plt.scatter(X[:, 0], y, color='blue', label='True')
13
+ plt.scatter(X[:, 0], y_pred, color='red', label='Predicted')
14
+ plt.legend()
15
+ plt.show()
16
+
17
+ def visualize_classification(model, X, y):
18
+ model.eval()
19
+
20
+ if X.shape[1] > 2:
21
+ # SVD projection for high-dimensional inputs.
22
+ X_mean = np.mean(X, axis=0)
23
+ X_centered = X - X_mean
24
+ _, _, Vt = np.linalg.svd(X_centered, full_matrices=False)
25
+ principal = Vt[:2] # shape: (2, D)
26
+ X_proj = (X - X_mean) @ principal.T
27
+
28
+ x1, x2 = X_proj[:, 0], X_proj[:, 1]
29
+ x_min, x_max = x1.min() - 1, x1.max() + 1
30
+ y_min, y_max = x2.min() - 1, x2.max() + 1
31
+ xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100),
32
+ np.linspace(y_min, y_max, 100))
33
+ grid_2d = np.c_[xx.ravel(), yy.ravel()]
34
+ # Inverse transform grid points to original space.
35
+ X_grid = X_mean + grid_2d @ principal
36
+
37
+ with torch.no_grad():
38
+ X_grid_tensor = torch.FloatTensor(X_grid)
39
+ Z = model(X_grid_tensor)
40
+ Z = torch.argmax(Z, dim=1).numpy()
41
+ Z = Z.reshape(xx.shape)
42
+
43
+ plt.figure(figsize=(10, 8))
44
+ plt.contourf(xx, yy, Z, alpha=0.4)
45
+ plt.scatter(X_proj[:, 0], X_proj[:, 1], c=y, alpha=0.8)
46
+ plt.title("Classification Visualization (SVD Projection)")
47
+ plt.show()
48
+
49
+ else:
50
+ x1 = X[:, 0]
51
+ x2 = X[:, 1]
52
+ x_min, x_max = x1.min() - 1, x1.max() + 1
53
+ y_min, y_max = x2.min() - 1, x2.max() + 1
54
+ xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100),
55
+ np.linspace(y_min, y_max, 100))
56
+ grid_2d = np.c_[xx.ravel(), yy.ravel()]
57
+ X_grid = grid_2d
58
+
59
+ with torch.no_grad():
60
+ X_grid_tensor = torch.FloatTensor(X_grid)
61
+ Z = model(X_grid_tensor)
62
+ Z = torch.argmax(Z, dim=1).numpy()
63
+ Z = Z.reshape(xx.shape)
64
+
65
+ plt.figure(figsize=(10, 8))
66
+ plt.contourf(xx, yy, Z, alpha=0.4)
67
+ plt.scatter(X[:, 0], X[:, 1], c=y, alpha=0.8)
68
+ plt.title("Classification Visualization")
69
+ plt.show()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: oikan
3
- Version: 0.0.1.4
3
+ Version: 0.0.1.6
4
4
  Summary: OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks
5
5
  Author: Arman Zhalgasbayev
6
6
  License: MIT
@@ -9,6 +9,7 @@ Classifier: License :: OSI Approved :: MIT License
9
9
  Classifier: Operating System :: OS Independent
10
10
  Requires-Python: >=3.7
11
11
  Description-Content-Type: text/markdown
12
+ License-File: LICENSE
12
13
  Requires-Dist: torch
13
14
  Requires-Dist: numpy
14
15
  Requires-Dist: sympy
@@ -49,8 +50,16 @@ from oikan.symbolic import extract_symbolic_formula
49
50
 
50
51
  model = OIKAN(input_dim=2, output_dim=1)
51
52
  train(model, (X_train, y_train))
53
+
54
+ visualize_regression(model, X, y)
55
+
52
56
  formula = extract_symbolic_formula(model, X_test, mode='regression')
53
57
  print("Extracted formula:", formula)
58
+
59
+ plot_symbolic_formula(model, X_test, mode='regression')
60
+
61
+ latex_formula = extract_latex_formula(model, X_test, mode='regression')
62
+ print("LaTeX:", latex_formula)
54
63
  ```
55
64
 
56
65
  ### Classification Example
@@ -62,10 +71,14 @@ from oikan.symbolic import extract_symbolic_formula, plot_symbolic_formula, extr
62
71
 
63
72
  model = OIKAN(input_dim=2, output_dim=2)
64
73
  train_classification(model, (X_train, y_train))
74
+
65
75
  visualize_classification(model, X_test, y_test)
76
+
66
77
  formula = extract_symbolic_formula(model, X_test, mode='classification')
67
78
  print("Extracted formula:", formula)
79
+
68
80
  plot_symbolic_formula(model, X_test, mode='classification')
81
+
69
82
  latex_formula = extract_latex_formula(model, X_test, mode='classification')
70
83
  print("LaTeX:", latex_formula)
71
84
  ```
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  setup.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "oikan"
7
- version = "0.0.1.4"
7
+ version = "0.0.1.6"
8
8
  description = "OIKAN: Optimized Interpretable Kolmogorov-Arnold Networks"
9
9
  authors = [{name = "Arman Zhalgasbayev"}]
10
10
  dependencies = [
@@ -1,37 +0,0 @@
1
- import numpy as np
2
- import matplotlib.pyplot as plt
3
- import torch
4
-
5
- def visualize_regression(model, X, y):
6
- model.eval()
7
- with torch.no_grad():
8
- X_tensor = torch.FloatTensor(X)
9
- y_pred = model(X_tensor).numpy()
10
-
11
- plt.figure(figsize=(10, 6))
12
- plt.scatter(X[:, 0], y, color='blue', label='True')
13
- plt.scatter(X[:, 0], y_pred, color='red', label='Predicted')
14
- plt.legend()
15
- plt.show()
16
-
17
- def visualize_classification(model, X, y):
18
- model.eval()
19
-
20
- # Create a mesh grid
21
- x_min, x_max = X[:, 0].min() - 1, X[:, 0].max() + 1
22
- y_min, y_max = X[:, 1].min() - 1, X[:, 1].max() + 1
23
- xx, yy = np.meshgrid(np.linspace(x_min, x_max, 100),
24
- np.linspace(y_min, y_max, 100))
25
-
26
- # Make predictions
27
- with torch.no_grad():
28
- X_grid = torch.FloatTensor(np.c_[xx.ravel(), yy.ravel()])
29
- Z = model(X_grid)
30
- Z = torch.argmax(Z, dim=1).numpy()
31
- Z = Z.reshape(xx.shape)
32
-
33
- # Plot
34
- plt.figure(figsize=(10, 8))
35
- plt.contourf(xx, yy, Z, alpha=0.4)
36
- plt.scatter(X[:, 0], X[:, 1], c=y, alpha=0.8)
37
- plt.show()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes