incremental_learner.rfmnn

Refined fuzzy min-max neural network classifier trained by the incremental learning algorithm.

class hbbrain.numerical_data.incremental_learner.rfmnn.RFMNNClassifier(theta=0.5, gamma=1, is_draw=False, V=None, W=None, C=None)[source]

Bases: BaseFMNNClassifier

Refined fuzzy min-max neural network classifier.

This class implements essential functions for a refined online learning algorithm to train a fuzzy min-max neural network. This algorithm proposes a new expansion procedure for addressing the problems of overlap leniency and irregularity of hyperbox expansion. It avoids the overlap cases between hyperboxes from different classes, reducing the number of overlap cases to one (containment case) as in the improved online learning algorithm. It also introduces a new formula that simplifies the overlap test procedure. Moreover, it introduces a new contraction procedure for overcoming the data distortion problem and providing more accurate decision boundaries for the contracted hyperboxes is proposed. The details of this algorithm can be found in [1].

Parameters:
thetafloat, optional, default=0.5

Maximum hyperbox size for numerical features.

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.

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]

O. N. Al-Sayaydeh, M. F. Mohammed, E. Alhroob, H. Tao, and C. P. Lim, “A refined fuzzy min-max neural network with new learning procedures for pattern classification,” IEEE Transactions on Fuzzy Systems, vol. 28, no. 10, pp. 2480-2494, 2019.

Examples

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

Training time in seconds.

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 refined online 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(x)

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(X_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 refined online 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 fuzzy min-max neural network.

get_sample_explanation(x)[source]

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

Parameters:
xndarray of shape (n_feature,)

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

predict(X)[source]

Predict class labels for samples in X.

Note

In the case there are many winner hyperboxes representing different class labels but with the same membership value with respect to the input pattern \(X_i\), an additional criterion based on the minimum rfmnn distance between the input patter \(X_i\) and the winner hyperboxes are used to find the final winner hyperbox that its class label is used for predicting the class label of the input pattern \(X_i\).

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

The data matrix for which we want to predict the targets.

Returns:
y_predndarray of shape (n_samples,)

Vector containing the predictions. In binary and multiclass problems, this is a vector containing n_samples.

simple_pruning(X_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:
X_valarray-like of shape (n_samples, n_features)

The data matrix contains 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.

hbbrain.numerical_data.incremental_learner.rfmnn.predict_rfmnn(V, W, C, X, g)[source]

Predict class labels for samples in X.

Note

This is a function to determine the right class labels for X with regard to a trained hyperbox-based classifier represented by [V, W, C]. It uses the winner-takes-all principle to predict class labels for each sample in X by assigning the class label of the sample to the class label of the hyperbox with the maximum membership value to that sample. It will use a specific distance desgined for the refined fuzzy min-max neural networks in the case of many hyperboxes with different classes having the same maximum membership value.

Parameters:
Varray-like of shape (n_hyperboxes, n_features)

A matrix stores all minimal points of all hyperboxes of a trained hyperbox-based model, 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 of all hyperboxes of a trained hyperbox-based model, in which each row is a maximal point of a hyperbox.

Cndarray of shape (n_hyperboxes,)

An array contains all class lables for all hyperboxes of a trained hyperbox-based model.

Xarray-like of shape (n_samples, n_features)

The data matrix contains input patterns for which we want to predict the targets.

gfloat or array-like of shape (n_features,), optional, default=1

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

Returns:
y_predndarray of shape (n_samples,)

A vector contains the predictions. In binary and multiclass problems, this is a vector containing n_samples.