incremental_learner.onln_gfmm

General fuzzy min-max neural network trained by the original incremental learning algorithm.

class hbbrain.numerical_data.incremental_learner.onln_gfmm.OnlineGFMM(theta=0.5, theta_min=1, gamma=1, alpha=0.9, is_draw=False, V=None, W=None, C=None)[source]

Bases: BaseGFMMClassifier

General fuzzy min-max neural network model using the original incremental learning algorithm.

This class implements the original online learning algorithm to train the general fuzzy min-max neural network. The details of this algorithm can be found in [1].

Note

This implementation uses the accelerated mechanism presented in [2] to accelerate the improved online learning algorithm. Compared to the original online learning algorithm proposed in [1], this implementation uses the similarity measure between two hyperboxes by shortest gap distance presented in [3] for overlap test. In addition, we extend the number of hyperbox contraction cases from four in the original algorithm to eight cases aiming to cover more overlapping cases between two hyperboxes.

Parameters:
thetafloat, optional, default=0.5

Maximum hyperbox size for numerical features.

theta_minfloat, optional, default=1

Minimum value of the maximum hyperbox size for continuous features so that the training loop is still performed. If the value of theta_min is larger than the value of theta, it will be automatically assigned a value equal to theta.

gammafloat or ndarray of shape (n_features,), optional, default=1

A sensitivity parameter describing the speed of decreasing of the membership function in each continuous feature.

alphafloat, optional, default=0.9

Multiplier factor to reduce the value of maximum hyperbox size after each training loop.

is_drawboolean, optional, default=False

Whether the construction of hyperboxes can be progressively shown during the training process on a canvas window.

Varray-like of shape (n_hyperboxes, n_features)

A matrix stores all minimal points for numerical features of all existing hyperboxes, in which each row is a minimal point of a hyperbox.

Warray-like of shape (n_hyperboxes, n_features)

A matrix stores all maximal points for numerical features of all existing hyperboxes, in which each row is a minimal point of a hyperbox.

Carray-like of shape (n_hyperboxes,)

A vector stores all class labels correponding to existing hyperboxes.

References

[1] (1,2)

B. Gabrys and A. Bargiela, “General fuzzy min-max neural network for clustering and classification,” IEEE Transactions on Neural Networks, vol. 11, no. 3, pp. 769-783, 2000.

[2]

T.T. Khuat and B. Gabrys, “Accelerated learning algorithms of general fuzzy min-max neural network using a novel hyperbox selection rule,” Information Sciences, vol. 547, pp. 887-909, 2021.

[3]

B. Gabrys, “Agglomerative learning algorithms for general fuzzy min-max neural network”, Journal of VLSI Signal Processing Systems for Signal, Image and Video Technology, vol. 32, no. 1, pp. 67-82, 2002.

Examples

>>> from sklearn.datasets import load_iris
>>> from hbbrain.numerical_data.incremental_learner.onln_gfmm import OnlineGFMM
>>> X, y = load_iris(return_X_y=True)
>>> from sklearn.preprocessing import MinMaxScaler
>>> scaler = MinMaxScaler()
>>> scaler.fit(X)
MinMaxScaler()
>>> X = scaler.transform(X)
>>> clf = OnlineGFMM(theta=0.1).fit(X, y)
>>> clf.predict(X[[10, 50, 100]])
array([0, 1, 2])
Attributes:
is_exist_missing_valueboolean

Is there any missing values in continuous features in the training data.

elapsed_training_timefloat

Training time in seconds.

n_passesint

Number of training loops.

Methods

delay([delay_constant])

Delay a time period to display hyperboxes

draw_hyperbox_and_boundary([window_name, ...])

Draw the existing hyperboxes and their decision boundaries among classes

fit(X, y)

Fit the model according to the given training data using the original incremental learning algorithm.

get_n_hyperboxes()

Get number of hyperboxes in the trained hyperbox-based model

get_params([deep])

Get parameters for this estimator.

get_sample_explanation(xl, xu)

Get useful information for explaining the reason behind the predicted result for the input pattern

initialise_canvas_graph([n_dims, ...])

Initialise a canvas to draw hyperboxes

predict(X)

Predict class labels for samples in X.

predict_proba(X)

Predict class probabilities of the input samples X.

predict_with_membership(X)

Predict class membership values of the input samples X.

score(X, y[, sample_weight])

Return the mean accuracy on the given test data and labels.

set_params(**params)

Set the parameters of this estimator.

show_sample_explanation(xl, xu, ...[, ...])

Show explanation for predicted results of an input pattern under the form of parallel coordinates or hyperboxes in 2D or 3D planes.

simple_pruning(Xl_val, Xu_val, y_val[, ...])

Simply prune low qualitied hyperboxes based on a pre-defined accuracy threshold for each hyperbox

fit(X, y)[source]

Fit the model according to the given training data using the original incremental learning algorithm.

Parameters:
Xarray-like of shape (n_samples, n_features)

Training vector, where n_samples is the number of samples and n_features is the number of features.

yarray-like of shape (n_samples,)

Target vector relative to X.

Returns:
selfobject

Fitted general fuzzy min-max neural network.

get_sample_explanation(xl, xu)[source]

Get useful information for explaining the reason behind the predicted result for the input pattern

Parameters:
xlndarray of shape (n_feature,)

Minimum point of the input pattern which needs to be explained.

xundarray of shape (n_feature,)

Maximum point of the input pattern which needs to be explained.

Returns:
y_predint

The predicted class of the input pattern

dict_mem_val_classesdictionary

A dictionary stores all membership values for all classes. The key is class label and the value is the corresponding membership value.

dict_min_point_classesdictionary

A dictionary stores all mimimal points of hyperboxes having the maximum membership value for each class. The key is the class label and the value is the minimal points of all hyperboxes coressponding to each class

dict_max_point_classesdictionary

A dictionary stores all maximal points of hyperboxes having the maximum membership value for each class. The key is the class label and the value is the maximal points of all hyperboxes coressponding to each class

simple_pruning(Xl_val, Xu_val, y_val, acc_threshold=0.5, keep_empty_boxes=False)[source]

Simply prune low qualitied hyperboxes based on a pre-defined accuracy threshold for each hyperbox

Parameters:
Xl_valarray-like of shape (n_samples, n_features)

The data matrix contains lower bounds of validation patterns.

Xu_valarray-like of shape (n_samples, n_features)

The data matrix contains upper bounds of validation patterns.

y_valndarray of shape (n_samples,)

A vector contains the true class label corresponding to each validation pattern.

acc_thresholdfloat, optional, default=0.5

The minimum accuracy for each hyperbox to be kept unchanged.

keep_empty_boxesboolean, optional, default=False

Whether to keep the hyperboxes which do not join the prediction process on the validation set. If True, keep them, else the decision for keeping or removing based on the classification accuracy on the validation dataset

Returns:
self

A hyperbox-based model with the low-qualitied hyperboxes pruned.