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

Public Member Functions

 __init__ (self, activation='tanh', act_params=None, alpha=10.0, layers=None, w2_weights=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_
 
 alpha
 
 act_params
 
 layers
 
 w2_weights
 
 verbose
 
 activation
 
 act
 

Detailed Description

Deep Representation Extreme Learning Machine (DrELM) Model.

This class implements a Deep Representation Extreme Learning Machine model for classification tasks.

Parameters:
-----------
    activation (str): Activation function to be used in the hidden layers. Default is 'tanh'.
    act_params (dict): Parameters for the activation function. Default is None.
    alpha (float): Regularization parameter. Default is 10.0.
    layers (list): List of layers to be added to the model. Default is None.
    w2_weights (list): List of weights matrices for the second layer. Default is None.
    verbose (int): Verbosity mode. Default is 0.

Attributes:
-----------
    classes_ (None or array): The classes seen during fitting.
    alpha (float): Regularization parameter.
    act_params (dict): Parameters for the activation function.
    layers (list): List of layers in the model.
    w2_weights (list): List of weights matrices for the second layer.
    verbose (int): Verbosity mode.
    activation (str): Activation function name.
    act (function): Activation function.

Methods:
-----------
    - add(layer): Add a layer to the model.
    - fit(x, y): Fit the model to the training data.
    - predict(x): Predict classes for input data.
    - predict_proba(x): Predict class probabilities for input data.
    - summary(): Print a summary of the model architecture.
    - to_dict(): Convert the model to a dictionary.
    - save(file_path): Serialize the model and save it to an HDF5 file.
    - load(file_path): Load a serialized model from an HDF5 file.

Examples:
-----------
    Create an instance of the Deep Representation ELM model (DrELMModel)

    >>> model = DrELMModel(activation='mish')

    Add layers to the Deep Representation ELM

    >>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
    >>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
    >>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
    >>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))

    Define a cross-validation strategy

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

    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/DrELM_Model.h5")

    Load the saved model from the file

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

    Evaluate the accuracy of the model on the training data

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

Member Function Documentation

◆ add()

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

Parameters:
-----------
    layer (object): The layer to be added.

Returns:
-----------
    None

Examples:
-----------
Create an instance of the Deep Representation ELM model (DrELMModel)

>>> model = DrELMModel(activation='mish')

Add layers to the Deep Representation ELM

>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))

◆ fit()

DrELMModel.DrELMModel.fit ( self,
x,
y )
Fit the model to the training data.

Parameters:
-----------
    x (array-like): The input data.
    y (array-like): The target labels.

Returns:
-----------
    None

Examples:
-----------
Create an instance of the Deep Representation ELM model (DrELMModel)

>>> model = DrELMModel(activation='mish')

Add layers to the Deep Representation ELM

>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))

Fit the ELM model to the entire dataset

>>> model.fit(X, y)

◆ load()

DrELMModel.DrELMModel.load ( cls,
str file_path )
Load a serialized model from an HDF5 file.

Parameters:
-----------
    file_path (str): The file path from which the model will be loaded.

Returns:
-----------
    DrELMModel: The loaded model instance.

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

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

◆ predict()

DrELMModel.DrELMModel.predict ( self,
x )
Predict classes for input data.

Parameters:
-----------
    x (array-like): The input data.

Returns:
-----------
    array: Predicted class labels.

Examples:
-----------
Create an instance of the Deep Representation ELM model (DrELMModel)

>>> model = DrELMModel(activation='mish')

Add layers to the Deep Representation ELM

>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))

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()

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

Parameters:
-----------
    x (array-like): The input data.

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

Examples:
-----------
Create an instance of the Deep Representation ELM model (DrELMModel)

>>> model = DrELMModel(activation='mish')

Add layers to the Deep Representation ELM

>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))
>>> model.add(ELMLayer(number_neurons=num_neurons, activation='identity'))

Fit the ELM model to the entire dataset

>>> model.fit(X, y)

Evaluate the prediction of the model on the training data

>>> pred_proba = model.predict_proba(X)

◆ save()

DrELMModel.DrELMModel.save ( self,
file_path )
Serialize the current instance and save it to a HDF5 file.

Parameters:
-----------
- path (str): The file path where the serialized instance will be saved.

Returns:
-----------
None

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

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

◆ summary()

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

Returns:
-----------
    None

◆ to_dict()

DrELMModel.DrELMModel.to_dict ( self)
Convert the model to a dictionary.

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

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