ITMO_FS.wrappers.randomized.TPhMGWO

class ITMO_FS.wrappers.randomized.TPhMGWO(wolfNumber=10, seed=1, alpha=0.01, classifier=KNeighborsClassifier(n_neighbors=10), foldNumber=5, iteration_number=30, Mp=0.5, errorRate=<function mean_squared_error>)

Performs Grey Wolf optimization with Two-Phase Mutation

Parameters:
  • wolfNumber (integer) – Number of search agents used to find solution for features selection problem
  • seed (integer) – Random seed used to initialize np.random.seed()
  • alpha (float) – weight of importance of classification accuracy Note alpha is used in equation that counts fitness as fitness = alpha * score + beta * |selected_features| / |features| where alpha = 1 - beta
  • classifier (classifier used for training and testing on provided dataset) – Note that algorithm implementation assumes that classifier has fit, predict methods Default algorithm uses sklearn.neighbors.KNeighborsClassifier
  • foldNumber (integer) – fold number to train and test classifier
  • iteration_number (integer) – number of iterations of algorithm
  • Mp (float) – probability of mutation

Notes

For more details see this paper.

Examples

>>> import numpy as np
>>> from ITMO_FS.wrappers.randomized import TPhMGWO
>>> from sklearn.datasets import make_classification
>>> tphmgwo = TPhMGWO()
>>> x, y = make_classification(500, 50, n_informative = 10, n_redundant = 30, n_repeated = 10, shuffle = True)
>>> result = tphmgwo.run(x, y)
>>> print(np.where(result == 1))
__init__(wolfNumber=10, seed=1, alpha=0.01, classifier=KNeighborsClassifier(n_neighbors=10), foldNumber=5, iteration_number=30, Mp=0.5, errorRate=<function mean_squared_error>)

Initialize self. See help(type(self)) for accurate signature.

exception ClassifierMethodsException
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

run(X, y)

Runs the TPhGWO algorithm on the specified dataset.

Parameters:
  • X (array-like, shape (n_samples,n_features)) – The input samples.
  • y (array-like, shape (n_samples)) – The classes for the samples.
Returns:

array-like, shape (n_samples,n_selected_features)

Return type:

0-1 array where 1 means feature is selected and 0 not