TfELM
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
MELMModel.MELMModel Class Reference
Inheritance diagram for MELMModel.MELMModel:

Public Member Functions

 __init__ (self, layers=None, verbose=0)
 
 add (self, layer)
 
 fit (self, x, y)
 
 predict (self, x)
 
 predict_proba (self, x)
 
 summary (self)
 
 to_dict (self)
 
 save (self, file_path)
 
 load (cls, str file_path)
 

Public Attributes

 classes_
 
 layers
 
 verbose
 

Detailed Description

    Multi-layer Extreme Learning Machine (MELM) model.

    MELMModel is a multi-layer variant of Extreme Learning Machine (ELM) model,
    consisting of multiple layers, each with its own computational units.

    Parameters:
    -----------
    layers (list, optional): List of layers. Defaults to None.
        verbose (int, optional): Verbosity level. Defaults to 0.
    verbose (int): Verbosity level.
        Controls the amount of information printed during model fitting and prediction.

    Attributes:
    -----------
    classes_ (array-like): The classes labels.
        Initialized to None and populated during fitting.

    Examples:
    -----------
    Create a Multilayer ELM model

    >>> model = MELMModel()

    Add 3 layers of neurons

    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=2000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))

    Define a cross-validation strategy

    >>> cv = RepeatedKFold(n_splits=10, n_repeats=50)

    Perform cross-validation to evaluate the model performance

    >>> scores = cross_val_score(model, X, y, cv=cv, scoring='accuracy', error_score='raise')

    Print the mean accuracy score obtained from cross-validation

    >>> print(np.mean(scores))

    Fit the ELM model to the entire dataset

    >>> model.fit(X, y)

    Save the trained model to a file

    >>> model.save("Saved Models/MELM_Model.h5")

    Load the saved model from the file

    >>> model = model.load("Saved Models/MELM_Model.h5")

    Evaluate the accuracy of the model on the training data

    >>> acc = accuracy_score(model.predict(X), y)

Member Function Documentation

◆ add()

MELMModel.MELMModel.add ( self,
layer )
    Add a layer to the model.

    Args:
    -----------
        layer: Layer to be added.

    Examples:
    -----------
    Create a Multilayer ELM model

    >>> model = MELMModel()

    Add 3 layers of neurons

    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=2000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))

◆ fit()

MELMModel.MELMModel.fit ( self,
x,
y )
    Fit the MELM model to input-output pairs.

    This method trains the MELM model by iteratively fitting each layer in the model.
    During the training process, input data is propagated through each layer.

    Args:
    -----------
        x (array-like): Input data.
        y (array-like): Output data.

    Examples:
    -----------
    Create a Multilayer ELM model

    >>> model = MELMModel()

    Add 3 layers of neurons

    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=2000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))

    Fit the ELM model to the entire dataset

    >>> model.fit(X, y)

◆ load()

MELMModel.MELMModel.load ( cls,
str file_path )
    Load a model from a file.

    This method loads a MELM model from a HDF5 file.

    Args:
    -----------
        file_path (str): File path to load the model from.

    Returns:
    -----------
        MELMModel: Loaded MELM model.

    Examples:
    -----------
    Load the saved model from the file

    >>> model = model.load("Saved Models/MELM_Model.h5")

◆ predict()

MELMModel.MELMModel.predict ( self,
x )
    Predict the output for input data.

    This method predicts the output for the given input data by propagating
    it through the layers of the MELM model.

    Args:
    -----------
        x (array-like): Input data.

    Returns:
    -----------
        array-like: Predicted output.

    Examples:
    -----------
    Create a Multilayer ELM model

    >>> model = MELMModel()

    Add 3 layers of neurons

    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=2000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))

    Fit the ELM model to the entire dataset

    >>> model.fit(X, y)

    Evaluate the accuracy of the model on the training data

    >>> acc = accuracy_score(model.predict(X), y)

◆ predict_proba()

MELMModel.MELMModel.predict_proba ( self,
x )
    Predict class probabilities for input data.

    This method predicts class probabilities for the given input data
    by propagating it through the layers of the MELM model and applying softmax.

    Args:
    -----------
        x (array-like): Input data.

    Returns:
    -----------
        array-like: Predicted class probabilities.

    Examples:
    -----------
    Create a Multilayer ELM model

    >>> model = MELMModel()

    Add 3 layers of neurons

    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=2000, activation='mish', C=10))
    >>> model.add(ELMLayer(number_neurons=1000, activation='mish', C=10))

    Fit the ELM model to the entire dataset

    >>> model.fit(X, y)

    Evaluate the prediction probability of the model on the training data

    >>> pred_proba = model.predict_proba(X)

◆ save()

MELMModel.MELMModel.save ( self,
file_path )
    Save the model to a file.

    This method saves the MELM model to a HDF5 file format.

    Args:
    -----------
        file_path (str): File path to save the model.

    Examples:
    -----------
    Save the trained model to a file

    >>> model.save("Saved Models/MELM_Model.h5")

◆ summary()

MELMModel.MELMModel.summary ( self)
    Print a summary of the model architecture.

    This method prints a summary of the MELM model architecture,
    including information about each layer and the total number of parameters.

◆ to_dict()

MELMModel.MELMModel.to_dict ( self)
    Convert the model configuration to a dictionary.

    This method converts the configuration of the MELM model to a dictionary
    for saving or further processing.

    Returns:
    -----------
        dict: Dictionary containing the model configuration.

The documentation for this class was generated from the following file: