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