intelelm.model package

intelelm.model.automated_comparator module

class intelelm.model.automated_comparator.AutomatedMhaElmComparator(optimizer_dict=None, task='classification', layer_sizes=(10,), act_name='elu', obj_name=None, verbose=False, seed=None, obj_weights=None, **kwargs)[source]

Bases: object

Automated compare different MhaElm models based on provided optimizer configurations.

This class facilitates the comparison of multiple MhaElm models with varying optimizer configurations. It provides methods for cross-validation and train-test split evaluation.

Parameters
  • optimizer_dict (dict, optional) – A dictionary of optimizer names and parameters.

  • task (str, optional) – The task type (classification or regression). Defaults to ‘classification’.

  • layer_sizes (int, list, tuple, optional) – The number of nodes in each hidden layer. Defaults is (10, ).

  • act_name (str, optional) – The activation function name. Defaults to ‘elu’.

  • obj_name (str, optional) – The objective function name. Defaults to None.

  • verbose (bool, optional) – Whether to print verbose output. Defaults to False.

  • seed (int, optional) – Random seed for reproducibility. Defaults to None.

  • obj_weights (array-like, optional) – Weights for the objective function. Defaults to None.

  • **kwargs – Additional keyword arguments for model initialization.

compare_cross_val_score(X, y, metric=None, cv=5, n_trials=10, to_csv=True, saved_file_path='history/results_cross_val_score.csv', **kwargs)[source]

Performs cross-validation with a single metric.

Compares different MhaElm models using cross-validation with a single metric.

Parameters
  • X (array-like) – The feature matrix.

  • y (array-like) – The target vector.

  • metric (str, optional) – The metric to evaluate. Defaults to None.

  • cv (int, optional) – The number of cross-validation folds. Defaults to 5.

  • n_trials (int, optional) – The number of trials. Defaults to 10.

  • to_csv (bool, optional) – Whether to save results to a CSV file. Defaults to True.

  • saved_file_path (str, optional) – The path to save the CSV file. Defaults to ‘history/results_cross_val_score.csv’.

  • **kwargs – Additional keyword arguments for cross_val_score.

Returns

The comparison results.

Return type

pandas.DataFrame

compare_cross_validate(X, y, metrics=None, cv=5, return_train_score=True, n_trials=10, to_csv=True, saved_file_path='history/results_cross_validate.csv', **kwargs)[source]

Performs cross-validation for model comparison.

Compares different MhaElm models using cross-validation.

Parameters
  • X (array-like) – The feature matrix.

  • y (array-like) – The target vector.

  • metrics (list, optional) – A list of metric names. Defaults to None.

  • cv (int, optional) – The number of cross-validation folds. Defaults to 5.

  • return_train_score (bool, optional) – Whether to return train scores. Defaults to True.

  • n_trials (int, optional) – The number of trials. Defaults to 10.

  • to_csv (bool, optional) – Whether to save results to a CSV file. Defaults to True.

  • saved_file_path (str, optional) – The path to save the CSV file. Defaults to ‘history/results_cross_validate.csv’.

  • **kwargs – Additional keyword arguments for cross_validate.

Returns

The comparison results.

Return type

pandas.DataFrame

compare_train_test(X_train, y_train, X_test, y_test, metrics=None, n_trials=10, to_csv=True, saved_file_path='history/results_train_test.csv')[source]

Compares models using train-test split.

Compares different MhaElm models using train-test split evaluation.

Parameters
  • X_train (array-like) – The training feature matrix.

  • y_train (array-like) – The training target vector.

  • X_test (array-like) – The testing feature matrix.

  • y_test (array-like) – The testing target vector.

  • metrics (list, optional) – A list of metric names. Defaults to None.

  • n_trials (int, optional) – The number of trials. Defaults to 10.

  • to_csv (bool, optional) – Whether to save results to a CSV file. Defaults to True.

  • saved_file_path (str, optional) – The path to save the CSV file. Defaults to ‘history/results_train_test.csv’.

Returns

The comparison results.

Return type

pandas.DataFrame

intelelm.model.automated_tuner module

class intelelm.model.automated_tuner.AutomatedMhaElmTuner(task='classification', param_dict=None, search_method='gridsearch', scoring=None, cv=3, **kwargs)[source]

Bases: object

Automated hyperparameter tuner for MhaElm models.

Performs hyperparameter tuning for MhaElm models using either GridSearchCV or RandomizedSearchCV. Provides an interface for fitting and predicting using the best found model.

model_class

The MhaElm model class (MhaElmRegressor or MhaElmClassifier).

