graforvfl.network package

graforvfl.network.base_rvfl module

class graforvfl.network.base_rvfl.BaseRVFL(size_hidden=10, act_name='sigmoid', weight_initializer='random_uniform', trainer='MPI', alpha=0.5, seed=None)[source]

Bases: BaseEstimator

This class defines the general Random Vector Functional Link (RVFL) networks

Parameters:
  • size_hidden (int, default=10) – The number of hidden nodes

  • act_name (str, default="sigmoid") – The activation of the hidden layer. The supported values are: [“none”, “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” }

  • weight_initializer (str, default="random_uniform") – The weight initialization methods. The supported methods are: [“orthogonal”, “he_uniform”, “he_normal”, “glorot_uniform”, “glorot_normal”, “lecun_uniform”, “lecun_normal”, “random_uniform”, “random_normal”] For definition of these methods, please check it at: https://keras.io/api/layers/initializers/

  • trainer (str, default = "MPI") –

    The utilized method for training weights of hidden-output layer and weights of input-output layer.
    • MPI: Moore-Penrose inversion

    • OLS: Ordinary Least Squares (OLS) without regularization

    • L2: OLS regression with regularization

  • alpha (float (Optional), default=0.5) – The penalty value for L2 method. Only effect when `trainer`=”L2”.

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

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'}
SUPPORTED_WEIGHT_INITIALIZER = ['orthogonal', 'he_uniform', 'he_normal', 'glorot_uniform', 'glorot_normal', 'lecun_uniform', 'lecun_normal', 'random_uniform', 'random_normal']
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]
get_weights()[source]
get_weights_size()[source]
static load_model(load_path='history', filename='network.pkl')[source]
predict(X)[source]
predict_proba(X)[source]
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='network.pkl')[source]

Save network 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_score_request(*, method: bool | None | str = '$UNCHANGED$') BaseRVFL

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_weights(weights)[source]

graforvfl.network.gfo_rvfl_tuner module

class graforvfl.network.gfo_rvfl_tuner.GfoRvflTuner(problem_type='regression', bounds=None, cv=5, scoring='MSE', optimizer='OriginalWOA', optimizer_paras=None, verbose=True, seed=None)[source]

Bases: object

Defines the Gradient Free Optimization-based Random Vector Functional Link Network.

Parameters:
  • problem_type (str, default="regression") – The problem type

  • bounds (from Mealpy library, default=None) – The boundary for RVFL hyper-parameters. It can be an instance of these classes: [FloatVar, BoolVar, StringVar, IntegerVar, PermutationVar, BinaryVar, MixedSetVar]

  • cv (int, default=5) – The k fold cross-validation method.

  • scoring (str) – The name of objective for the problem, also depend on the problem is classification and regression.

  • optimizer (str or instance of Optimizer class (from Mealpy library), default = "BaseGA") – The Metaheuristic Algorithm that use to solve the feature selection problem. Current supported list, please check it here: https://github.com/thieu1995/mealpy. If a custom optimizer is passed, make sure it is an instance of Optimizer class.

  • optimizer_paras (None or dict of parameter, default=None) – The parameter for the optimizer object. If None, the default parameters of optimizer is used (defined in https://github.com/thieu1995/mealpy.) If dict is passed, make sure it has at least epoch and pop_size parameters.

  • verbose (bool, default=False) – Whether to print progress messages to stdout.

  • 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 sklearn.datasets import load_breast_cancer
>>> from mealpy import StringVar, IntegerVar
>>> from graforvfl import Data, GfoRvflTuner
>>> ## Load data object
>>> X, y = load_breast_cancer(return_X_y=True)
>>> data = Data(X, y)
>>> ## Split train and test
>>> data.split_train_test(test_size=0.2, random_state=2, inplace=True)
>>> print(data.X_train.shape, data.X_test.shape)
>>> ## Scaling dataset
>>> data.X_train, scaler_X = data.scale(data.X_train, scaling_methods=("standard", "minmax"))
>>> data.X_test = scaler_X.transform(data.X_test)
>>> data.y_train, scaler_y = data.encode_label(data.y_train)
>>> data.y_test = scaler_y.transform(data.y_test)
>>> # Design the boundary (parameters)
>>> my_bounds = [
>>>     IntegerVar(lb=2, ub=1000, name="size_hidden"),
>>>     StringVar(valid_sets=("none", "relu", "leaky_relu", "celu", "prelu", "gelu",
>>>         "elu", "selu", "rrelu", "tanh", "sigmoid"), name="act_name"),
>>>     StringVar(valid_sets=("orthogonal", "he_uniform", "he_normal", "glorot_uniform", "glorot_normal",
>>>         "lecun_uniform", "lecun_normal", "random_uniform", "random_normal"), name="weight_initializer")
>>> ]
>>> opt_paras = {"name": "WOA", "epoch": 10, "pop_size": 20}
>>> model = GfoRvflTuner(problem_type="classification", bounds=my_bounds, cv=3, scoring="AS",
>>>                   optimizer="OriginalWOA", optimizer_paras=opt_paras, verbose=True, seed=42)
>>> model.fit(data.X_train, data.y_train)
>>> print(model.best_params)
>>> print(model.best_estimator)
>>> print(model.best_estimator.scores(data.X_test, data.y_test, list_methods=("PS", "RS", "NPV", "F1S", "F2S")))
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'}
fit(X, y)[source]
static load_model(load_path='history', filename='network.pkl')[source]
predict(X)[source]
save_convergence(save_path='history', filename='convergence.csv')[source]

Save the convergence (fitness value) 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_model(save_path='history', filename='network.pkl')[source]

Save network 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_performance_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_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) –

