MemAI 0.1.2__tar.gz → 1.0.0__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.
- {memai-0.1.2 → memai-1.0.0}/MemAI.egg-info/PKG-INFO +40 -13
- {memai-0.1.2 → memai-1.0.0}/PKG-INFO +40 -13
- memai-1.0.0/README.md +127 -0
- {memai-0.1.2 → memai-1.0.0}/memai/Memai.py +33 -2
- memai-1.0.0/memai/__init__.py +1 -0
- {memai-0.1.2 → memai-1.0.0}/pyproject.toml +1 -1
- memai-0.1.2/README.md +0 -100
- memai-0.1.2/memai/__init__.py +0 -1
- {memai-0.1.2 → memai-1.0.0}/MemAI.egg-info/SOURCES.txt +0 -0
- {memai-0.1.2 → memai-1.0.0}/MemAI.egg-info/dependency_links.txt +0 -0
- {memai-0.1.2 → memai-1.0.0}/MemAI.egg-info/requires.txt +0 -0
- {memai-0.1.2 → memai-1.0.0}/MemAI.egg-info/top_level.txt +0 -0
- {memai-0.1.2 → memai-1.0.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MemAI
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Memory based AI. It doesn't require any parameters and also doesn't require huge amount of data. just needs the sufficient
|
|
5
5
|
Author: Apan Dan
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,26 +8,24 @@ Requires-Python: >=3.10
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: numpy
|
|
10
10
|
|
|
11
|
-
# Updates
|
|
12
|
-
|
|
13
|
-
- Added The display feature
|
|
14
|
-
- fixed a bug
|
|
15
|
-
|
|
16
11
|
|
|
12
|
+
# Updates
|
|
17
13
|
|
|
14
|
+
- Changed Name from ***The-Shaper*** to ***Memai***
|
|
15
|
+
- Added the **train** feature
|
|
18
16
|
|
|
19
17
|
## How to Use
|
|
20
18
|
|
|
21
19
|
### 1. Install
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
|
-
pip install
|
|
22
|
+
pip install memai
|
|
25
23
|
```
|
|
26
24
|
|
|
27
25
|
### 2. Import
|
|
28
26
|
|
|
29
27
|
```python
|
|
30
|
-
import
|
|
28
|
+
import memai
|
|
31
29
|
```
|
|
32
30
|
|
|
33
31
|
### 3. Create a Dataset
|
|
@@ -45,7 +43,7 @@ dataset = [
|
|
|
45
43
|
### 4. Create a Model
|
|
46
44
|
|
|
47
45
|
```python
|
|
48
|
-
AI =
|
|
46
|
+
AI = memai.Model("MyModel", dataset, None)
|
|
49
47
|
```
|
|
50
48
|
|
|
51
49
|
The third argument is the modulo. Use `None` for no modulo.
|
|
@@ -57,7 +55,27 @@ result = AI.think([2])
|
|
|
57
55
|
print(result)
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
### 6.
|
|
58
|
+
### 6. Train (Newly Added)
|
|
59
|
+
|
|
60
|
+
The *train* function allows the model to learn by letting it try to answer a question and then
|
|
61
|
+
adding its try to te dataset. For example
|
|
62
|
+
```python
|
|
63
|
+
AI.train([4])
|
|
64
|
+
```
|
|
65
|
+
then if you do:
|
|
66
|
+
```python
|
|
67
|
+
print(AI.dataset)
|
|
68
|
+
```
|
|
69
|
+
you will see something like:
|
|
70
|
+
|
|
71
|
+
```consolas
|
|
72
|
+
[[[1],3,-1],[[2],3,0],[[3],5,0],[[4],5,0]]
|
|
73
|
+
```
|
|
74
|
+
|
|
|
75
|
+
Newly Added sublist -----
|
|
76
|
+
|
|
77
|
+
in the terminal
|
|
78
|
+
### 7. Get Correct Outputs
|
|
61
79
|
|
|
62
80
|
```python
|
|
63
81
|
print(AI.get_correct_outputs())
|
|
@@ -65,7 +83,10 @@ print(AI.get_correct_outputs())
|
|
|
65
83
|
|
|
66
84
|
This returns the reconstructed outputs using `output - loss`.
|
|
67
85
|
|
|
68
|
-
###
|
|
86
|
+
### 8. Change the Dataset
|
|
87
|
+
|
|
88
|
+
Use the following code to change the dataset of the model.
|
|
89
|
+
*Warning : This fully changes the model. The whole dataset before will be lost after this is done.*
|
|
69
90
|
|
|
70
91
|
```python
|
|
71
92
|
AI.change_dataset([
|
|
@@ -74,9 +95,10 @@ AI.change_dataset([
|
|
|
74
95
|
])
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
## Display the Dataset
|
|
98
|
+
## 9.Display the Dataset
|
|
78
99
|
|
|
79
|
-
|
|
100
|
+
Bored of doing ```print(AI.dataset)```to see the dataset all the time? There is a solution.
|
|
101
|
+
Use `display()` to print your model's dataset in a neat table. Nothing else
|
|
80
102
|
|
|
81
103
|
```python
|
|
82
104
|
import shaper
|
|
@@ -108,3 +130,8 @@ INPUT OUTPUT LOSS
|
|
|
108
130
|
Each row shows the input, stored output, and loss.
|
|
109
131
|
|
|
110
132
|
The model will use the updated dataset for future predictions.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# Note:
|
|
137
|
+
This is actually the newer version of The-Shaper. The older vesrion has been archibed
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: MemAI
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
4
4
|
Summary: Memory based AI. It doesn't require any parameters and also doesn't require huge amount of data. just needs the sufficient
|
|
5
5
|
Author: Apan Dan
|
|
6
6
|
License-Expression: MIT
|
|
@@ -8,26 +8,24 @@ Requires-Python: >=3.10
|
|
|
8
8
|
Description-Content-Type: text/markdown
|
|
9
9
|
Requires-Dist: numpy
|
|
10
10
|
|
|
11
|
-
# Updates
|
|
12
|
-
|
|
13
|
-
- Added The display feature
|
|
14
|
-
- fixed a bug
|
|
15
|
-
|
|
16
11
|
|
|
12
|
+
# Updates
|
|
17
13
|
|
|
14
|
+
- Changed Name from ***The-Shaper*** to ***Memai***
|
|
15
|
+
- Added the **train** feature
|
|
18
16
|
|
|
19
17
|
## How to Use
|
|
20
18
|
|
|
21
19
|
### 1. Install
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
|
-
pip install
|
|
22
|
+
pip install memai
|
|
25
23
|
```
|
|
26
24
|
|
|
27
25
|
### 2. Import
|
|
28
26
|
|
|
29
27
|
```python
|
|
30
|
-
import
|
|
28
|
+
import memai
|
|
31
29
|
```
|
|
32
30
|
|
|
33
31
|
### 3. Create a Dataset
|
|
@@ -45,7 +43,7 @@ dataset = [
|
|
|
45
43
|
### 4. Create a Model
|
|
46
44
|
|
|
47
45
|
```python
|
|
48
|
-
AI =
|
|
46
|
+
AI = memai.Model("MyModel", dataset, None)
|
|
49
47
|
```
|
|
50
48
|
|
|
51
49
|
The third argument is the modulo. Use `None` for no modulo.
|
|
@@ -57,7 +55,27 @@ result = AI.think([2])
|
|
|
57
55
|
print(result)
|
|
58
56
|
```
|
|
59
57
|
|
|
60
|
-
### 6.
|
|
58
|
+
### 6. Train (Newly Added)
|
|
59
|
+
|
|
60
|
+
The *train* function allows the model to learn by letting it try to answer a question and then
|
|
61
|
+
adding its try to te dataset. For example
|
|
62
|
+
```python
|
|
63
|
+
AI.train([4])
|
|
64
|
+
```
|
|
65
|
+
then if you do:
|
|
66
|
+
```python
|
|
67
|
+
print(AI.dataset)
|
|
68
|
+
```
|
|
69
|
+
you will see something like:
|
|
70
|
+
|
|
71
|
+
```consolas
|
|
72
|
+
[[[1],3,-1],[[2],3,0],[[3],5,0],[[4],5,0]]
|
|
73
|
+
```
|
|
74
|
+
|
|
|
75
|
+
Newly Added sublist -----
|
|
76
|
+
|
|
77
|
+
in the terminal
|
|
78
|
+
### 7. Get Correct Outputs
|
|
61
79
|
|
|
62
80
|
```python
|
|
63
81
|
print(AI.get_correct_outputs())
|
|
@@ -65,7 +83,10 @@ print(AI.get_correct_outputs())
|
|
|
65
83
|
|
|
66
84
|
This returns the reconstructed outputs using `output - loss`.
|
|
67
85
|
|
|
68
|
-
###
|
|
86
|
+
### 8. Change the Dataset
|
|
87
|
+
|
|
88
|
+
Use the following code to change the dataset of the model.
|
|
89
|
+
*Warning : This fully changes the model. The whole dataset before will be lost after this is done.*
|
|
69
90
|
|
|
70
91
|
```python
|
|
71
92
|
AI.change_dataset([
|
|
@@ -74,9 +95,10 @@ AI.change_dataset([
|
|
|
74
95
|
])
|
|
75
96
|
```
|
|
76
97
|
|
|
77
|
-
## Display the Dataset
|
|
98
|
+
## 9.Display the Dataset
|
|
78
99
|
|
|
79
|
-
|
|
100
|
+
Bored of doing ```print(AI.dataset)```to see the dataset all the time? There is a solution.
|
|
101
|
+
Use `display()` to print your model's dataset in a neat table. Nothing else
|
|
80
102
|
|
|
81
103
|
```python
|
|
82
104
|
import shaper
|
|
@@ -108,3 +130,8 @@ INPUT OUTPUT LOSS
|
|
|
108
130
|
Each row shows the input, stored output, and loss.
|
|
109
131
|
|
|
110
132
|
The model will use the updated dataset for future predictions.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
# Note:
|
|
137
|
+
This is actually the newer version of The-Shaper. The older vesrion has been archibed
|
memai-1.0.0/README.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
|
|
2
|
+
# Updates
|
|
3
|
+
|
|
4
|
+
- Changed Name from ***The-Shaper*** to ***Memai***
|
|
5
|
+
- Added the **train** feature
|
|
6
|
+
|
|
7
|
+
## How to Use
|
|
8
|
+
|
|
9
|
+
### 1. Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pip install memai
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### 2. Import
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import memai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 3. Create a Dataset
|
|
22
|
+
|
|
23
|
+
Each dataset row contains `[input, output, loss]`. Inputs should be lists, even for a single value.
|
|
24
|
+
|
|
25
|
+
```python
|
|
26
|
+
dataset = [
|
|
27
|
+
[[1], 3, -1],
|
|
28
|
+
[[2], 3, 0],
|
|
29
|
+
[[3], 5, 0]
|
|
30
|
+
]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### 4. Create a Model
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
AI = memai.Model("MyModel", dataset, None)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
The third argument is the modulo. Use `None` for no modulo.
|
|
40
|
+
|
|
41
|
+
### 5. Make a Prediction
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
result = AI.think([2])
|
|
45
|
+
print(result)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 6. Train (Newly Added)
|
|
49
|
+
|
|
50
|
+
The *train* function allows the model to learn by letting it try to answer a question and then
|
|
51
|
+
adding its try to te dataset. For example
|
|
52
|
+
```python
|
|
53
|
+
AI.train([4])
|
|
54
|
+
```
|
|
55
|
+
then if you do:
|
|
56
|
+
```python
|
|
57
|
+
print(AI.dataset)
|
|
58
|
+
```
|
|
59
|
+
you will see something like:
|
|
60
|
+
|
|
61
|
+
```consolas
|
|
62
|
+
[[[1],3,-1],[[2],3,0],[[3],5,0],[[4],5,0]]
|
|
63
|
+
```
|
|
64
|
+
|
|
|
65
|
+
Newly Added sublist -----
|
|
66
|
+
|
|
67
|
+
in the terminal
|
|
68
|
+
### 7. Get Correct Outputs
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
print(AI.get_correct_outputs())
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This returns the reconstructed outputs using `output - loss`.
|
|
75
|
+
|
|
76
|
+
### 8. Change the Dataset
|
|
77
|
+
|
|
78
|
+
Use the following code to change the dataset of the model.
|
|
79
|
+
*Warning : This fully changes the model. The whole dataset before will be lost after this is done.*
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
AI.change_dataset([
|
|
83
|
+
[[4], 7, 0],
|
|
84
|
+
[[5], 8, 1]
|
|
85
|
+
])
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## 9.Display the Dataset
|
|
89
|
+
|
|
90
|
+
Bored of doing ```print(AI.dataset)```to see the dataset all the time? There is a solution.
|
|
91
|
+
Use `display()` to print your model's dataset in a neat table. Nothing else
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
import shaper
|
|
95
|
+
|
|
96
|
+
dataset = [
|
|
97
|
+
[[1], 3, -1],
|
|
98
|
+
[[2], 3, 0],
|
|
99
|
+
[[3], 5, 0]
|
|
100
|
+
]
|
|
101
|
+
|
|
102
|
+
AI = shaper.Model("MyModel", dataset, None)
|
|
103
|
+
AI.display()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Example output:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
==================================================
|
|
110
|
+
THE SHAPER: MyModel
|
|
111
|
+
==================================================
|
|
112
|
+
INPUT OUTPUT LOSS
|
|
113
|
+
--------------------------------------------------
|
|
114
|
+
[1] 3 -1
|
|
115
|
+
[2] 3 0
|
|
116
|
+
[3] 5 0
|
|
117
|
+
==================================================
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Each row shows the input, stored output, and loss.
|
|
121
|
+
|
|
122
|
+
The model will use the updated dataset for future predictions.
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# Note:
|
|
127
|
+
This is actually the newer version of The-Shaper. The older vesrion has been archibed
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
# The Shaper
|
|
2
2
|
import numpy as np
|
|
3
3
|
|
|
4
|
+
class DumbnessError(Exception):
|
|
5
|
+
pass
|
|
4
6
|
|
|
5
7
|
class Model:
|
|
6
|
-
def __init__(self, name_id, dataset, modulo=False):
|
|
8
|
+
def __init__(self, name_id : str, dataset : list, modulo=False):
|
|
7
9
|
self.name_id = name_id
|
|
8
|
-
self.dataset = dataset
|
|
10
|
+
self.dataset : list = dataset
|
|
9
11
|
self.modulo = modulo
|
|
10
12
|
|
|
11
13
|
def change_dataset(self, new_dataset):
|
|
@@ -35,6 +37,8 @@ Estimates the correct output by subtracting the loss from the stored output.
|
|
|
35
37
|
Calculates the difference between the closest stored input and the given input. Subtracting this difference adjusts the estimated output for the new input."""
|
|
36
38
|
|
|
37
39
|
|
|
40
|
+
|
|
41
|
+
|
|
38
42
|
distances = [
|
|
39
43
|
sum((c - t) ** 2 for c, t in zip(row[0], input))
|
|
40
44
|
for row in self.dataset
|
|
@@ -47,6 +51,33 @@ Calculates the difference between the closest stored input and the given input.
|
|
|
47
51
|
else:
|
|
48
52
|
return c_l[1] - c_l[2] - sum([a - b for a, b in zip(c_l[0],input)])
|
|
49
53
|
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def train(self, input:list, target: int | float):
|
|
59
|
+
"""
|
|
60
|
+
this function allows the model to learn by letting it try to predict a given input and then putting its try in the dataset.
|
|
61
|
+
"""
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
distances = [
|
|
65
|
+
sum((c - t) ** 2 for c, t in zip(row[0], input))
|
|
66
|
+
for row in self.dataset
|
|
67
|
+
]
|
|
68
|
+
try:
|
|
69
|
+
closest_index = distances.index(min(distances))
|
|
70
|
+
except ValueError or TypeError or Exception:
|
|
71
|
+
raise DumbnessError("The dataset is empty bro! Do you want the model to be as dumb as 'YOU' bro?")
|
|
72
|
+
c_l = self.dataset[closest_index]
|
|
73
|
+
|
|
74
|
+
if self.modulo:
|
|
75
|
+
result = (c_l[1] - c_l[2] - sum([a - b for a, b in zip(c_l[0],input)])) % self.modulo
|
|
76
|
+
self.dataset.append([input,result,result-target])
|
|
77
|
+
else:
|
|
78
|
+
result = c_l[1] - c_l[2] - sum([a - b for a, b in zip(c_l[0],input)])
|
|
79
|
+
self.dataset.append([input,result,result-target])
|
|
80
|
+
|
|
50
81
|
def get_correct_outputs(self):
|
|
51
82
|
"""
|
|
52
83
|
It tries to reverse engineer all the *Expected Outputs* in the datasets by substracting the random output genarated from the loss of it.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .Memai import Model
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "MemAI"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "1.0.0"
|
|
8
8
|
description = "Memory based AI. It doesn't require any parameters and also doesn't require huge amount of data. just needs the sufficient"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
memai-0.1.2/README.md
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
# Updates
|
|
2
|
-
|
|
3
|
-
- Added The display feature
|
|
4
|
-
- fixed a bug
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
## How to Use
|
|
10
|
-
|
|
11
|
-
### 1. Install
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
pip install The-Shaper
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
### 2. Import
|
|
18
|
-
|
|
19
|
-
```python
|
|
20
|
-
import shaper
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
### 3. Create a Dataset
|
|
24
|
-
|
|
25
|
-
Each dataset row contains `[input, output, loss]`. Inputs should be lists, even for a single value.
|
|
26
|
-
|
|
27
|
-
```python
|
|
28
|
-
dataset = [
|
|
29
|
-
[[1], 3, -1],
|
|
30
|
-
[[2], 3, 0],
|
|
31
|
-
[[3], 5, 0]
|
|
32
|
-
]
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
### 4. Create a Model
|
|
36
|
-
|
|
37
|
-
```python
|
|
38
|
-
AI = shaper.Model("MyModel", dataset, None)
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
The third argument is the modulo. Use `None` for no modulo.
|
|
42
|
-
|
|
43
|
-
### 5. Make a Prediction
|
|
44
|
-
|
|
45
|
-
```python
|
|
46
|
-
result = AI.think([2])
|
|
47
|
-
print(result)
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### 6. Get Correct Outputs
|
|
51
|
-
|
|
52
|
-
```python
|
|
53
|
-
print(AI.get_correct_outputs())
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
This returns the reconstructed outputs using `output - loss`.
|
|
57
|
-
|
|
58
|
-
### 7. Change the Dataset
|
|
59
|
-
|
|
60
|
-
```python
|
|
61
|
-
AI.change_dataset([
|
|
62
|
-
[[4], 7, 0],
|
|
63
|
-
[[5], 8, 1]
|
|
64
|
-
])
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Display the Dataset
|
|
68
|
-
|
|
69
|
-
Use `display()` to print your model's dataset in a neat table.
|
|
70
|
-
|
|
71
|
-
```python
|
|
72
|
-
import shaper
|
|
73
|
-
|
|
74
|
-
dataset = [
|
|
75
|
-
[[1], 3, -1],
|
|
76
|
-
[[2], 3, 0],
|
|
77
|
-
[[3], 5, 0]
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
AI = shaper.Model("MyModel", dataset, None)
|
|
81
|
-
AI.display()
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
Example output:
|
|
85
|
-
|
|
86
|
-
```text
|
|
87
|
-
==================================================
|
|
88
|
-
THE SHAPER: MyModel
|
|
89
|
-
==================================================
|
|
90
|
-
INPUT OUTPUT LOSS
|
|
91
|
-
--------------------------------------------------
|
|
92
|
-
[1] 3 -1
|
|
93
|
-
[2] 3 0
|
|
94
|
-
[3] 5 0
|
|
95
|
-
==================================================
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
Each row shows the input, stored output, and loss.
|
|
99
|
-
|
|
100
|
-
The model will use the updated dataset for future predictions.
|
memai-0.1.2/memai/__init__.py
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
from .shaper import Model
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|