Type

class

param_grid

The parameter grid for hyperparameter tuning.

Type

dict

search_method

The optimization method (‘gridsearch’ or ‘randomsearch’).

Type

str

kwargs

Additional keyword arguments for the search method.

Type

dict

searcher

The searcher

Type

GridSearchCV or RandomizedSearchCV

best_estimator_

The best estimator found during tuning.

Type

sklearn.base.BaseEstimator

best_params_

The best hyperparameters found during tuning.

Type

dict

fit(X, y)[source]

Fits the tuner to the data and tunes hyperparameters.

predict(X)[source]

Predicts using the best estimator.

fit(X, y)[source]

Fits the tuner to the data and tunes the hyperparameters.

Parameters
  • X (array-like) – Training features.

  • y (array-like) – Training target values.

Returns

Fitted tuner object.

Return type

self

predict(X)[source]

Predicts using the best estimator found during tuning.

Parameters

X (array-like) – Data to predict.

Returns

Predicted values.

Return type

array-like

intelelm.model.base_elm module

class intelelm.model.base_elm.BaseElm(layer_sizes=(10,), act_name='relu')[source]

Bases: sklearn.base.BaseEstimator

class BaseElm(BaseEstimator):

A base class for implementing Extreme Learning Machines (ELM) with support for both classification and regression tasks.

layer_sizeslist

List containing the sizes of each layer in the network.

act_namestr

The name of the activation function to be used.

networkobject

The ELM network object.

loss_trainlist

List of loss values recorded during training.

n_labelsint

Number of labels in the dataset.

CLS_OBJ_LOSSES = None
SUPPORTED_CLS_METRICS = {'AS': 'max', 'BSL': 'min', 'CEL': 'min', 'CKS': 'max', 'F1S': 'max', 'F2S': 'max', 'FBS': 'max', 'GINI': 'min', 'GMS': 'max', 'HL': 'min', 'HS': 'max', 'JSI': 'max', 'KLDL': 'min', 'LS': 'max', 'MCC': 'max', 'NPV': 'max', 'PS': 'max', 'ROC-AUC': 'max', 'RS': 'max', 'SS': 'max'}
SUPPORTED_REG_METRICS = {'A10': 'max', 'A20': 'max', 'A30': 'max', 'ACOD': 'max', 'APCC': 'max', 'AR': 'max', 'AR2': 'max', 'CI': 'max', 'COD': 'max', 'COR': 'max', 'COV': 'max', 'CRM': 'min', 'DRV': 'min', 'EC': 'max', 'EVS': 'max', 'GINI': 'min', 'GINI_WIKI': 'min', 'JSD': 'min', 'KGE': 'max', 'MAAPE': 'min', 'MAE': 'min', 'MAPE': 'min', 'MASE': 'min', 'ME': 'min', 'MRB': 'min', 'MRE': 'min', 'MSE': 'min', 'MSLE': 'min', 'MedAE': 'min', 'NNSE': 'max', 'NRMSE': 'min', 'NSE': 'max', 'OI': 'max', 'PCC': 'max', 'PCD': 'max', 'R': 'max', 'R2': 'max', 'R2S': 'max', 'RAE': 'min', 'RMSE': 'min', 'RSE': 'min', 'RSQ': 'max', 'SMAPE': 'min', 'VAF': 'max', 'WI': 'max'}
create_network(X, y) Optional[intelelm.model.base_elm.MultiLayerELM][source]
Parameters
  • X (ndarray) – Input data used to train the network.

  • y (ndarray) – Target values corresponding to the input data X.

Returns

Returns an instance of the MultiLayerELM class if creation is successful, otherwise, returns None.

Return type

Optional[“MultiLayerELM”]

evaluate(y_true, y_pred, list_metrics=None)[source]

Return the list of performance metrics of the prediction.

