Extreme Learning Machine model.
This class implements an Extreme Learning Machine (ELM) model, which is a single-hidden-layer feedforward neural
network. The model can be used for both classification and regression tasks.
Parameters:
-----------
layer : ELMLayer
The hidden layer of the ELM model.
classification : bool, default=True
Indicates whether the model is used for classification (True) or regression (False) tasks.
random_weights : bool, default=True
Indicates whether to randomly initialize the weights of the hidden layer.
Attributes:
-----------
classes_ : array-like, shape (n_classes,)
The unique class labels in the training data.
Examples:
-----------
Initialize an Extreme Learning Machine (ELM) layer with 1000 neurons
>>> elm = ELMLayer(number_neurons=1000, activation='mish')
Create an ELM model using the trained ELM layer
>>> model = ELMModel(elm)
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/ELM_Model.h5")
Load the saved model from the file
>>> model = model.load("Saved Models/ELM_Model.h5")
Evaluate the accuracy of the model on the training data
>>> acc = accuracy_score(model.predict(X), y)
>>> print(acc)
ELMModel.ELMModel.fit |
( |
| self, |
|
|
| X, |
|
|
| y ) |
Fit the ELM model to the training data.
Parameters:
-----------
X : array-like, shape (n_samples, n_features)
The input training data.
y : array-like, shape (n_samples,) or (n_samples, n_classes)
The target values for classification or regression tasks.
Returns:
--------
self : object
Returns the instance itself.
Example:
-----------
Initialize an Extreme Learning Machine (ELM) layer with 1000 neurons
>>> elm = ELMLayer(number_neurons=1000, activation='mish')
Create an ELM model using the trained ELM layer
>>> model = ELMModel(elm)
Fit the ELM model to the entire dataset
>>> model.fit(X, y)
ELMModel.ELMModel.predict |
( |
| self, |
|
|
| X ) |
Predict class labels or regression values for the input data.
Parameters:
-----------
X : array-like, shape (n_samples, n_features)
The input data.
Returns:
--------
y_pred : array-like, shape (n_samples,)
The predicted class labels or regression values.
Example:
-----------
Initialize an Extreme Learning Machine (ELM) layer with 1000 neurons
>>> elm = ELMLayer(number_neurons=1000, activation='mish')
Create an ELM model using the trained ELM layer
>>> model = ELMModel(elm)
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)
ELMModel.ELMModel.predict_proba |
( |
| self, |
|
|
| x ) |
Predict class probabilities for the input data.
Parameters:
-----------
X : array-like, shape (n_samples, n_features)
The input data.
Returns:
--------
y_proba : array-like, shape (n_samples, n_classes)
The predicted class probabilities.
Example:
-----------
Initialize an Extreme Learning Machine (ELM) layer with 1000 neurons
>>> elm = ELMLayer(number_neurons=1000, activation='mish')
Create an ELM model using the trained ELM layer
>>> model = ELMModel(elm)
Fit the ELM model to the entire dataset
>>> model.fit(X, y)
Evaluate the accuracy of the model on the training data
>>> pred_proba = model.predict_proba(X)