pyerualjetwork 4.1.4__tar.gz → 4.1.5__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/PKG-INFO +11 -2
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/README.md +11 -2
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/__init__.py +3 -3
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/data_operations_cuda.py +5 -2
- pyerualjetwork-4.1.5/pyerualjetwork/memory_operations.py +192 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/visualizations_cuda.py +37 -43
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork.egg-info/PKG-INFO +11 -2
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork.egg-info/SOURCES.txt +1 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/setup.py +1 -1
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/activation_functions.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/activation_functions_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/data_operations.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/help.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/loss_functions.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/loss_functions_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/metrics.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/metrics_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/model_operations.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/model_operations_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/plan.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/plan_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/planeat.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/planeat_cuda.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/ui.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork/visualizations.py +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork.egg-info/dependency_links.txt +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/pyerualjetwork.egg-info/top_level.txt +0 -0
- {pyerualjetwork-4.1.4 → pyerualjetwork-4.1.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 4.1.
|
3
|
+
Version: 4.1.5
|
4
4
|
Summary: PyerualJetwork is a machine learning library written in Python for professionals, incorporating advanced, unique, new, and modern techniques.
|
5
5
|
Author: Hasan Can Beydili
|
6
6
|
Author-email: tchasancan@gmail.com
|
@@ -11,7 +11,11 @@ Description-Content-Type: text/markdown
|
|
11
11
|
|
12
12
|
Note: anaplan old name of pyerualjetwork
|
13
13
|
|
14
|
-
https://libraries.io/pypi/pyerualjetwork
|
14
|
+
Libraries.io Page: https://libraries.io/pypi/pyerualjetwork
|
15
|
+
|
16
|
+
PyPi Page: https://pypi.org/project/pyerualjetwork/
|
17
|
+
|
18
|
+
GitHub Page: https://github.com/HCB06/PyerualJetwork
|
15
19
|
|
16
20
|
|
17
21
|
pip install pyerualjetwork
|
@@ -53,6 +57,11 @@ PyerualJetwork is a machine learning library written in Python for professionals
|
|
53
57
|
Both the PLAN algorithm and the PyerualJetwork library were created by Author, and all rights are reserved by Author.
|
54
58
|
PyerualJetwork is free to use for commercial business and individual users. PyerualJetwork is written in fully functional programming with non-oop elements. PyerualJetwork consists of many functions that complement each other, which facilitates the learning process and debugging during use.
|
55
59
|
As of 12/21/2024, the library includes PLAN and PLANEAT module, but other machine learning modules are expected to be added in the future.
|
60
|
+
|
61
|
+
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
62
|
+
For example:
|
63
|
+
|
64
|
+
fit function only fits given training data(suitable for dynamic graph) but learner function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: feed_forward function, list of activation functions, loss functions. You can create your unique model architecture. Move your data to GPU or CPU or manage how much should in GPU, Its all up to you.
|
56
65
|
<br><br>
|
57
66
|
|
58
67
|
PyerualJetworket includes Plan Vision, NLPlan, PLANEAT and at the between of both, Deep Plan.<br>
|
@@ -2,7 +2,11 @@
|
|
2
2
|
|
3
3
|
Note: anaplan old name of pyerualjetwork
|
4
4
|
|
5
|
-
https://libraries.io/pypi/pyerualjetwork
|
5
|
+
Libraries.io Page: https://libraries.io/pypi/pyerualjetwork
|
6
|
+
|
7
|
+
PyPi Page: https://pypi.org/project/pyerualjetwork/
|
8
|
+
|
9
|
+
GitHub Page: https://github.com/HCB06/PyerualJetwork
|
6
10
|
|
7
11
|
|
8
12
|
pip install pyerualjetwork
|
@@ -44,6 +48,11 @@ PyerualJetwork is a machine learning library written in Python for professionals
|
|
44
48
|
Both the PLAN algorithm and the PyerualJetwork library were created by Author, and all rights are reserved by Author.
|
45
49
|
PyerualJetwork is free to use for commercial business and individual users. PyerualJetwork is written in fully functional programming with non-oop elements. PyerualJetwork consists of many functions that complement each other, which facilitates the learning process and debugging during use.
|
46
50
|
As of 12/21/2024, the library includes PLAN and PLANEAT module, but other machine learning modules are expected to be added in the future.
|
51
|
+
|
52
|
+
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
53
|
+
For example:
|
54
|
+
|
55
|
+
fit function only fits given training data(suitable for dynamic graph) but learner function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: feed_forward function, list of activation functions, loss functions. You can create your unique model architecture. Move your data to GPU or CPU or manage how much should in GPU, Its all up to you.
|
47
56
|
<br><br>
|
48
57
|
|
49
58
|
PyerualJetworket includes Plan Vision, NLPlan, PLANEAT and at the between of both, Deep Plan.<br>
|
@@ -83,4 +92,4 @@ Anaconda users can access the 'Anaconda Prompt' terminal from the Start menu and
|
|
83
92
|
|
84
93
|
After installing the module using "pip" you can now call the library module in your project environment. Use: “from pyerualjetwork import plan”. Now, you can call the necessary functions from the plan module.
|
85
94
|
|
86
|
-
The PLAN algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out ![PYERUALJETWORK USER MANUEL](https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf) file.
|
95
|
+
The PLAN algorithm will not be explained in this document. This document focuses on how professionals can integrate and use PyerualJetwork in their systems. However, briefly, the PLAN algorithm can be described as a classification algorithm. PLAN algorithm achieves this task with an incredibly energy-efficient, fast, and hyperparameter-free user-friendly approach. For more detailed information, you can check out ![PYERUALJETWORK USER MANUEL](https://github.com/HCB06/PyerualJetwork/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf) file.
|
@@ -2,7 +2,6 @@
|
|
2
2
|
import subprocess
|
3
3
|
subprocess.check_call(["pip", "install", 'setuptools==75.6.0'])
|
4
4
|
import pkg_resources
|
5
|
-
from datetime import datetime
|
6
5
|
|
7
6
|
print("Auto checking and installation dependencies for PyerualJetwork")
|
8
7
|
|
@@ -14,7 +13,8 @@ package_names = [
|
|
14
13
|
'networkx==3.3',
|
15
14
|
'numpy==1.26.4',
|
16
15
|
'matplotlib==3.9.0',
|
17
|
-
'colorama==0.4.6'
|
16
|
+
'colorama==0.4.6',
|
17
|
+
'psutil==6.1.1'
|
18
18
|
]
|
19
19
|
|
20
20
|
installed_packages = pkg_resources.working_set
|
@@ -47,7 +47,7 @@ for package_name in package_names:
|
|
47
47
|
|
48
48
|
print(f"PyerualJetwork is ready to use with {err} errors")
|
49
49
|
|
50
|
-
__version__ = "4.1.
|
50
|
+
__version__ = "4.1.5"
|
51
51
|
__update__ = "* Note: CUDA modules need cupy. Enter this command in your terminal: 'pip install cupy-cuda12x' or your cuda version.\n* Changes: https://github.com/HCB06/PyerualJetwork/blob/main/CHANGES\n* PyerualJetwork document: https://github.com/HCB06/Anaplan/blob/main/Welcome_to_PyerualJetwork/PYERUALJETWORK_USER_MANUEL_AND_LEGAL_INFORMATION(EN).pdf\n* YouTube tutorials: https://www.youtube.com/@HasanCanBeydili"
|
52
52
|
|
53
53
|
def print_version(__version__):
|
@@ -1,7 +1,6 @@
|
|
1
1
|
from tqdm import tqdm
|
2
2
|
import cupy as cp
|
3
3
|
from colorama import Fore, Style
|
4
|
-
import sys
|
5
4
|
import math
|
6
5
|
import numpy as np
|
7
6
|
|
@@ -136,6 +135,10 @@ def split(X, y, test_size, random_state=42, dtype=cp.float32, use_cpu=False):
|
|
136
135
|
x_train, x_test = X[train_indices], X[test_indices]
|
137
136
|
y_train, y_test = y[train_indices], y[test_indices]
|
138
137
|
|
138
|
+
del X
|
139
|
+
del y
|
140
|
+
cp.get_default_memory_pool.free_all_blocks()
|
141
|
+
|
139
142
|
return x_train, x_test, y_train, y_test
|
140
143
|
|
141
144
|
|
@@ -191,7 +194,7 @@ def manuel_balancer(x_train, y_train, target_samples_per_class, dtype=cp.float32
|
|
191
194
|
|
192
195
|
if use_cpu:
|
193
196
|
selected_indices = np.random.choice(
|
194
|
-
class_indices, target_samples_per_class, replace=False)
|
197
|
+
class_indices.get(), target_samples_per_class, replace=False)
|
195
198
|
else:
|
196
199
|
selected_indices = cp.random.choice(class_indices, target_samples_per_class, replace=False)
|
197
200
|
|
@@ -0,0 +1,192 @@
|
|
1
|
+
import psutil
|
2
|
+
import numpy as np
|
3
|
+
import cupy as cp
|
4
|
+
import gc
|
5
|
+
import logging
|
6
|
+
|
7
|
+
def get_available_memory():
|
8
|
+
"""
|
9
|
+
The function `get_available_memory` returns the amount of available memory in the system using the
|
10
|
+
`psutil` library.
|
11
|
+
:return: The function `get_available_memory()` returns the amount of available memory in bytes on
|
12
|
+
the system.
|
13
|
+
"""
|
14
|
+
memory = psutil.virtual_memory().available
|
15
|
+
return memory
|
16
|
+
|
17
|
+
def get_optimal_batch_size_for_cpu(x, data_size_bytes, available_memory):
|
18
|
+
"""
|
19
|
+
The function calculates the optimal batch size for a given data size and available memory based on
|
20
|
+
the size of each element.
|
21
|
+
|
22
|
+
:param x: `x` is a NumPy array representing the input data for which we want to determine the
|
23
|
+
optimal batch size for processing on the CPU
|
24
|
+
:param data_size_bytes: The `data_size_bytes` parameter represents the size of the data in bytes
|
25
|
+
that you want to process in batches
|
26
|
+
:param available_memory: The `available_memory` parameter represents the total memory available on
|
27
|
+
the CPU in bytes. This function calculates the optimal batch size for processing data based on the
|
28
|
+
provided parameters. Let me know if you need any further assistance or explanation!
|
29
|
+
:return: the optimal batch size for a given array `x` based on the available memory and the size of
|
30
|
+
each element in bytes.
|
31
|
+
"""
|
32
|
+
safe_memory = available_memory * 0.25
|
33
|
+
element_size = data_size_bytes / x.size
|
34
|
+
return int(safe_memory / (element_size * 2))
|
35
|
+
|
36
|
+
def transfer_to_cpu(x, dtype=np.float32):
|
37
|
+
"""
|
38
|
+
The `transfer_to_cpu` function converts data to a specified data type on the CPU, handling memory constraints
|
39
|
+
by batching the conversion process.
|
40
|
+
|
41
|
+
:param x: The `x` parameter in the `transfer_to_cpu` function is the input data that you want to transfer to
|
42
|
+
the CPU. It can be either a NumPy array or any other data structure that supports the `get` method
|
43
|
+
for retrieving the data
|
44
|
+
:param dtype: The `dtype` parameter in the `transfer_to_cpu` function specifies the data type to which the
|
45
|
+
input array `x` should be converted before moving it to the CPU. By default, it is set to
|
46
|
+
`np.float32`, which is a 32-bit floating-point number data type in NumPy
|
47
|
+
:return: The `transfer_to_cpu` function returns the processed data in NumPy array format with the specified
|
48
|
+
data type (`dtype`). If the input `x` is already a NumPy array with the same data type as specified,
|
49
|
+
it returns `x` as is. Otherwise, it converts the input data to the specified data type and returns
|
50
|
+
the processed NumPy array.
|
51
|
+
"""
|
52
|
+
try:
|
53
|
+
if isinstance(x, np.ndarray):
|
54
|
+
return x.astype(dtype) if x.dtype != dtype else x
|
55
|
+
|
56
|
+
data_size = x.nbytes
|
57
|
+
available_memory = get_available_memory()
|
58
|
+
|
59
|
+
logging.debug(f"Data size: {data_size/1e6:.2f}MB, Available memory: {available_memory/1e6:.2f}MB")
|
60
|
+
|
61
|
+
if data_size <= available_memory * 0.25:
|
62
|
+
final_result = np.array(x.get(), dtype=dtype, copy=False)
|
63
|
+
del x
|
64
|
+
cp.get_default_memory_pool().free_all_blocks()
|
65
|
+
return final_result
|
66
|
+
|
67
|
+
batch_size = get_optimal_batch_size_for_cpu(x, data_size, available_memory)
|
68
|
+
logging.debug(f"Using batch size: {batch_size}")
|
69
|
+
|
70
|
+
result = []
|
71
|
+
total_batches = (x.size + batch_size - 1) // batch_size
|
72
|
+
|
73
|
+
for i in range(0, x.size, batch_size):
|
74
|
+
try:
|
75
|
+
chunk = x[i:i + batch_size]
|
76
|
+
result.append(np.array(chunk.get(), dtype=dtype))
|
77
|
+
del chunk
|
78
|
+
|
79
|
+
if i > 0 and i % (batch_size * 10) == 0:
|
80
|
+
cp.get_default_memory_pool().free_all_blocks()
|
81
|
+
gc.collect()
|
82
|
+
|
83
|
+
except Exception as e:
|
84
|
+
logging.error(f"Error processing batch {i//batch_size + 1}/{total_batches}: {str(e)}")
|
85
|
+
raise
|
86
|
+
|
87
|
+
final_result = np.concatenate(result)
|
88
|
+
del x
|
89
|
+
cp.get_default_memory_pool().free_all_blocks()
|
90
|
+
gc.collect()
|
91
|
+
return final_result
|
92
|
+
|
93
|
+
except Exception as e:
|
94
|
+
logging.error(f"Error in transfer_to_cpu: {str(e)}")
|
95
|
+
raise
|
96
|
+
|
97
|
+
def get_optimal_batch_size_for_gpu(x, data_size_bytes):
|
98
|
+
"""
|
99
|
+
The function calculates the optimal batch size for a GPU based on available memory and data size.
|
100
|
+
|
101
|
+
:param x: A list or array containing the data elements that will be processed on the GPU
|
102
|
+
:param data_size_bytes: The `data_size_bytes` parameter represents the total size of the data in
|
103
|
+
bytes that you want to process on the GPU. This could be the size of a single batch of data or the
|
104
|
+
total size of the dataset, depending on how you are structuring your computations
|
105
|
+
:return: the optimal batch size that can be used for processing the given data on the GPU, based on
|
106
|
+
the available free memory on the GPU and the size of the data elements.
|
107
|
+
"""
|
108
|
+
free_memory = cp.get_default_memory_pool().free_bytes()
|
109
|
+
device_memory = cp.cuda.runtime.memGetInfo()[0]
|
110
|
+
safe_memory = min(free_memory, device_memory) * 0.25
|
111
|
+
|
112
|
+
element_size = data_size_bytes / len(x)
|
113
|
+
return int(safe_memory / (element_size * 2))
|
114
|
+
|
115
|
+
|
116
|
+
def transfer_to_gpu(x, dtype=cp.float32):
|
117
|
+
"""
|
118
|
+
The `transfer_to_gpu` function in Python converts input data to GPU arrays, optimizing memory usage by
|
119
|
+
batching and handling out-of-memory errors.
|
120
|
+
|
121
|
+
:param x: The `x` parameter in the `transfer_to_gpu` function is the input data that you want to transfer to
|
122
|
+
the GPU for processing. It can be either a NumPy array or a CuPy array. If it's a NumPy array, the
|
123
|
+
function will convert it to a CuPy array and
|
124
|
+
:param dtype: The `dtype` parameter in the `transfer_to_gpu` function specifies the data type to which the
|
125
|
+
input array `x` should be converted when moving it to the GPU. By default, it is set to
|
126
|
+
`cp.float32`, which is a 32-bit floating-point data type provided by the Cu
|
127
|
+
:return: The `transfer_to_gpu` function returns the input data `x` converted to a GPU array of type `dtype`
|
128
|
+
(default is `cp.float32`). If the input `x` is already a GPU array with the same dtype, it returns
|
129
|
+
`x` as is. If the data size of `x` exceeds 25% of the free GPU memory, it processes the data in
|
130
|
+
batches to
|
131
|
+
"""
|
132
|
+
|
133
|
+
try:
|
134
|
+
if isinstance(x, cp.ndarray):
|
135
|
+
return x.astype(dtype) if x.dtype != dtype else x
|
136
|
+
|
137
|
+
data_size = x.nbytes
|
138
|
+
free_gpu_memory = cp.cuda.runtime.memGetInfo()[0]
|
139
|
+
|
140
|
+
logging.debug(f"Data size: {data_size/1e6:.2f}MB, Free GPU memory: {free_gpu_memory/1e6:.2f}MB")
|
141
|
+
|
142
|
+
if data_size <= free_gpu_memory * 0.25:
|
143
|
+
new_x = cp.array(x, dtype=dtype, copy=False)
|
144
|
+
del x
|
145
|
+
gc.collect()
|
146
|
+
return new_x
|
147
|
+
|
148
|
+
batch_size = get_optimal_batch_size_for_gpu(x, data_size)
|
149
|
+
logging.debug(f"Using batch size: {batch_size}")
|
150
|
+
|
151
|
+
result = []
|
152
|
+
total_batches = (len(x) + batch_size - 1) // batch_size
|
153
|
+
|
154
|
+
for i in range(0, len(x), batch_size):
|
155
|
+
try:
|
156
|
+
chunk = x[i:i + batch_size]
|
157
|
+
gpu_chunk = cp.array(chunk, dtype=dtype)
|
158
|
+
result.append(gpu_chunk)
|
159
|
+
|
160
|
+
del chunk
|
161
|
+
|
162
|
+
if i > 0 and i % (batch_size * 5) == 0:
|
163
|
+
pool = cp.get_default_memory_pool()
|
164
|
+
if pool.used_bytes() > free_gpu_memory * 0.75:
|
165
|
+
pool.free_all_blocks()
|
166
|
+
gc.collect()
|
167
|
+
|
168
|
+
except cp.cuda.memory.OutOfMemoryError:
|
169
|
+
logging.error(f"GPU out of memory at batch {i//batch_size + 1}/{total_batches}")
|
170
|
+
cp.get_default_memory_pool().free_all_blocks()
|
171
|
+
batch_size = max(batch_size // 2, 1)
|
172
|
+
continue
|
173
|
+
|
174
|
+
except Exception as e:
|
175
|
+
logging.error(f"Error processing batch {i//batch_size + 1}/{total_batches}: {str(e)}")
|
176
|
+
raise
|
177
|
+
|
178
|
+
try:
|
179
|
+
final_result = cp.concatenate(result)
|
180
|
+
del result
|
181
|
+
del x
|
182
|
+
gc.collect()
|
183
|
+
cp.get_default_memory_pool().free_all_blocks()
|
184
|
+
return final_result
|
185
|
+
|
186
|
+
except Exception as e:
|
187
|
+
logging.error(f"Error concatenating results: {str(e)}")
|
188
|
+
raise
|
189
|
+
|
190
|
+
except Exception as e:
|
191
|
+
logging.error(f"Error in transfer_to_gpu: {str(e)}")
|
192
|
+
raise
|
@@ -348,8 +348,8 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activation_potentiation)
|
|
348
348
|
acc = acc_list[len(acc_list) - 1]
|
349
349
|
y_true = decode_one_hot(y_test)
|
350
350
|
|
351
|
-
y_true = cp.array(y_true)
|
352
|
-
y_preds = cp.array(y_preds)
|
351
|
+
y_true = cp.array(y_true, copy=False)
|
352
|
+
y_preds = cp.array(y_preds, copy=False)
|
353
353
|
Class = cp.unique(decode_one_hot(y_test))
|
354
354
|
|
355
355
|
precision, recall, f1 = metrics(y_test, y_preds)
|
@@ -358,7 +358,7 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activation_potentiation)
|
|
358
358
|
cm = confusion_matrix(y_true, y_preds, len(Class))
|
359
359
|
fig, axs = plt.subplots(2, 2, figsize=(16, 12))
|
360
360
|
|
361
|
-
sns.heatmap(cm, annot=True, fmt='d', ax=axs[0, 0])
|
361
|
+
sns.heatmap(cm.get(), annot=True, fmt='d', ax=axs[0, 0])
|
362
362
|
axs[0, 0].set_title("Confusion Matrix")
|
363
363
|
axs[0, 0].set_xlabel("Predicted Class")
|
364
364
|
axs[0, 0].set_ylabel("Actual Class")
|
@@ -393,7 +393,7 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activation_potentiation)
|
|
393
393
|
fpr, tpr, thresholds = roc_curve(y_true_copy, y_preds_copy)
|
394
394
|
|
395
395
|
roc_auc = cp.trapz(tpr, fpr)
|
396
|
-
axs[1, 0].plot(fpr, tpr, color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
396
|
+
axs[1, 0].plot(fpr.get(), tpr.get(), color='darkorange', lw=2, label=f'ROC curve (area = {roc_auc:.2f})')
|
397
397
|
axs[1, 0].plot([0, 1], [0, 1], color='navy', lw=2, linestyle='--')
|
398
398
|
axs[1, 0].set_xlim([0.0, 1.0])
|
399
399
|
axs[1, 0].set_ylim([0.0, 1.05])
|
@@ -405,7 +405,7 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activation_potentiation)
|
|
405
405
|
|
406
406
|
|
407
407
|
metric = ['Precision', 'Recall', 'F1 Score', 'Accuracy']
|
408
|
-
values = [precision, recall, f1, acc]
|
408
|
+
values = [precision, recall, f1, acc.get()]
|
409
409
|
colors = ['#1f77b4', '#ff7f0e', '#2ca02c', '#d62728']
|
410
410
|
|
411
411
|
|
@@ -432,35 +432,29 @@ def plot_evaluate(x_test, y_test, y_preds, acc_list, W, activation_potentiation)
|
|
432
432
|
|
433
433
|
grid = cp.c_[xx.ravel(), yy.ravel()]
|
434
434
|
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
Z = [None] * len(grid_full)
|
441
|
-
|
442
|
-
predict_progress = initialize_loading_bar(total=len(grid_full),leave=False,
|
443
|
-
bar_format=bar_format_normal ,desc="Predicts For Decision Boundary",ncols= 65)
|
435
|
+
grid_full = cp.zeros((grid.shape[0], x_test.shape[1]), dtype=cp.float32)
|
436
|
+
grid_full[:, feature_indices] = grid
|
437
|
+
|
438
|
+
Z = [None] * len(grid_full)
|
444
439
|
|
445
|
-
|
440
|
+
predict_progress = initialize_loading_bar(total=len(grid_full),leave=False,
|
441
|
+
bar_format=bar_format_normal ,desc="Predicts For Decision Boundary",ncols= 65)
|
446
442
|
|
447
|
-
|
448
|
-
predict_progress.update(1)
|
443
|
+
for i in range(len(grid_full)):
|
449
444
|
|
450
|
-
|
445
|
+
Z[i] = cp.argmax(predict_model_ram(grid_full[i], W=W, activation_potentiation=activation_potentiation))
|
446
|
+
predict_progress.update(1)
|
451
447
|
|
452
|
-
|
453
|
-
Z = Z.reshape(xx.shape)
|
448
|
+
predict_progress.close()
|
454
449
|
|
455
|
-
|
456
|
-
|
457
|
-
axs[1,1].set_xlabel(f'Feature {0 + 1}')
|
458
|
-
axs[1,1].set_ylabel(f'Feature {1 + 1}')
|
459
|
-
axs[1,1].set_title('Decision Boundary')
|
450
|
+
Z = cp.array(Z)
|
451
|
+
Z = Z.reshape(xx.shape)
|
460
452
|
|
461
|
-
|
462
|
-
|
463
|
-
|
453
|
+
axs[1,1].contourf(xx.get(), yy.get(), Z.get(), alpha=0.8)
|
454
|
+
axs[1,1].scatter(x_test[:, feature_indices[0]].get(), x_test[:, feature_indices[1]].get(), c=decode_one_hot(y_test).get(), edgecolors='k', marker='o', s=20, alpha=0.9)
|
455
|
+
axs[1,1].set_xlabel(f'Feature {0 + 1}')
|
456
|
+
axs[1,1].set_ylabel(f'Feature {1 + 1}')
|
457
|
+
axs[1,1].set_title('Decision Boundary')
|
464
458
|
|
465
459
|
plt.show()
|
466
460
|
|
@@ -487,13 +481,13 @@ def plot_decision_boundary(x, y, activation_potentiation, W, artist=None, ax=Non
|
|
487
481
|
for i in range(len(grid_full)):
|
488
482
|
Z[i] = cp.argmax(predict_model_ram(grid_full[i], W=W, activation_potentiation=activation_potentiation))
|
489
483
|
|
490
|
-
Z = cp.array(Z)
|
484
|
+
Z = cp.array(Z, dtype=cp.int32)
|
491
485
|
Z = Z.reshape(xx.shape)
|
492
486
|
|
493
487
|
if ax is None:
|
494
488
|
|
495
|
-
plt.contourf(xx, yy, Z, alpha=0.8)
|
496
|
-
plt.scatter(x[:, feature_indices[0]], x[:, feature_indices[1]], c=decode_one_hot(y), edgecolors='k', marker='o', s=20, alpha=0.9)
|
489
|
+
plt.contourf(xx.get(), yy.get(), Z.get(), alpha=0.8)
|
490
|
+
plt.scatter(x[:, feature_indices[0]].get(), x[:, feature_indices[1]].get(), c=decode_one_hot(y).get(), edgecolors='k', marker='o', s=20, alpha=0.9)
|
497
491
|
plt.xlabel(f'Feature {0 + 1}')
|
498
492
|
plt.ylabel(f'Feature {1 + 1}')
|
499
493
|
plt.title('Decision Boundary')
|
@@ -503,8 +497,8 @@ def plot_decision_boundary(x, y, activation_potentiation, W, artist=None, ax=Non
|
|
503
497
|
else:
|
504
498
|
|
505
499
|
try:
|
506
|
-
art1_1 = ax[1, 0].contourf(xx, yy, Z, alpha=0.8)
|
507
|
-
art1_2 = ax[1, 0].scatter(x[:, feature_indices[0]], x[:, feature_indices[1]], c=decode_one_hot(y), edgecolors='k', marker='o', s=20, alpha=0.9)
|
500
|
+
art1_1 = ax[1, 0].contourf(xx.get(), yy.get(), Z.get(), alpha=0.8)
|
501
|
+
art1_2 = ax[1, 0].scatter(x[:, feature_indices[0]].get(), x[:, feature_indices[1]].get(), c=decode_one_hot(y).get(), edgecolors='k', marker='o', s=20, alpha=0.9)
|
508
502
|
ax[1, 0].set_xlabel(f'Feature {0 + 1}')
|
509
503
|
ax[1, 0].set_ylabel(f'Feature {1 + 1}')
|
510
504
|
ax[1, 0].set_title('Decision Boundary')
|
@@ -513,11 +507,11 @@ def plot_decision_boundary(x, y, activation_potentiation, W, artist=None, ax=Non
|
|
513
507
|
|
514
508
|
except:
|
515
509
|
|
516
|
-
art1_1 = ax
|
517
|
-
art1_2 = ax
|
518
|
-
ax
|
519
|
-
ax
|
520
|
-
ax
|
510
|
+
art1_1 = ax.contourf(xx.get(), yy.get(), Z.get(), alpha=0.8)
|
511
|
+
art1_2 = ax.scatter(x[:, feature_indices[0]].get(), x[:, feature_indices[1]].get(), c=decode_one_hot(y).get(), edgecolors='k', marker='o', s=20, alpha=0.9)
|
512
|
+
ax.set_xlabel(f'Feature {0 + 1}')
|
513
|
+
ax.set_ylabel(f'Feature {1 + 1}')
|
514
|
+
ax.set_title('Decision Boundary')
|
521
515
|
|
522
516
|
|
523
517
|
return art1_1, art1_2
|
@@ -558,7 +552,7 @@ def plot_decision_space(x, y, y_preds=None, s=100, color='tab20'):
|
|
558
552
|
if y_preds[i] == cls:
|
559
553
|
class_points.append(X_pca[i])
|
560
554
|
|
561
|
-
class_points = cp.array(class_points)
|
555
|
+
class_points = cp.array(class_points, dtype=y.dtype)
|
562
556
|
|
563
557
|
|
564
558
|
if len(class_points) > 2:
|
@@ -604,7 +598,7 @@ def neuron_history(LTPW, ax1, row, col, class_count, artist5, data, fig1, acc=Fa
|
|
604
598
|
|
605
599
|
def initialize_visualization_for_fit(val, show_training, neurons_history, x_train, y_train):
|
606
600
|
"""Initializes the visualization setup based on the parameters."""
|
607
|
-
from .
|
601
|
+
from .data_operations_cuda import find_closest_factors
|
608
602
|
visualization_objects = {}
|
609
603
|
|
610
604
|
if show_training:
|
@@ -640,7 +634,7 @@ def initialize_visualization_for_fit(val, show_training, neurons_history, x_trai
|
|
640
634
|
|
641
635
|
def update_weight_visualization_for_fit(ax, LTPW, artist2):
|
642
636
|
"""Updates the weight visualization plot."""
|
643
|
-
art2 = ax.imshow(LTPW, interpolation='sinc', cmap='viridis')
|
637
|
+
art2 = ax.imshow(LTPW.get(), interpolation='sinc', cmap='viridis')
|
644
638
|
artist2.append([art2])
|
645
639
|
|
646
640
|
|
@@ -680,7 +674,7 @@ def display_visualization_for_fit(fig, artist_list, interval):
|
|
680
674
|
|
681
675
|
def initialize_visualization_for_learner(show_history, neurons_history, neural_web_history, x_train, y_train):
|
682
676
|
"""Initialize all visualization components"""
|
683
|
-
from .
|
677
|
+
from .data_operations_cuda import find_closest_factors
|
684
678
|
viz_objects = {}
|
685
679
|
|
686
680
|
if show_history:
|
@@ -728,7 +722,7 @@ def update_history_plots_for_learner(viz_objects, depth_list, loss_list, best_ac
|
|
728
722
|
hist = viz_objects['history']
|
729
723
|
|
730
724
|
# Loss plot
|
731
|
-
art1 = hist['ax'][0].plot(depth_list, loss_list, color='r', markersize=6, linewidth=2)
|
725
|
+
art1 = hist['ax'][0].plot(depth_list.get(), loss_list.get(), color='r', markersize=6, linewidth=2)
|
732
726
|
hist['ax'][0].set_title('Test Loss Over Depth')
|
733
727
|
hist['artist1'].append(art1)
|
734
728
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyerualjetwork
|
3
|
-
Version: 4.1.
|
3
|
+
Version: 4.1.5
|
4
4
|
Summary: PyerualJetwork is a machine learning library written in Python for professionals, incorporating advanced, unique, new, and modern techniques.
|
5
5
|
Author: Hasan Can Beydili
|
6
6
|
Author-email: tchasancan@gmail.com
|
@@ -11,7 +11,11 @@ Description-Content-Type: text/markdown
|
|
11
11
|
|
12
12
|
Note: anaplan old name of pyerualjetwork
|
13
13
|
|
14
|
-
https://libraries.io/pypi/pyerualjetwork
|
14
|
+
Libraries.io Page: https://libraries.io/pypi/pyerualjetwork
|
15
|
+
|
16
|
+
PyPi Page: https://pypi.org/project/pyerualjetwork/
|
17
|
+
|
18
|
+
GitHub Page: https://github.com/HCB06/PyerualJetwork
|
15
19
|
|
16
20
|
|
17
21
|
pip install pyerualjetwork
|
@@ -53,6 +57,11 @@ PyerualJetwork is a machine learning library written in Python for professionals
|
|
53
57
|
Both the PLAN algorithm and the PyerualJetwork library were created by Author, and all rights are reserved by Author.
|
54
58
|
PyerualJetwork is free to use for commercial business and individual users. PyerualJetwork is written in fully functional programming with non-oop elements. PyerualJetwork consists of many functions that complement each other, which facilitates the learning process and debugging during use.
|
55
59
|
As of 12/21/2024, the library includes PLAN and PLANEAT module, but other machine learning modules are expected to be added in the future.
|
60
|
+
|
61
|
+
PyerualJetwork ready for both eager execution(like PyTorch) and static graph(like Tensorflow) concepts because PyerualJetwork using only functions.
|
62
|
+
For example:
|
63
|
+
|
64
|
+
fit function only fits given training data(suitable for dynamic graph) but learner function learns and optimize entire architecture(suitable for static graph). Or more deeper eager executions PyerualJetwork have: feed_forward function, list of activation functions, loss functions. You can create your unique model architecture. Move your data to GPU or CPU or manage how much should in GPU, Its all up to you.
|
56
65
|
<br><br>
|
57
66
|
|
58
67
|
PyerualJetworket includes Plan Vision, NLPlan, PLANEAT and at the between of both, Deep Plan.<br>
|
@@ -8,6 +8,7 @@ pyerualjetwork/data_operations_cuda.py
|
|
8
8
|
pyerualjetwork/help.py
|
9
9
|
pyerualjetwork/loss_functions.py
|
10
10
|
pyerualjetwork/loss_functions_cuda.py
|
11
|
+
pyerualjetwork/memory_operations.py
|
11
12
|
pyerualjetwork/metrics.py
|
12
13
|
pyerualjetwork/metrics_cuda.py
|
13
14
|
pyerualjetwork/model_operations.py
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|