Parameters
  • y_true (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • y_pred (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Predicted values for X.

  • list_metrics (list) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

fit(X, y)[source]
Parameters
  • X (array-like of shape (n_samples, n_features)) – Training data.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target values.

get_weights()[source]

Retrieves the current weights of the neural network.

Returns

A list containing the weights of the neural network.

Return type

list

static load_model(load_path='history', filename='model.pkl')[source]
Parameters
  • load_path (str, optional) – Directory path where the model file is located. Defaults to “history”.

  • filename (str) – Name of the file to be loaded. If the filename doesn’t end with “.pkl”, the extension is automatically added.

Returns

The model loaded from the specified pickle file.

Return type

object

predict(X, return_prob=False)[source]

Inherit the predict function from BaseElm class, with 1 more parameter return_prob.

Parameters
  • X ({array-like, sparse matrix} of shape (n_samples, n_features)) – The input data.

  • return_prob (bool, default=False) –

    It is used for classification problem:

    • If True, the returned results are the probability for each sample

    • If False, the returned results are the predicted labels

save_loss_train(save_path='history', filename='loss.csv')[source]

Save the loss (convergence) during the training process to csv file.

Parameters
  • save_path (saved path (relative path, consider from current executed script path)) –

  • filename (name of the file, needs to have ".csv" extension) –

save_metrics(y_true, y_pred, list_metrics=('RMSE', 'MAE'), save_path='history', filename='metrics.csv')[source]

Save evaluation metrics to csv file

Parameters
  • y_true (ground truth data) –

  • y_pred (predicted output) –

  • list_metrics (list of evaluation metrics) –

  • save_path (saved path (relative path, consider from current executed script path)) –

  • filename (name of the file, needs to have ".csv" extension) –

save_model(save_path='history', filename='model.pkl')[source]

Save model to pickle file

Parameters
  • save_path (saved path (relative path, consider from current executed script path)) –

  • filename (name of the file, needs to have ".pkl" extension) –

save_y_predicted(X, y_true, save_path='history', filename='y_predicted.csv')[source]

Save the predicted results to csv file

Parameters
  • X (The features data, nd.ndarray) –

  • y_true (The ground truth data) –

  • save_path (saved path (relative path, consider from current executed script path)) –

  • filename (name of the file, needs to have ".csv" extension) –

score(X, y, method=None)[source]

Return the metric of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • method (str, default="RMSE") – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

result – The result of selected metric

Return type

float

scores(X, y, list_methods=None)[source]

Return the list of metrics of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • list_methods (list, default=("MSE", "MAE")) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.base_elm.BaseElm

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.base_elm.BaseElm

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object

class intelelm.model.base_elm.BaseMhaElm(layer_sizes=(10,), act_name='elu', obj_name=None, optim='BaseGA', optim_paras=None, seed=None, verbose=True)[source]

Bases: intelelm.model.base_elm.BaseElm

The BaseMhaElm class is an optimization-based extension of the BaseElm class, designed for flexible optimization and parameter tuning of networks utilizing various optimizers from the Mealpy library. It supports different activation functions, objectives, and optimization strategies.

SUPPORTED_OPTIMIZERS

List of supported optimizers, obtained from the Mealpy library.

Type

list

SUPPORTED_CLS_OBJECTIVES

Dictionary of supported classification objectives.

Type

dict

SUPPORTED_REG_OBJECTIVES

Dictionary of supported regression objectives.

Type

dict

__init__(layer_sizes=None, act_name='elu', obj_name=None, optim='BaseGA', optim_paras=None, seed=None, verbose=True)[source]

Initializes the BaseMhaElm with specified parameters.

get_name()[source]

Returns the name of the optimizer used, appended with -ELM.

set_params(**params)[source]

Sets the parameters for the optimizer and updates parent class parameters.

set_optimizer(optim)[source]

Sets the optimizer attribute.

set_optim_paras(optim_paras)[source]

Sets the optimizer parameters attribute.

set_optimizer_object(optim=None, optim_paras=None)[source]

Sets the optimizer object with the specified parameters.

set_seed(seed)[source]

Sets the random seed for the class.

_get_history_loss(optimizer=None)[source]

Retrieves the historical loss values from the optimizer.

fitness_function(solution=None)[source]

Placeholder fitness function to be overridden by the subclass or user.

_get_lb_ub(lb=None, ub=None, problem_size=None)[source]

Computes the lower and upper bounds based on the provided inputs and problem size.

_get_minmax(obj_name=None)[source]

Retrieves the minmax value for the specified objective name.

fit(X, y, lb=(- 10.0,), ub=(10.0,), mode='single', n_workers=None, termination=None, save_population=False)[source]

Fits the model to the provided data using the specified optimization parameters.

SUPPORTED_CLS_OBJECTIVES = {'AS': 'max', 'BSL': 'min', 'CEL': 'min', 'CKS': 'max', 'F1S': 'max', 'F2S': 'max', 'FBS': 'max', 'GINI': 'min', 'GMS': 'max', 'HL': 'min', 'HS': 'max', 'JSI': 'max', 'KLDL': 'min', 'LS': 'max', 'MCC': 'max', 'NPV': 'max', 'PS': 'max', 'ROC-AUC': 'max', 'RS': 'max', 'SS': 'max'}
SUPPORTED_OPTIMIZERS = ['OriginalABC', 'OriginalACOR', 'AugmentedAEO', 'EnhancedAEO', 'ImprovedAEO', 'ModifiedAEO', 'OriginalAEO', 'MGTO', 'OriginalAGTO', 'DevALO', 'OriginalALO', 'OriginalAO', 'OriginalAOA', 'IARO', 'LARO', 'OriginalARO', 'OriginalASO', 'OriginalAVOA', 'OriginalArchOA', 'AdaptiveBA', 'DevBA', 'OriginalBA', 'DevBBO', 'OriginalBBO', 'OriginalBBOA', 'OriginalBES', 'ABFO', 'OriginalBFO', 'OriginalBMO', 'DevBRO', 'OriginalBRO', 'OriginalBSA', 'ImprovedBSO', 'OriginalBSO', 'CleverBookBeesA', 'OriginalBeesA', 'ProbBeesA', 'OriginalCA', 'OriginalCDO', 'OriginalCEM', 'OriginalCGO', 'DevCHIO', 'OriginalCHIO', 'OriginalCOA', 'OCRO', 'OriginalCRO', 'OriginalCSA', 'OriginalCSO', 'OriginalCircleSA', 'OriginalCoatiOA', 'JADE', 'OriginalDE', 'SADE', 'SAP_DE', 'DevDMOA', 'OriginalDMOA', 'OriginalDO', 'DevEFO', 'OriginalEFO', 'OriginalEHO', 'AdaptiveEO', 'ModifiedEO', 'OriginalEO', 'OriginalEOA', 'LevyEP', 'OriginalEP', 'CMA_ES', 'LevyES', 'OriginalES', 'Simple_CMA_ES', 'OriginalESOA', 'OriginalEVO', 'OriginalFA', 'DevFBIO', 'OriginalFBIO', 'OriginalFFA', 'OriginalFFO', 'OriginalFLA', 'DevFOA', 'OriginalFOA', 'WhaleFOA', 'OriginalFOX', 'OriginalFPA', 'BaseGA', 'EliteMultiGA', 'EliteSingleGA', 'MultiGA', 'SingleGA', 'OriginalGBO', 'DevGCO', 'OriginalGCO', 'OriginalGJO', 'OriginalGOA', 'DevGSKA', 'OriginalGSKA', 'Matlab101GTO', 'Matlab102GTO', 'OriginalGTO', 'GWO_WOA', 'IGWO', 'OriginalGWO', 'RW_GWO', 'OriginalHBA', 'OriginalHBO', 'OriginalHC', 'SwarmHC', 'OriginalHCO', 'OriginalHGS', 'OriginalHGSO', 'OriginalHHO', 'DevHS', 'OriginalHS', 'OriginalICA', 'OriginalINFO', 'OriginalIWO', 'DevJA', 'LevyJA', 'OriginalJA', 'DevLCO', 'ImprovedLCO', 'OriginalLCO', 'OriginalMA', 'OriginalMFO', 'OriginalMGO', 'OriginalMPA', 'OriginalMRFO', 'WMQIMRFO', 'OriginalMSA', 'DevMVO', 'OriginalMVO', 'OriginalNGO', 'ImprovedNMRA', 'OriginalNMRA', 'OriginalNRO', 'OriginalOOA', 'OriginalPFA', 'OriginalPOA', 'AIW_PSO', 'CL_PSO', 'C_PSO', 'HPSO_TVAC', 'LDW_PSO', 'OriginalPSO', 'P_PSO', 'OriginalPSS', 'DevQSA', 'ImprovedQSA', 'LevyQSA', 'OppoQSA', 'OriginalQSA', 'OriginalRIME', 'OriginalRUN', 'GaussianSA', 'OriginalSA', 'SwarmSA', 'DevSARO', 'OriginalSARO', 'DevSBO', 'OriginalSBO', 'DevSCA', 'OriginalSCA', 'QleSCA', 'OriginalSCSO', 'ImprovedSFO', 'OriginalSFO', 'L_SHADE', 'OriginalSHADE', 'OriginalSHIO', 'OriginalSHO', 'ImprovedSLO', 'ModifiedSLO', 'OriginalSLO', 'DevSMA', 'OriginalSMA', 'DevSOA', 'OriginalSOA', 'OriginalSOS', 'DevSPBO', 'OriginalSPBO', 'OriginalSRSR', 'DevSSA', 'OriginalSSA', 'OriginalSSDO', 'OriginalSSO', 'OriginalSSpiderA', 'OriginalSSpiderO', 'OriginalSTO', 'OriginalSeaHO', 'OriginalServalOA', 'OriginalTDO', 'DevTLO', 'ImprovedTLO', 'OriginalTLO', 'OriginalTOA', 'DevTPO', 'OriginalTS', 'OriginalTSA', 'OriginalTSO', 'EnhancedTWO', 'LevyTWO', 'OppoTWO', 'OriginalTWO', 'DevVCS', 'OriginalVCS', 'OriginalWCA', 'OriginalWDO', 'OriginalWHO', 'HI_WOA', 'OriginalWOA', 'OriginalWaOA', 'OriginalWarSO', 'OriginalZOA']
SUPPORTED_REG_OBJECTIVES = {'A10': 'max', 'A20': 'max', 'A30': 'max', 'ACOD': 'max', 'APCC': 'max', 'AR': 'max', 'AR2': 'max', 'CI': 'max', 'COD': 'max', 'COR': 'max', 'COV': 'max', 'CRM': 'min', 'DRV': 'min', 'EC': 'max', 'EVS': 'max', 'GINI': 'min', 'GINI_WIKI': 'min', 'JSD': 'min', 'KGE': 'max', 'MAAPE': 'min', 'MAE': 'min', 'MAPE': 'min', 'MASE': 'min', 'ME': 'min', 'MRB': 'min', 'MRE': 'min', 'MSE': 'min', 'MSLE': 'min', 'MedAE': 'min', 'NNSE': 'max', 'NRMSE': 'min', 'NSE': 'max', 'OI': 'max', 'PCC': 'max', 'PCD': 'max', 'R': 'max', 'R2': 'max', 'R2S': 'max', 'RAE': 'min', 'RMSE': 'min', 'RSE': 'min', 'RSQ': 'max', 'SMAPE': 'min', 'VAF': 'max', 'WI': 'max'}
fit(X, y, lb=(- 10.0,), ub=(10.0,), mode='single', n_workers=None, termination=None, save_population=False)[source]
Parameters
  • X (The features data, np.ndarray) –

  • y (The ground truth data) –

  • lb (The lower bound for decision variables in optimization problem (The weights and biases of network)) –

  • ub (The upper bound for decision variables in optimization problem (The weights and biases of network)) –

  • mode (Parallel: 'process', 'thread'; Sequential: 'swarm', 'single'.) –

    • ‘process’: The parallel mode with multiple cores run the tasks

    • ’thread’: The parallel mode with multiple threads run the tasks

    • ’swarm’: The sequential mode that no effect on updating phase of other agents

    • ’single’: The sequential mode that effect on updating phase of other agents, this is default mode

  • n_workers (The number of workers (cores or threads) to do the tasks (effect only on parallel mode)) –

  • termination (The termination dictionary or an instance of Termination class in Mealpy library) –

  • save_population (Save the population of search agents (Don't set it to True when you don't know how to use it)) –

fitness_function(solution=None)[source]
get_name()[source]
set_fit_request(*, lb: Union[bool, None, str] = '$UNCHANGED$', mode: Union[bool, None, str] = '$UNCHANGED$', n_workers: Union[bool, None, str] = '$UNCHANGED$', save_population: Union[bool, None, str] = '$UNCHANGED$', termination: Union[bool, None, str] = '$UNCHANGED$', ub: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.base_elm.BaseMhaElm

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters
  • lb (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for lb parameter in fit.

  • mode (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for mode parameter in fit.

  • n_workers (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for n_workers parameter in fit.

  • save_population (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for save_population parameter in fit.

  • termination (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for termination parameter in fit.

  • ub (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for ub parameter in fit.

Returns

self – The updated object.

Return type

object

set_optim_paras(optim_paras)[source]
set_optimizer(optim)[source]
set_optimizer_object(optim=None, optim_paras=None)[source]
Parameters
  • optim (str or Optimizer) – The optim can be a string indicating the name of the optimizer supported by the Mealpy library or an instance of the Optimizer class.

  • optim_paras (dict, optional) – A dictionary containing the hyper-parameters for the optimizer. This is only used if the optim parameter is provided either as a string or an Optimizer instance that supports parameter configuration.

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters

**params (dict) – Estimator parameters.

Returns

self – Estimator instance.

Return type

estimator instance

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.base_elm.BaseMhaElm

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.base_elm.BaseMhaElm

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object

set_seed(seed)[source]
Parameters

seed (int) – The seed value to initialize the random number generator.

class intelelm.model.base_elm.MultiLayerELM(layer_sizes=(10,), act_name='relu', seed=None)[source]

Bases: object

Initializes the Multi-Layer ELM model.

Parameters
  • layer_sizes (list of int) – List of integers, where each integer represents the number of neurons in the respective hidden layers.

  • act_name (str, optional) – Activation function to be used in the hidden layers (“relu”, “leaky_relu”, “celu”, “prelu”, “gelu”, “elu”, “selu”, “rrelu”, “tanh”, “hard_tanh”, “sigmoid”, “hard_sigmoid”, “log_sigmoid”, “silu”, “swish”, “hard_swish”, “soft_plus”, “mish”, “soft_sign”, “tanh_shrink”, “soft_shrink”, “hard_shrink”, “softmin”, “softmax”, “log_softmax”). Default is ‘relu’.

  • seed (int, optional) – Seed for random number generator. Default is None.

decode(solution_vector, X, y)[source]

Decode a 1-D solution vector into the weights and biases of the network.

Parameters: - solution_vector: 1-D numpy array containing the flattened weights and biases.

encode()[source]

Encode the current weights and biases into a 1-D vector (solution vector).

Returns: - A 1-D numpy array containing all the weights and biases of the network.

fit(X, y)[source]

Fit the model to data matrix X and target(s) y.

Parameters
  • X (ndarray or sparse matrix of shape (n_samples, n_features)) – The input data.

  • y (ndarray of shape (n_samples,) or (n_samples, n_outputs)) – The target values (class labels in classification, real numbers in regression).

Returns

self – Returns a trained ELM model.

Return type

object

get_ndim()[source]

Get the total number of dimensions (weights + biases) in the network.

Returns: - An integer representing the total number of parameters (weights + biases).

get_weights()[source]
predict(X)[source]

Predict using the Extreme Learning Machine model.

Parameters

X ({array-like, sparse matrix} of shape (n_samples, n_features)) – The input data.

Returns

y – The predicted values.

Return type

ndarray of shape (n_samples, n_outputs)

intelelm.model.mha_elm module

class intelelm.model.mha_elm.MhaElmClassifier(layer_sizes=(10,), act_name='elu', obj_name=None, optim='BaseGA', optim_paras=None, seed=None, verbose=False)[source]

Bases: intelelm.model.base_elm.BaseMhaElm, sklearn.base.ClassifierMixin

Defines the general class of Metaheuristic-based ELM model for Classification problems that inherit the BaseMhaElm and ClassifierMixin classes.

CLS_OBJ_LOSSES

List of supported classification objective losses.

Type

list

__init__(self, layer_sizes=None, act_name='elu', obj_name=None, optim='BaseGA', optim_paras=None, seed=None, verbose=False)[source]

Initializes the MhaElmClassifier with the given parameters.

_check_y(self, y)[source]

Checks the output labels (y) to ensure they are in the correct format and dimensionality.

create_network(self, X, y) MultiLayerELM:[source]

Sets up the MultiLayerELM network for classification based on input data (X) and labels (y).

fitness_function(self, solution=None)[source]

Evaluates the fitness function for the classification metric.

score(self, X, y, method='AS')[source]

Returns the metric on the given test data and labels.

scores(self, X, y, list_methods=('AS', 'RS'))[source]

Returns the list of metrics on the given test data and labels.

evaluate(self, y_true, y_pred, list_metrics=('AS', 'RS'))[source]

Returns the list of performance metrics on the given test data and labels.

CLS_OBJ_LOSSES = ['CEL', 'HL', 'KLDL', 'BSL']
create_network(X, y) intelelm.model.base_elm.MultiLayerELM[source]
Parameters
  • X (array-like) – The input features for training the network.

  • y (list, tuple, or np.ndarray) – The target labels for the input data. It must be 1D and will be processed to determine the number of unique labels.

evaluate(y_true, y_pred, list_metrics=('AS', 'RS'))[source]

Return the list of performance metrics on the given test data and labels.

Parameters
  • y_true (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • y_pred (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Predicted values for X.

  • list_metrics (list, default=("AS", "RS")) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

fitness_function(solution=None)[source]

Evaluates the fitness function for classification metric

Parameters

solution (np.ndarray, default=None) –

Returns

result – The fitness value

Return type

float

score(X, y, method='AS')[source]

Return the metric on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • method (str, default="AS") – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

result – The result of selected metric

Return type

float

scores(X, y, list_methods=('AS', 'RS'))[source]

Return the list of metrics on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • list_methods (list, default=("AS", "RS")) – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

set_fit_request(*, lb: Union[bool, None, str] = '$UNCHANGED$', mode: Union[bool, None, str] = '$UNCHANGED$', n_workers: Union[bool, None, str] = '$UNCHANGED$', save_population: Union[bool, None, str] = '$UNCHANGED$', termination: Union[bool, None, str] = '$UNCHANGED$', ub: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmClassifier

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters
  • lb (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for lb parameter in fit.

  • mode (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for mode parameter in fit.

  • n_workers (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for n_workers parameter in fit.

  • save_population (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for save_population parameter in fit.

  • termination (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for termination parameter in fit.

  • ub (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for ub parameter in fit.

Returns

self – The updated object.

Return type

object

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmClassifier

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmClassifier

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object

class intelelm.model.mha_elm.MhaElmRegressor(layer_sizes=(10,), act_name='elu', obj_name=None, optim='BaseGA', optim_paras=None, seed=None, verbose=False, obj_weights=None)[source]

Bases: intelelm.model.base_elm.BaseMhaElm, sklearn.base.RegressorMixin

class MhaElmRegressor(BaseMhaElm, RegressorMixin)

def __init__(self, layer_sizes, act_name=”elu”,

obj_name=None, optim=”BaseGA”, optim_paras=None, seed=None, verbose=False, obj_weights=None):

layer_sizeslist

List containing the sizes of each layer in the network.

act_namestr, default=”elu”

The activation function to be used in the network.

obj_namestr, optional

The name of the objective function to be optimized.

optimstr, default=”BaseGA”

The optimization method to be used.

optim_parasdict, optional

Parameters for the optimization method.

seedint, optional

Random seed for reproducibility.

verbosebool, default=False

Whether to print verbose output.

obj_weightslist or tuple or np.ndarray, optional

Weights for the objective function.

create_network(X, y) intelelm.model.base_elm.MultiLayerELM[source]
Parameters
  • X (array-like) – The input data used to train the network.

  • y (array-like) – The target values. It should be a 1D vector or a 2D matrix. Accepted types: list, tuple, np.ndarray.

Returns

An instance of MultiLayerELM initialized with the specified parameters and objective scaler.

Return type

MultiLayerELM

Raises
  • TypeError – If y is not a list, tuple, or np.ndarray, or if y has an invalid shape that is not a 1D vector or 2D matrix, or if self.obj_weights is of an invalid type.

  • ValueError – If the length of self.obj_weights does not match the number of objectives.

evaluate(y_true, y_pred, list_metrics=('MSE', 'MAE'))[source]

Return the list of performance metrics of the prediction.

Parameters
  • y_true (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • y_pred (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Predicted values for X.

  • list_metrics (list, default=("MSE", "MAE")) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

fitness_function(solution=None)[source]

Evaluates the fitness function for regression metric

Parameters

solution (np.ndarray, default=None) –

Returns

result – The fitness value

Return type

float

score(X, y, method='RMSE')[source]

Return the metric of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • method (str, default="RMSE") – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

result – The result of selected metric

Return type

float

scores(X, y, list_methods=('MSE', 'MAE'))[source]

Return the list of metrics of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • list_methods (list, default=("MSE", "MAE")) – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

set_fit_request(*, lb: Union[bool, None, str] = '$UNCHANGED$', mode: Union[bool, None, str] = '$UNCHANGED$', n_workers: Union[bool, None, str] = '$UNCHANGED$', save_population: Union[bool, None, str] = '$UNCHANGED$', termination: Union[bool, None, str] = '$UNCHANGED$', ub: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmRegressor

Request metadata passed to the fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters
  • lb (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for lb parameter in fit.

  • mode (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for mode parameter in fit.

  • n_workers (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for n_workers parameter in fit.

  • save_population (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for save_population parameter in fit.

  • termination (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for termination parameter in fit.

  • ub (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for ub parameter in fit.

Returns

self – The updated object.

Return type

object

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmRegressor

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.mha_elm.MhaElmRegressor

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object

intelelm.model.standard_elm module

class intelelm.model.standard_elm.ElmClassifier(layer_sizes=(10,), act_name='elu', seed=None)[source]

Bases: intelelm.model.base_elm.BaseElm, sklearn.base.ClassifierMixin

Defines the general class of Traditional ELM model for Classification problems that inherit the BaseElm and ClassifierMixin classes.

Parameters
  • layer_sizes (list of int, integers > 0) – A list of integers specifying the number of neurons in each hidden layer.

  • act_name ({"relu", "leaky_relu", "celu", "prelu", "gelu", "elu", "selu", "rrelu", "tanh", "hard_tanh", "sigmoid",) – “hard_sigmoid”, “log_sigmoid”, “silu”, “swish”, “hard_swish”, “soft_plus”, “mish”, “soft_sign”, “tanh_shrink”, “soft_shrink”, “hard_shrink”, “softmin”, “softmax”, “log_softmax” }, default=’sigmoid’ Activation function for the hidden layer.

  • seed (int, default=None) – Determines random number generation for weights and bias initialization. Pass an int for reproducible results across multiple function calls.

Examples

>>> from intelelm import Data, ElmClassifier
>>> from sklearn.datasets import make_classification
>>> X, y = make_classification(n_samples=100, random_state=1)
>>> data = Data(X, y)
>>> data.split_train_test(test_size=0.2, random_state=1)
>>> model = ElmClassifier(layer_sizes=(10, ), act_name="elu")
>>> model.fit(data.X_train, data.y_train)
>>> pred = model.predict(data.X_test)
>>> print(pred)
array([1, 0, 1, 0, 1])
CLS_OBJ_LOSSES = ['CEL', 'HL', 'KLDL', 'BSL']
create_network(X, y) intelelm.model.base_elm.MultiLayerELM[source]
Parameters
  • X (ndarray) – Input data used to train the network.

  • y (ndarray) – Target values corresponding to the input data X.

Returns

Returns an instance of the MultiLayerELM class if creation is successful, otherwise, returns None.

Return type

Optional[“MultiLayerELM”]

evaluate(y_true, y_pred, list_metrics=('AS', 'RS'))[source]

Return the list of performance metrics on the given test data and labels.

Parameters
  • y_true (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • y_pred (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Predicted values for X.

  • list_metrics (list, default=("AS", "RS")) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

score(X, y, method='AS')[source]

Return the metric on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • method (str, default="AS") – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

result – The result of selected metric

Return type

float

scores(X, y, list_methods=('AS', 'RS'))[source]

Return the list of metrics on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True labels for X.

  • list_methods (list, default=("AS", "RS")) – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.standard_elm.ElmClassifier

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.standard_elm.ElmClassifier

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object

class intelelm.model.standard_elm.ElmRegressor(layer_sizes=(10,), act_name='elu', seed=None)[source]

Bases: intelelm.model.base_elm.BaseElm, sklearn.base.RegressorMixin

Defines the general class of Traditional ELM model for Regression problems that inherit the BaseElm and RegressorMixin classes. It uses Moore–Penrose inverse matrix to calculate the output.

create_network(X, y) intelelm.model.base_elm.MultiLayerELM[source]

Creates a MultiLayerELM network based on provided input data.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Input samples.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Target values for X.

Returns

network – An instance of MultiLayerELM configured with the specified layers and activation function.

Return type

MultiLayerELM

evaluate(y_true, y_pred, list_metrics=('MSE', 'MAE'))[source]

Return the list of performance metrics of the prediction.

Parameters
  • y_true (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • y_pred (array-like of shape (n_samples,) or (n_samples, n_outputs)) – Predicted values for X.

  • list_metrics (list, default=("MSE", "MAE")) – You can get metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

score(X, y, method='RMSE')[source]

Return the metric of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • method (str, default="RMSE") – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

result – The result of selected metric

Return type

float

scores(X, y, list_methods=('MSE', 'MAE'))[source]

Return the list of metrics of the prediction.

Parameters
  • X (array-like of shape (n_samples, n_features)) – Test samples. For some estimators this may be a precomputed kernel matrix or a list of generic objects instead with shape (n_samples, n_samples_fitted), where n_samples_fitted is the number of samples used in the fitting for the estimator.

  • y (array-like of shape (n_samples,) or (n_samples, n_outputs)) – True values for X.

  • list_methods (list, default=("MSE", "MAE")) – You can get all of the metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns

results – The results of the list metrics

Return type

dict

set_predict_request(*, return_prob: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.standard_elm.ElmRegressor

Request metadata passed to the predict method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to predict if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to predict.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

return_prob (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for return_prob parameter in predict.

Returns

self – The updated object.

Return type

object

set_score_request(*, method: Union[bool, None, str] = '$UNCHANGED$') intelelm.model.standard_elm.ElmRegressor

Request metadata passed to the score method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to score if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to score.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

New in version 1.3.

Note

This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a Pipeline. Otherwise it has no effect.

Parameters

method (str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED) – Metadata routing for method parameter in score.

Returns

self – The updated object.

Return type

object