class graforvfl.network.gfo_rvfl_tuner.HyperparameterProblem(bounds=None, minmax='max', X=None, y=None, model_class=None, metric_class=None, obj_name=None, cv=5, seed=None, **kwargs)[source]

Bases: Problem

This class defines the Hyper-parameter tuning problem that will be used for Mealpy library.

Parameters:
  • bounds (from Mealpy library.) –

  • minmax (from Mealpy library.) –

  • 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.

  • model_class (RvflRegressor or RvflClassifier) – The class definition of RVFL network for regression or classification problem.

  • metric_class (RegressionMetric or ClassificationMetric) – The class definition of Performance Metrics for regression or classification problem.

  • obj_name (str) – The name of the loss function used in network

  • cv (int, default=5) – The k fold cross-validation method

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

obj_func(x)[source]

Objective function

Parameters:

x (numpy.ndarray) – Solution.

Returns:

Function value of x.

Return type:

float

graforvfl.network.standard_rvfl module

class graforvfl.network.standard_rvfl.RvflClassifier(size_hidden=10, act_name='sigmoid', weight_initializer='random_normal', trainer='MPI', alpha=0.5, seed=None)[source]

Bases: BaseRVFL, ClassifierMixin

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

Parameters:
  • size_hidden (int, default=10) – The number of hidden nodes

  • act_name (str, default="sigmoid") – The activation of the hidden layer. The supported values are: [“none”, “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” }

  • weight_initializer (str, default="random_uniform") – The weight initialization methods. The supported methods are: [“orthogonal”, “he_uniform”, “he_normal”, “glorot_uniform”, “glorot_normal”, “lecun_uniform”, “lecun_normal”, “random_uniform”, “random_normal”] For definition of these methods, please check it at: https://keras.io/api/layers/initializers/

  • trainer (str, default = "MPI") –

    The utilized method for training weights of hidden-output layer and weights of input-output layer.
    • MPI: Moore-Penrose inversion

    • OLS: Ordinary Least Squares (OLS) without regularization

    • L2: OLS regression with regularization

  • alpha (float (Optional), default=0.5) – The penalty value for L2 method. Only effect when `trainer`=”L2”.

  • 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 graforvfl import Data, RvflClassifier
>>> 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 = RvflClassifier(size_hidden=10, act_name='sigmoid', weight_initializer="random_normal", trainer="OLS", alpha=0.5, seed=42)
>>> 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']
evaluate(y_true, y_pred, list_metrics=('AS', 'RS'))[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]
predict(X)[source]
predict_proba(X)[source]
score(X, y, method='AS')[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=('AS', 'RS'))[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_score_request(*, method: bool | None | str = '$UNCHANGED$') RvflClassifier

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 graforvfl.network.standard_rvfl.RvflRegressor(size_hidden=10, act_name='sigmoid', weight_initializer='random_normal', trainer='MPI', alpha=0.5, seed=None)[source]

Bases: BaseRVFL, RegressorMixin

Defines the ELM network for Regression problems that inherit the BaseRVFL and RegressorMixin classes.

Parameters:
  • size_hidden (int, default=10) – The number of hidden nodes

  • act_name (str, default="sigmoid") – The activation of the hidden layer. The supported values are: [“none”, “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” }

  • weight_initializer (str, default="random_uniform") – The weight initialization methods. The supported methods are: [“orthogonal”, “he_uniform”, “he_normal”, “glorot_uniform”, “glorot_normal”, “lecun_uniform”, “lecun_normal”, “random_uniform”, “random_normal”] For definition of these methods, please check it at: https://keras.io/api/layers/initializers/

  • trainer (str, default = "MPI") –

    The utilized method for training weights of hidden-output layer and weights of input-output layer.
    • MPI: Moore-Penrose inversion

    • OLS: Ordinary Least Squares (OLS) without regularization

    • L2: OLS regression with regularization

  • alpha (float (Optional), default=0.5) – The penalty value for L2 method. Only effect when `trainer`=”L2”.

  • 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 graforvfl import RvflRegressor, Data
>>> from sklearn.datasets import make_regression
>>> X, y = make_regression(n_samples=200, random_state=1)
>>> data = Data(X, y)
>>> data.split_train_test(test_size=0.2, random_state=1)
>>> model = RvflRegressor(size_hidden=10, act_name='sigmoid', weight_initializer="random_normal", trainer="OLS", alpha=0.5, seed=42)
>>> model.fit(data.X_train, data.y_train)
>>> pred = model.predict(data.X_test)
>>> print(pred)
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) – 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 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 metrics from Permetrics library: https://github.com/thieu1995/permetrics

Returns:

results – The results of the list metrics

Return type:

dict

set_score_request(*, method: bool | None | str = '$UNCHANGED$') RvflRegressor

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