diff --git a/.gitignore b/.gitignore
index 2872692..1a5fada 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,135 @@
/Logo.pptx
/*.jpg
test/
-security.txt
\ No newline at end of file
+security.txt
+
+# Byte-compiled / optimized / DLL files
+__pycache__/
+*.py[cod]
+*$py.class
+
+# C extensions
+*.so
+
+# Distribution / packaging
+.Python
+.idea/
+build/
+develop-eggs/
+dist/
+downloads/
+eggs/
+.eggs/
+lib/
+lib64/
+parts/
+sdist/
+var/
+wheels/
+pip-wheel-metadata/
+share/python-wheels/
+*.egg-info/
+.installed.cfg
+*.egg
+MANIFEST
+
+# PyInstaller
+# Usually these files are written by a python script from a template
+# before PyInstaller builds the exe, so as to inject date/other infos into it.
+*.manifest
+*.spec
+
+# Installer logs
+pip-log.txt
+pip-delete-this-directory.txt
+
+# Unit test / coverage reports
+htmlcov/
+.tox/
+.nox/
+.coverage
+.coverage.*
+.cache
+nosetests.xml
+coverage.xml
+*.cover
+*.py,cover
+.hypothesis/
+.pytest_cache/
+
+# Translations
+*.mo
+*.pot
+
+# Django stuff:
+*.log
+local_settings.py
+db.sqlite3
+db.sqlite3-journal
+
+# Flask stuff:
+instance/
+.webassets-cache
+
+# Scrapy stuff:
+.scrapy
+
+# Sphinx documentation
+docs/_build/
+
+# PyBuilder
+target/
+
+# Jupyter Notebook
+.ipynb_checkpoints
+
+# IPython
+profile_default/
+ipython_config.py
+
+# pyenv
+.python-version
+
+# pipenv
+# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
+# However, in case of collaboration, if having platform-specific dependencies or dependencies
+# having no cross-platform support, pipenv may install dependencies that don't work, or not
+# install all needed dependencies.
+#Pipfile.lock
+
+# PEP 582; used by e.g. github.com/David-OConnor/pyflow
+__pypackages__/
+
+# Celery stuff
+celerybeat-schedule
+celerybeat.pid
+
+# SageMath parsed files
+*.sage.py
+
+# Environments
+.env
+.venv
+env/
+venv/
+ENV/
+env.bak/
+venv.bak/
+
+# Spyder project settings
+.spyderproject
+.spyproject
+
+# Rope project settings
+.ropeproject
+
+# mkdocs documentation
+/site
+
+# mypy
+.mypy_cache/
+.dmypy.json
+dmypy.json
+
+# Pyre type checker
+.pyre/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/Py_FS.iml b/.idea/Py_FS.iml
new file mode 100644
index 0000000..74d515a
--- /dev/null
+++ b/.idea/Py_FS.iml
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..dd4c951
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..58bc467
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e4b6663
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Py_FS/__pycache__/__init__.cpython-38.pyc b/Py_FS/__pycache__/__init__.cpython-38.pyc
index 628edb4..a366bd2 100644
Binary files a/Py_FS/__pycache__/__init__.cpython-38.pyc and b/Py_FS/__pycache__/__init__.cpython-38.pyc differ
diff --git a/Py_FS/evaluation/__pycache__/_utilities.cpython-38.pyc b/Py_FS/evaluation/__pycache__/_utilities.cpython-38.pyc
index cd87701..ee64c1a 100644
Binary files a/Py_FS/evaluation/__pycache__/_utilities.cpython-38.pyc and b/Py_FS/evaluation/__pycache__/_utilities.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/MI.cpython-38.pyc b/Py_FS/filter/__pycache__/MI.cpython-38.pyc
index 138100b..9150500 100644
Binary files a/Py_FS/filter/__pycache__/MI.cpython-38.pyc and b/Py_FS/filter/__pycache__/MI.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/PCC.cpython-38.pyc b/Py_FS/filter/__pycache__/PCC.cpython-38.pyc
index de4ef89..59d53b2 100644
Binary files a/Py_FS/filter/__pycache__/PCC.cpython-38.pyc and b/Py_FS/filter/__pycache__/PCC.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/Relief.cpython-38.pyc b/Py_FS/filter/__pycache__/Relief.cpython-38.pyc
index 47c104c..4e68e62 100644
Binary files a/Py_FS/filter/__pycache__/Relief.cpython-38.pyc and b/Py_FS/filter/__pycache__/Relief.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/SCC.cpython-38.pyc b/Py_FS/filter/__pycache__/SCC.cpython-38.pyc
index 0f4db5e..de1e9ef 100644
Binary files a/Py_FS/filter/__pycache__/SCC.cpython-38.pyc and b/Py_FS/filter/__pycache__/SCC.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/__init__.cpython-38.pyc b/Py_FS/filter/__pycache__/__init__.cpython-38.pyc
index 0262db5..4741ab9 100644
Binary files a/Py_FS/filter/__pycache__/__init__.cpython-38.pyc and b/Py_FS/filter/__pycache__/__init__.cpython-38.pyc differ
diff --git a/Py_FS/filter/__pycache__/_utilities.cpython-38.pyc b/Py_FS/filter/__pycache__/_utilities.cpython-38.pyc
index 33fc9f2..866079a 100644
Binary files a/Py_FS/filter/__pycache__/_utilities.cpython-38.pyc and b/Py_FS/filter/__pycache__/_utilities.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/__pycache__/__init__.cpython-38.pyc b/Py_FS/wrapper/__pycache__/__init__.cpython-38.pyc
index 0747078..6df53bf 100644
Binary files a/Py_FS/wrapper/__pycache__/__init__.cpython-38.pyc and b/Py_FS/wrapper/__pycache__/__init__.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/AMOA.py b/Py_FS/wrapper/nature_inspired/AMOA.py
new file mode 100644
index 0000000..da1377e
--- /dev/null
+++ b/Py_FS/wrapper/nature_inspired/AMOA.py
@@ -0,0 +1,198 @@
+"""
+
+Programmer: Soumitri Chattopadhyay
+Date of Development: 29/05/2021
+This code has been developed according to the procedures mentioned in the following research article:
+"Laith A., Diabat A., Mirjalili S., Elaziz M.A., Gandomi A.H. The Arithmetic Optimization Algorithm.
+Computer Methods in Applied Mechanics and Engineering, 376, 113609 (2021)"
+
+"""
+import math
+
+import numpy as np
+import time
+import matplotlib.pyplot as plt
+
+from sklearn.model_selection import train_test_split
+from sklearn import datasets
+
+from _utilities import Solution, Data, initialize, sort_agents, display, compute_fitness, compute_accuracy
+from _transfer_functions import get_trans_function
+
+
+def AMOA(num_agents, max_iter, train_data, train_label, obj_function=compute_fitness,
+ trans_func_shape='s', save_conv_graph=False):
+ # Name of the optimizer
+ ############################### Parameters ####################################
+ # #
+ # num_agents: number of agents #
+ # max_iter: maximum number of generations #
+ # train_data: training samples of data #
+ # train_label: class labels for the training samples #
+ # obj_function: the function to maximize while doing feature selection #
+ # trans_function_shape: shape of the transfer function used #
+ # save_conv_graph: boolean value for saving convergence graph #
+ # #
+ ###############################################################################
+
+ short_name = 'AMOA'
+ agent_name = 'Agent'
+ train_data, train_label = np.array(train_data), np.array(train_label)
+ num_features = train_data.shape[1]
+ trans_function = get_trans_function(trans_func_shape)
+
+ # setting up the objectives
+ weight_acc = None
+ if (obj_function == compute_fitness):
+ weight_acc = float(input('Weight for the classification accuracy [0-1]: '))
+ obj = (obj_function, weight_acc)
+ compute_accuracy = (compute_fitness, 1) # compute_accuracy is just compute_fitness with accuracy weight as 1
+
+ # initialize agents and Leader (the agent with the max fitness)
+ agents = initialize(num_agents, num_features)
+ fitness = np.zeros(num_agents)
+ accuracy = np.zeros(num_agents)
+ Leader_agent = np.zeros((num_features,))
+ Leader_fitness = float("-inf")
+ Leader_accuracy = float("-inf")
+
+ # initialize convergence curves
+ convergence_curve = {}
+ convergence_curve['fitness'] = np.zeros(max_iter)
+ convergence_curve['feature_count'] = np.zeros(max_iter)
+
+ # format the data
+ data = Data()
+ val_size = float(input('Enter the percentage of data wanted for valdiation [0, 100]: ')) / 100
+ data.train_X, data.val_X, data.train_Y, data.val_Y = train_test_split(train_data, train_label, stratify=train_label,
+ test_size=val_size)
+
+ # create a solution object
+ solution = Solution()
+ solution.num_agents = num_agents
+ solution.max_iter = max_iter
+ solution.num_features = num_features
+ solution.obj_function = obj_function
+
+ # initializing parameters
+ lb = 0.1
+ ub = 0.9
+ eps = 1e-6
+ alpha = 5
+ mu = 0.5
+
+ # rank initial agents
+ agents, fitness = sort_agents(agents, obj, data)
+
+ # start timer
+ start_time = time.time()
+
+ for iter_no in range(max_iter):
+ print('\n================================================================================')
+ print(' Iteration - {}'.format(iter_no + 1))
+ print('================================================================================\n')
+
+ # Eq. (2)
+ MoA = moa(lb, ub, max_iter, iter_no)
+
+ # Eq. (4)
+ MoP = mop(max_iter, iter_no, alpha)
+
+ for i in range(num_agents):
+ for j in range(num_features):
+
+ r1 = np.random.random()
+
+ # Exploration phase (M,D)
+ if r1 > MoA:
+ # Eq. (3)
+ r2 = np.random.random()
+ if r2 >= 0.5:
+ agents[i,j] = Leader_agent[j] * (MoP + eps) * ((ub-lb) * mu + lb)
+ else:
+ agents[i,j] = Leader_agent[j] / (MoP + eps) * ((ub - lb) * mu + lb)
+
+ # Exploitation phase (A,S)
+ else:
+ # Eq. (5)
+ r3 = np.random.random()
+ if r3 >= 0.5:
+ agents[i,j] = Leader_agent[j] + MoP * ((ub - lb) * mu + lb)
+ else:
+ agents[i,j] = Leader_agent[j] - MoP * ((ub - lb) * mu + lb)
+
+ # convert to binary using transformation function
+ if np.random.random() < trans_function(agents[i][j]):
+ agents[i,j] = 1
+ else:
+ agents[i,j] = 0
+
+ # update final information
+ agents, fitness = sort_agents(agents, obj, data)
+ display(agents, fitness, agent_name)
+
+ # update Leader (best agent)
+ if fitness[0] > Leader_fitness:
+ Leader_agent = agents[0].copy()
+ Leader_fitness = fitness[0].copy()
+
+ convergence_curve['fitness'][iter_no] = Leader_fitness
+ convergence_curve['feature_count'][iter_no] = int(np.sum(Leader_agent))
+
+ # compute final accuracy
+ Leader_agent, Leader_accuracy = sort_agents(Leader_agent, compute_accuracy, data)
+ agents, accuracy = sort_agents(agents, compute_accuracy, data)
+
+ print('\n================================================================================')
+ print(' Final Result ')
+ print('================================================================================\n')
+ print('Leader ' + agent_name + ' Dimension : {}'.format(int(np.sum(Leader_agent))))
+ print('Leader ' + agent_name + ' Fitness : {}'.format(Leader_fitness))
+ print('Leader ' + agent_name + ' Classification Accuracy : {}'.format(Leader_accuracy))
+ print('\n================================================================================\n')
+
+ # stop timer
+ end_time = time.time()
+ exec_time = end_time - start_time
+
+ # plot convergence curves
+ iters = np.arange(max_iter) + 1
+ fig, axes = plt.subplots(2, 1)
+ fig.tight_layout(pad=5)
+ fig.suptitle('Convergence Curves')
+
+ axes[0].set_title('Convergence of Fitness over Iterations')
+ axes[0].set_xlabel('Iteration')
+ axes[0].set_ylabel('Fitness')
+ axes[0].plot(iters, convergence_curve['fitness'])
+
+ axes[1].set_title('Convergence of Feature Count over Iterations')
+ axes[1].set_xlabel('Iteration')
+ axes[1].set_ylabel('Number of Selected Features')
+ axes[1].plot(iters, convergence_curve['feature_count'])
+
+ if (save_conv_graph):
+ plt.savefig('convergence_graph_' + short_name + '.jpg')
+ plt.show()
+
+ # update attributes of solution
+ solution.best_agent = Leader_agent
+ solution.best_fitness = Leader_fitness
+ solution.best_accuracy = Leader_accuracy
+ solution.convergence_curve = convergence_curve
+ solution.final_agents = agents
+ solution.final_fitness = fitness
+ solution.final_accuracy = accuracy
+ solution.execution_time = exec_time
+
+ return solution
+
+def moa(lb,ub,max_iter,t):
+ return lb + (ub-lb) * t/max_iter
+
+def mop(max_iter,t,alpha=5):
+ return 1 - math.pow((t/max_iter), (1/alpha))
+
+if __name__ == '__main__':
+ iris = datasets.load_iris()
+ AMOA(10, 20, iris.data, iris.target, save_conv_graph=False)
diff --git a/Py_FS/wrapper/nature_inspired/AOA.py b/Py_FS/wrapper/nature_inspired/AOA.py
new file mode 100644
index 0000000..5f6e2db
--- /dev/null
+++ b/Py_FS/wrapper/nature_inspired/AOA.py
@@ -0,0 +1,267 @@
+"""
+
+Programmer: Soumitri Chattopadhyay
+Date of Development: 09/05/2021
+This code has been developed according to the procedures mentioned in the following research article:
+"Hashim, F.A., Hussain, K., Houssein, E.H. et al. Archimedes Optimization Algorithm.
+Applied Intelligence, 51, 1531–1551 (2021)"
+
+"""
+
+import numpy as np
+import time
+import matplotlib.pyplot as plt
+
+from sklearn.model_selection import train_test_split
+from sklearn import datasets
+
+from _utilities import Solution, Data, initialize, sort_agents, display, compute_fitness, compute_accuracy
+from _transfer_functions import get_trans_function
+
+
+def AOA(num_agents, max_iter, train_data, train_label, obj_function=compute_fitness,
+ trans_func_shape='s', save_conv_graph=False):
+ # Name of the optimizer
+ ############################### Parameters ####################################
+ # #
+ # num_agents: number of agents #
+ # max_iter: maximum number of generations #
+ # train_data: training samples of data #
+ # train_label: class labels for the training samples #
+ # obj_function: the function to maximize while doing feature selection #
+ # trans_function_shape: shape of the transfer function used #
+ # save_conv_graph: boolean value for saving convergence graph #
+ # #
+ ###############################################################################
+
+ short_name = 'AOA'
+ agent_name = 'Particles'
+ train_data, train_label = np.array(train_data), np.array(train_label)
+ num_features = train_data.shape[1]
+ trans_function = get_trans_function(trans_func_shape)
+
+ # setting up the objectives
+ weight_acc = None
+ if (obj_function == compute_fitness):
+ weight_acc = float(input('Weight for the classification accuracy [0-1]: '))
+ obj = (obj_function, weight_acc)
+ compute_accuracy = (compute_fitness, 1) # compute_accuracy is just compute_fitness with accuracy weight as 1
+
+ # initialize agents and Leader (the agent with the max fitness)
+ agents = initialize(num_agents, num_features)
+ fitness = np.zeros(num_agents)
+ accuracy = np.zeros(num_agents)
+ Leader_agent = np.zeros((1, num_features))
+ Leader_fitness = float("-inf")
+ Leader_accuracy = float("-inf")
+
+ # initialize convergence curves
+ convergence_curve = {}
+ convergence_curve['fitness'] = np.zeros(max_iter)
+ convergence_curve['feature_count'] = np.zeros(max_iter)
+
+ # format the data
+ data = Data()
+ val_size = float(input('Enter the percentage of data wanted for valdiation [0, 100]: ')) / 100
+ data.train_X, data.val_X, data.train_Y, data.val_Y = train_test_split(train_data, train_label, stratify=train_label,
+ test_size=val_size)
+
+ # create a solution object
+ solution = Solution()
+ solution.num_agents = num_agents
+ solution.max_iter = max_iter
+ solution.num_features = num_features
+ solution.obj_function = obj_function
+
+ # initializing parameters
+ C1, C2, C3, C4 = (2, 6, 2, 0.5)
+ upper = 0.9
+ lower = 0.1
+
+ # initializing agent attributes
+ position = np.random.rand(num_agents, num_features) # Eq. (4)
+ volume = np.random.rand(num_agents, num_features) # Eq. (5)
+ density = np.random.rand(num_agents, num_features) # Eq. (5)
+ acceleration = np.random.rand(num_agents, num_features) # Eq. (6)
+
+ # initializing leader agent attributes
+ Leader_position = np.zeros((1, num_features))
+ Leader_volume = np.zeros((1, num_features))
+ Leader_density = np.zeros((1, num_features))
+ Leader_acceleration = np.zeros((1, num_features))
+
+ # rank initial agents
+ agents, position, volume, density, acceleration, fitness = sort_agents_attr(agents, position, volume, density,
+ acceleration, obj, data)
+ Leader_agent = agents[0].copy()
+ Leader_fitness = fitness[0].copy()
+ Leader_position = position[0].copy()
+ Leader_volume = volume[0].copy()
+ Leader_density = density[0].copy()
+ Leader_acceleration = acceleration[0].copy()
+
+ # start timer
+ start_time = time.time()
+
+ for iter_no in range(max_iter):
+ print('\n================================================================================')
+ print(' Iteration - {}'.format(iter_no + 1))
+ print('================================================================================\n')
+
+ # weight factors
+ Tf = np.exp((iter_no - max_iter) / max_iter) # Eq. (8)
+ Df = np.exp((max_iter - iter_no) / max_iter) - (iter_no / max_iter) # Eq. (9)
+
+ # updating densities and volumes
+ for i in range(num_agents):
+ for j in range(num_features):
+ # Eq. (7)
+ r1, r2 = np.random.random(2)
+ # update density
+ density[i][j] = density[i][j] + r1 * (Leader_density[j] - density[i][j])
+ # update volume
+ volume[i][j] = volume[i][j] + r2 * (Leader_volume[j] - volume[i][j])
+
+ # Exploration phase
+ if Tf <= 0.5:
+ # Eq. (10)
+ for i in range(num_agents):
+ for j in range(num_features):
+ # update acceleration
+ rand_vol, rand_density, rand_accn = np.random.random(3)
+ acceleration[i][j] = (rand_density + rand_vol * rand_accn) / (density[i][j] * volume[i][j])
+ # update position
+ r1, rand_pos = np.random.random(2)
+ # Eq. (13)
+ position[i][j] = position[i][j] + C1 * r1 * Df * (rand_pos - position[i][j])
+
+ # Exploitation phase
+ else:
+ # Eq. (11)
+ for i in range(num_agents):
+ for j in range(num_features):
+ # update acceleration
+ acceleration[i][j] = (Leader_density[j] + Leader_volume[j] * Leader_acceleration[j]) / (
+ density[i][j] * volume[i][j])
+ # update position
+ r2, r3 = np.random.random(2)
+ T_ = C3 * Tf
+ P = 2 * r3 - C4
+ # Eq. (15)
+ F = 1 if P <= 0.5 else -1
+ # Eq. (14)
+ position[i][j] = position[i][j] + F * C2 * r2 * acceleration[i][j] * Df * (
+ (T_ * Leader_position[j]) - position[i][j])
+
+ # Normalize accelerations
+ for i in range(num_agents):
+ max_accn = np.amax(acceleration[i])
+ min_accn = np.amin(acceleration[i])
+ for j in range(num_features):
+ # Eq. (12)
+ acceleration[i][j] = lower + (acceleration[i][j] - min_accn) / (max_accn - min_accn) * upper
+
+ # Convert to binary: lower acceleration => closer to equilibrium
+ for i in range(num_agents):
+ for j in range(num_features):
+ if trans_function(acceleration[i][j]) < np.random.random():
+ agents[i][j] = 1
+ else:
+ agents[i][j] = 0
+
+ ###########################################################################
+
+ # update final information
+ agents, position, volume, density, acceleration, fitness = sort_agents_attr(agents, position, volume, density, acceleration, obj, data)
+ display(agents, fitness, agent_name)
+
+ # update Leader (best agent)
+ if fitness[0] > Leader_fitness:
+ Leader_agent = agents[0].copy()
+ Leader_fitness = fitness[0].copy()
+ Leader_position = position[0].copy()
+ Leader_volume = volume[0].copy()
+ Leader_density = density[0].copy()
+ Leader_acceleration = acceleration[0].copy()
+
+ convergence_curve['fitness'][iter_no] = Leader_fitness
+ convergence_curve['feature_count'][iter_no] = int(np.sum(Leader_agent))
+
+ # compute final accuracy
+ Leader_agent, Leader_accuracy = sort_agents(Leader_agent, compute_accuracy, data)
+ agents, accuracy = sort_agents(agents, compute_accuracy, data)
+
+ print('\n================================================================================')
+ print(' Final Result ')
+ print('================================================================================\n')
+ print('Leader ' + agent_name + ' Dimension : {}'.format(int(np.sum(Leader_agent))))
+ print('Leader ' + agent_name + ' Fitness : {}'.format(Leader_fitness))
+ print('Leader ' + agent_name + ' Classification Accuracy : {}'.format(Leader_accuracy))
+ print('\n================================================================================\n')
+
+ # stop timer
+ end_time = time.time()
+ exec_time = end_time - start_time
+
+ # plot convergence curves
+ iters = np.arange(max_iter) + 1
+ fig, axes = plt.subplots(2, 1)
+ fig.tight_layout(pad=5)
+ fig.suptitle('Convergence Curves')
+
+ axes[0].set_title('Convergence of Fitness over Iterations')
+ axes[0].set_xlabel('Iteration')
+ axes[0].set_ylabel('Fitness')
+ axes[0].plot(iters, convergence_curve['fitness'])
+
+ axes[1].set_title('Convergence of Feature Count over Iterations')
+ axes[1].set_xlabel('Iteration')
+ axes[1].set_ylabel('Number of Selected Features')
+ axes[1].plot(iters, convergence_curve['feature_count'])
+
+ if (save_conv_graph):
+ plt.savefig('convergence_graph_' + short_name + '.jpg')
+ plt.show()
+
+ # update attributes of solution
+ solution.best_agent = Leader_agent
+ solution.best_fitness = Leader_fitness
+ solution.best_accuracy = Leader_accuracy
+ solution.convergence_curve = convergence_curve
+ solution.final_agents = agents
+ solution.final_fitness = fitness
+ solution.final_accuracy = accuracy
+ solution.execution_time = exec_time
+
+ return solution
+
+def sort_agents_attr(agents, position, volume, density, acceleration, obj, data):
+ # sort the agents according to fitness
+ train_X, val_X, train_Y, val_Y = data.train_X, data.val_X, data.train_Y, data.val_Y
+ (obj_function, weight_acc) = obj
+
+ # if there is only one agent
+ if len(agents.shape) == 1:
+ num_agents = 1
+ fitness = obj_function(agents, train_X, val_X, train_Y, val_Y, weight_acc)
+ return agents, position, volume, density, acceleration, fitness
+
+ # for multiple agents
+ else:
+ num_agents = agents.shape[0]
+ fitness = np.zeros(num_agents)
+ for id, agent in enumerate(agents):
+ fitness[id] = obj_function(agent, train_X, val_X, train_Y, val_Y, weight_acc)
+ idx = np.argsort(-fitness)
+ sorted_agents = agents[idx].copy()
+ sorted_fitness = fitness[idx].copy()
+ sorted_position = position[idx].copy()
+ sorted_density = density[idx].copy()
+ sorted_volume = volume[idx].copy()
+ sorted_acceleration = acceleration[idx].copy()
+
+ return sorted_agents, sorted_position, sorted_volume, sorted_density, sorted_acceleration, sorted_fitness
+
+if __name__ == '__main__':
+ iris = datasets.load_iris()
+ AOA(10, 20, iris.data, iris.target, save_conv_graph=False)
diff --git a/Py_FS/wrapper/nature_inspired/SCA.py b/Py_FS/wrapper/nature_inspired/SCA.py
index b6c0f34..76a7866 100644
--- a/Py_FS/wrapper/nature_inspired/SCA.py
+++ b/Py_FS/wrapper/nature_inspired/SCA.py
@@ -183,4 +183,4 @@ def SCA(num_agents, max_iter, train_data, train_label, obj_function=compute_fitn
if __name__ == '__main__':
iris = datasets.load_iris()
- SCA(10, 20, iris.data, iris.target, save_conv_graph=True)
+ SCA(10, 20, iris.data, iris.target, save_conv_graph=False)
diff --git a/Py_FS/wrapper/nature_inspired/__init__.py b/Py_FS/wrapper/nature_inspired/__init__.py
index 4c8b07b..944bae0 100644
--- a/Py_FS/wrapper/nature_inspired/__init__.py
+++ b/Py_FS/wrapper/nature_inspired/__init__.py
@@ -9,8 +9,8 @@
from Py_FS.wrapper.nature_inspired.PSO import PSO
from Py_FS.wrapper.nature_inspired.RDA import RDA
from Py_FS.wrapper.nature_inspired.SCA import SCA
-from Py_FS.wrapper.nature_inspired.WOA import WOA
-
+from Py_FS.wrapper.nature_inspired.AOA import AOA
+from Py_FS.wrapper.nature_inspired.AMOA import AMOA
__all__ = [
'BBA',
@@ -24,5 +24,6 @@
'PSO',
'RDA',
'SCA',
- 'WOA'
+ 'AOA',
+ 'AMOA'
]
\ No newline at end of file
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/BBA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/BBA.cpython-38.pyc
index 5a2f076..730516c 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/BBA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/BBA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/CS.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/CS.cpython-38.pyc
index aa17d62..e25930f 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/CS.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/CS.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/EO.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/EO.cpython-38.pyc
index 18aa20e..1c8c1fe 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/EO.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/EO.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/GA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/GA.cpython-38.pyc
index 0eb1e07..907add7 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/GA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/GA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/GSA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/GSA.cpython-38.pyc
index d557eb1..5c7806a 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/GSA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/GSA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/GWO.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/GWO.cpython-38.pyc
index 2783a8c..2e1683e 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/GWO.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/GWO.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/HS.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/HS.cpython-38.pyc
index 00b3a4b..c3d4ce1 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/HS.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/HS.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/MA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/MA.cpython-38.pyc
index e1bd4ba..38f61d0 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/MA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/MA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/PSO.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/PSO.cpython-38.pyc
index 06bf95b..2b1c8e2 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/PSO.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/PSO.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/RDA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/RDA.cpython-38.pyc
index cdac7bc..21877ce 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/RDA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/RDA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/SCA.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/SCA.cpython-38.pyc
index fa5acd7..b76ada7 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/SCA.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/SCA.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/__init__.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/__init__.cpython-38.pyc
index 53f6547..15990b5 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/__init__.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/__init__.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/_transfer_functions.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/_transfer_functions.cpython-38.pyc
index 6f05101..82d348b 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/_transfer_functions.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/_transfer_functions.cpython-38.pyc differ
diff --git a/Py_FS/wrapper/nature_inspired/__pycache__/_utilities.cpython-38.pyc b/Py_FS/wrapper/nature_inspired/__pycache__/_utilities.cpython-38.pyc
index b0323fd..48d19f1 100644
Binary files a/Py_FS/wrapper/nature_inspired/__pycache__/_utilities.cpython-38.pyc and b/Py_FS/wrapper/nature_inspired/__pycache__/_utilities.cpython-38.pyc differ