GAMINet
Neural GAM with main effects and interactions.
- class modeva.models.MoGAMINetRegressor(name: str = None, feature_names=None, feature_types=None, interact_num=10, subnet_size_main_effect=(20,), subnet_size_interaction=(20, 20), activation_func='ReLU', max_epochs=(1000, 1000, 1000), learning_rates=(0.001, 0.001, 0.0001), early_stop_thres=('auto', 'auto', 'auto'), batch_size=1000, batch_size_inference=10000, max_iter_per_epoch=100, val_ratio=0.2, warm_start=True, gam_sample_size=5000, mlp_sample_size=1000, heredity=True, reg_clarity=0.1, loss_threshold=0.01, reg_mono=0.1, mono_increasing_list=(), mono_decreasing_list=(), mono_sample_size=1000, include_interaction_list=(), boundary_clip=True, normalize=True, verbose=False, n_jobs=10, device=None, random_state=0)[source]
Generalized additive model with pairwise interaction regressor.
- Parameters:
- namestr, default=None
The name of the model.
- feature_nameslist or None, default=None
The list of feature names. If None, will use “X0”, “X1”, “X2”, etc.
- feature_typeslist or None, default=None
The list of feature types. Available types include “numerical” and “categorical”. If None, will use numerical for all features.
- interact_numint, default=10
The max number of interactions to be included in the second stage training.
- subnet_size_main_effecttuple of int, default=(20, )
The hidden layer architecture of each subnetwork in the main effect block.
- subnet_size_interactiontuple of int, default=(20, 20)
The hidden layer architecture of each subnetwork in the interaction block.
- activation_func{“ReLU”, “Sigmoid”, “Tanh”}, default=”ReLU”
The name of the activation function.
- max_epochstuple of THREE int, default=(1000, 1000, 1000)
The max number of epochs in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively.
- learning_ratestuple of THREE float, default=(1e-3, 1e-3, 1e-4)
The initial learning rates of Adam optimizer in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively.
- early_stop_threstuple of THREE int or “auto”, default=[“auto”, “auto”, “auto”]
The early stopping threshold in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively. In auto mode, the value is set to max(5, min(5000 * n_features / (max_iter_per_epoch * batch_size), 100)).
- batch_sizeint, default=1000
The batch size. Note that it should not be larger than the training size * (1 - validation ratio).
- batch_size_inferenceint, default=10000
The batch size used in the inference stage. It is imposed to avoid out-of-memory issue when dealing very large dataset.
- max_iter_per_epochint, default=100
The max number of iterations per epoch. In the init stage of model fit, its value will be clipped by min(max_iter_per_epoch, int(sample_size / batch_size)). For each epoch, the data would be reshuffled and only the first “max_iter_per_epoch” batches would be used for training. It is imposed to make the training scalable for very large dataset.
- val_ratiofloat, default=0.2
The validation ratio, should be greater than 0 and smaller than 1.
- warm_startbool, default=True
Initialize the network by fitting a rough LGBM model. The initialization is performed by, 1) fit a LGBM model as teacher model, 2) generate random samples from the teacher model, 3) fit each subnetwork using the generated samples. And it is used for both main effect and interaction subnetwork initialization.
- gam_sample_sizeint, default=5000
The sub-sample size for GAM fitting as warm_start=True.
- mlp_sample_sizeint, default=1000
The generated sample size for individual subnetwork fitting as warm_start=True.
- hereditybool, default=True
Whether to perform interaction screening subject to heredity constraint.
- loss_thresholdfloat, default=0.01
The loss tolerance threshold for selecting fewer main effects or interactions, according to the validation performance. For instance, assume the best validation performance is achieved when using 10 main effects; if only use the top 5 main effects also gives similar validation performance, we could prune the last 5 by setting this parameter to be positive.
- reg_clarityfloat, default=0.1
The regularization strength of marginal clarity constraint.
- reg_monofloat, default=0.1
The regularization strength of monotonicity constraint.
- mono_sample_sizeint, default=1000
As monotonicity constraint is used, we would generate some data points uniformly within the feature space per epoch, to impose the monotonicity regularization in addition to original training samples.
- mono_increasing_listtuple of str, default=()
The feature name tuple subject to monotonic increasing constraint.
- mono_decreasing_listtuple of str, default=()
The feature name tuple subject to monotonic decreasing constraint.
- include_interaction_listtuple of (str, str), default=()
The tuple of interaction to be included for fitting, each interaction is expressed by (feature_name1, feature_name2).
- boundary_clipbool, default=True
In the inference stage, whether to clip the feature values by their min and max values in the training data.
- normalizebool, default=True
Whether to normalize the data before inputting to the network.
- verbosebool, default=False
Whether to output the training logs.
- n_jobsint, default=10
The number of cpu cores for parallel computing. -1 means all the available cpus will be used.
- devicestring, default=None
The hardware device name used for training.
- random_stateint, default=0
The random seed.
- Attributes:
- net_torch network object
The fitted GAMI-Net module.
- interaction_list_list of tuples
The list of feature index pairs (tuple) for each fitted interaction.
- active_main_effect_index_list of int
The selected main effect index.
- active_interaction_index_list of int
The selected interaction index.
- main_effect_val_loss_list of float
The validation loss as the most important main effects are sequentially added.
- interaction_val_loss_list of float
The validation loss as the most important interactions are sequentially added.
- time_cost_list of tuple
The time cost of each stage.
- n_interactions_int
The actual number of interactions used in the fitting stage. It is greater or equal to the number of active interactions.
- calibrate_interval(X, y, alpha=0.1, max_depth: int = 5)
Fit a conformal prediction model to the given data.
This method computes the model’s prediction interval calibrated to the given data.
If the model is a regressor, splits the data with 50% for fitting lower (alpha / 5) and upper (1 - alpha / 2) gradient boosting trees-based quantile regression to the model’s residual; and 50% for calibration.
If the model is a binary classifiers, it computes the calibration quantile based on predicted probabilities for the positive class.
- Parameters:
- XXnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- yarray-like of shape (n_samples, )
Target values.
- alphafloat, default=0.1
Expected miscoverage for the conformal prediction.
- max_depthint, default=5
Maximum depth of the gradient boosting trees for regression tasks. Only used when task_type is REGRESSION.
- Raises:
- ValueError: If the model is neither a regressor nor a classifier.
- certify_mono(n_samples=10000)
Certify whether monotonicity constraint is satisfied.
- Parameters:
- n_samplesint, default=10000
Size of random samples for certifying the monotonicity constraint.
- Returns:
- mono_statusbool
True means monotonicity constraint is satisfied.
- extract_model_info(feature_names)
- fit(X, y, sample_weight=None)[source]
Fits a GAMINet regression model to the training data.
This method trains the model in three stages: main effects training, interaction training, and fine-tuning. It handles data preprocessing, model initialization, and the complete training pipeline.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Training data features.
- ynp.ndarray of shape (n_samples,)
Target values for regression.
- sample_weightnp.ndarray of shape (n_samples,), default=None
Individual weights for each sample. If None, all samples are weighted equally.
- Returns:
- selfobject
Returns the fitted estimator.
- get_clarity_loss(x, sample_weight=None)
Returns clarity loss of given samples.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features
- sample_weightnp.ndarray of shape (n_samples, )
Sample weight.
- Returns:
- clarity_lossfloat
clarity loss.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_mono_loss(x, sample_weight=None)
Returns monotonicity loss of given samples.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- sample_weightnp.ndarray of shape (n_samples, ), default=None
Sample weight.
- Returns:
- mono_lossfloat
monotonicity loss.
- get_params(deep=True)
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- get_raw_output(x, main_effect=True, interaction=True)
Returns numpy array of raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- main_effectbool, default=True
Whether to include main effects.
- interactionbool, default=True
Whether to include interactions.
- Returns:
- prednp.ndarray of shape (n_samples, 1)
numpy array of raw prediction.
- interpret(dataset)
- load(file_name: str)
Load the model into memory from file system.
- Parameters:
- file_name: str
The path and name of the file.
- Returns:
- estimator object
- predict(X)
Model predictions, calling the child class’s ‘_predict’ method.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- Returns:
- np.ndarray: The (calibrated) final prediction
- predict_effect(fidx, X)
Get the raw prediction of given feature idx.
- Parameters:
- fidx: tuple of int
The index of features
- X: np.ndarray
The input data.
- predict_interaction(x)
Returns numpy array of interactions’ raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- Returns:
- prednp.ndarray of shape (n_samples, n_interactions)
numpy array of interactions’ raw prediction.
- predict_interval(X)
Predict the prediction interval for the given data based on the conformal prediction model.
It splits the data with 50% for fitting lower (alpha / 5) and upper (1 - alpha / 2) gradient boosting trees-based quantile regression to the model’s residual; and 50% for calibration.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- Returns:
- np.ndarray: The lower and upper bounds of the prediction intervals for each sample
in the format [n_samples, 2] for regressors or a flattened array for classifiers.
- Raises:
- ValueError: If fit_conformal has not been called to fit the conformal prediction model
before calling this method.
- predict_main_effect(x)
Returns numpy array of main effects’ raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- Returns:
- prednp.ndarray of shape (n_samples, n_features)
numpy array of main effects’ raw prediction.
- reset_calibrate_interval()
- reset_calibrate_proba()
- save(file_name: str)
Save the model into file system.
- Parameters:
- file_name: str
The path and name of the file.
- score(X, y, sample_weight=None)
Return the coefficient of determination of the prediction.
The coefficient of determination \(R^2\) is defined as \((1 - \frac{u}{v})\), where \(u\) is the residual sum of squares
((y_true - y_pred)** 2).sum()and \(v\) is the total sum of squares((y_true - y_true.mean()) ** 2).sum(). The best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a \(R^2\) score of 0.0.- Parameters:
- Xarray-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), wheren_samples_fittedis the number of samples used in the fitting for the estimator.- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True values for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns:
- scorefloat
\(R^2\) of
self.predict(X)w.r.t. y.
Notes
The \(R^2\) score used when calling
scoreon a regressor usesmultioutput='uniform_average'from version 0.23 to keep consistent with default value ofr2_score(). This influences thescoremethod of all the multioutput regressors (except forMultiOutputRegressor).
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGAMINetRegressor
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.Added 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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter infit.
- Returns:
- selfobject
The updated object.
- set_params(**params)
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:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGAMINetRegressor
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.Added 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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
- Returns:
- selfobject
The updated object.
- ACTIVATIONS = ['ReLU', 'Sigmoid', 'Tanh']
- property name
- property version
- class modeva.models.MoGAMINetClassifier(name: str = None, feature_names=None, feature_types=None, interact_num=10, subnet_size_main_effect=(20,), subnet_size_interaction=(20, 20), activation_func='ReLU', max_epochs=(1000, 1000, 1000), learning_rates=(0.001, 0.001, 0.0001), early_stop_thres=('auto', 'auto', 'auto'), batch_size=1000, batch_size_inference=10000, max_iter_per_epoch=100, val_ratio=0.2, warm_start=True, gam_sample_size=5000, mlp_sample_size=1000, heredity=True, reg_clarity=0.1, loss_threshold=0.01, reg_mono=0.1, mono_increasing_list=(), mono_decreasing_list=(), mono_sample_size=1000, include_interaction_list=(), boundary_clip=True, normalize=True, verbose=False, n_jobs=10, device=None, random_state=0)[source]
Generalized additive model with pairwise interaction classifier.
- Parameters:
- namestr, default=None
The name of the model.
- feature_nameslist or None, default=None
The list of feature names. If None, will use “X0”, “X1”, “X2”, etc.
- feature_typeslist or None, default=None
The list of feature types. Available types include “numerical” and “categorical”. If None, will use numerical for all features.
- interact_numint, default=10
The max number of interactions to be included in the second stage training.
- subnet_size_main_effecttuple of int, default=(20, )
The hidden layer architecture of each subnetwork in the main effect block.
- subnet_size_interactiontuple of int, default=(20, 20)
The hidden layer architecture of each subnetwork in the interaction block.
- activation_func{“ReLU”, “Sigmoid”, “Tanh”}, default=”ReLU”
The name of the activation function.
- max_epochstuple of THREE int, default=(1000, 1000, 1000)
The max number of epochs in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively.
- learning_ratestuple of THREE float, default=(1e-3, 1e-3, 1e-4)
The initial learning rates of Adam optimizer in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively.
- early_stop_threstuple of THREE int or “auto”, default=[“auto”, “auto”, “auto”]
The early stopping threshold in the first (main effect training), second (interaction training), and third (fine-tuning) stages, respectively. In auto mode, the value is set to max(5, min(5000 * n_features / (max_iter_per_epoch * batch_size), 100)).
- batch_sizeint, default=1000
The batch size. Note that it should not be larger than the training size * (1 - validation ratio).
- batch_size_inferenceint, default=10000
The batch size used in the inference stage. It is imposed to avoid out-of-memory issue when dealing very large dataset.
- max_iter_per_epochint, default=100
The max number of iterations per epoch. In the init stage of model fit, its value will be clipped by min(max_iter_per_epoch, int(sample_size / batch_size)). For each epoch, the data would be reshuffled and only the first “max_iter_per_epoch” batches would be used for training. It is imposed to make the training scalable for very large dataset.
- val_ratiofloat, default=0.2
The validation ratio, should be greater than 0 and smaller than 1.
- warm_startbool, default=True
Initialize the network by fitting a rough LGBM model. The initialization is performed by, 1) fit a LGBM model as teacher model, 2) generate random samples from the teacher model, 3) fit each subnetwork using the generated samples. And it is used for both main effect and interaction subnetwork initialization.
- gam_sample_sizeint, default=5000
The sub-sample size for GAM fitting as warm_start=True.
- mlp_sample_sizeint, default=1000
The generated sample size for individual subnetwork fitting as warm_start=True.
- hereditybool, default=True
Whether to perform interaction screening subject to heredity constraint.
- loss_thresholdfloat, default=0.01
The loss tolerance threshold for selecting fewer main effects or interactions, according to the validation performance. For instance, assume the best validation performance is achieved when using 10 main effects; if only use the top 5 main effects also gives similar validation performance, we could prune the last 5 by setting this parameter to be positive.
- reg_clarityfloat, default=0.1
The regularization strength of marginal clarity constraint.
- reg_monofloat, default=0.1
The regularization strength of monotonicity constraint.
- mono_sample_sizeint, default=1000
As monotonicity constraint is used, we would generate some data points uniformly within the feature space per epoch, to impose the monotonicity regularization in addition to original training samples.
- mono_increasing_listtuple of str, default=()
The feature name tuple subject to monotonic increasing constraint.
- mono_decreasing_listtuple of str, default=()
The feature name tuple subject to monotonic decreasing constraint.
- include_interaction_listtuple of (str, str), default=()
The tuple of interaction to be included for fitting, each interaction is expressed by (feature_name1, feature_name2).
- boundary_clipbool, default=True
In the inference stage, whether to clip the feature values by their min and max values in the training data.
- normalizebool, default=True
Whether to normalize the data before inputting to the network.
- verbosebool, default=False
Whether to output the training logs.
- n_jobsint, default=10
The number of cpu cores for parallel computing. -1 means all the available cpus will be used.
- devicestring, default=None
The hardware device name used for training.
- random_stateint, default=0
The random seed.
- Attributes:
- net_torch network object
The fitted GAMI-Net module.
- interaction_list_list of tuples
The list of feature index pairs (tuple) for each fitted interaction.
- active_main_effect_index_list of int
The selected main effect index.
- active_interaction_index_list of int
The selected interaction index.
- main_effect_val_loss_list of float
The validation loss as the most important main effects are sequentially added.
- interaction_val_loss_list of float
The validation loss as the most important interactions are sequentially added.
- time_cost_list of tuple
The time cost of each stage.
- n_interactions_int
The actual number of interactions used in the fitting stage. It is greater or equal to the number of active interactions.
- calibrate_interval(X, y, alpha=0.1)
Fit a conformal prediction model to the given data.
This method computes the model’s prediction interval calibrated to the given data.
It computes the calibration quantile based on predicted probabilities for the positive class.
- Parameters:
- XXnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- yarray-like of shape (n_samples, )
Target values.
- alphafloat, default=0.1
Expected miscoverage for the conformal prediction.
- Raises:
- ValueError: If the model is neither a regressor nor a classifier.
- calibrate_proba(X, y, sample_weight=None, method='sigmoid')
Fit the calibration method on the model’s predictions.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- ynp.ndarray of shape (n_samples, )
Ground truth labels.
- sample_weightarray-like, shape (n_samples,), default=None
Sample weights.
- method{‘sigmoid’, ‘isotonic’}, default=’sigmoid’
The calibration method.
‘sigmoid’: Platt’s method, i.e., fit a logistic regression on predicted probabilities and y
‘isotonic’: Fit an isotonic regression on predicted probabilities and y.
- Returns:
- self: Calibrated estimator
- certify_mono(n_samples=10000)
Certify whether monotonicity constraint is satisfied.
- Parameters:
- n_samplesint, default=10000
Size of random samples for certifying the monotonicity constraint.
- Returns:
- mono_statusbool
True means monotonicity constraint is satisfied.
- decision_function(X, calibration: bool = True)
Computes the decision function for the given input data.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will use calibrated probability if calibration is done. Otherwise, will use raw probability.
- Returns:
- logit_predictionarray, shape (n_samples,) or (n_samples, n_classes)
Array of (calibrated) logit predictions.
- extract_model_info(feature_names)
- fit(X, y, sample_weight=None)[source]
Fit GAMINetClassifier model.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Data features.
- ynp.ndarray of shape (n_samples, )
Target response.
- sample_weightnp.ndarray of shape (n_samples, )
Sample weight.
- Returns:
- selfobject
Fitted Estimator.
- get_clarity_loss(x, sample_weight=None)
Returns clarity loss of given samples.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features
- sample_weightnp.ndarray of shape (n_samples, )
Sample weight.
- Returns:
- clarity_lossfloat
clarity loss.
- get_metadata_routing()
Get metadata routing of this object.
Please check User Guide on how the routing mechanism works.
- Returns:
- routingMetadataRequest
A
MetadataRequestencapsulating routing information.
- get_mono_loss(x, sample_weight=None)
Returns monotonicity loss of given samples.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- sample_weightnp.ndarray of shape (n_samples, ), default=None
Sample weight.
- Returns:
- mono_lossfloat
monotonicity loss.
- get_params(deep=True)
Get parameters for this estimator.
- Parameters:
- deepbool, default=True
If True, will return the parameters for this estimator and contained subobjects that are estimators.
- Returns:
- paramsdict
Parameter names mapped to their values.
- get_raw_output(x, main_effect=True, interaction=True)
Returns numpy array of raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- main_effectbool, default=True
Whether to include main effects.
- interactionbool, default=True
Whether to include interactions.
- Returns:
- prednp.ndarray of shape (n_samples, 1)
numpy array of raw prediction.
- interpret(dataset)
- load(file_name: str)
Load the model into memory from file system.
- Parameters:
- file_name: str
The path and name of the file.
- Returns:
- estimator object
- predict(X, calibration: bool = True)
Model predictions, calling the child class’s ‘_predict’ method.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will use calibrated probability if calibration is done. Otherwise, will use raw probability.
- Returns:
- np.ndarray: The (calibrated) final prediction
- predict_effect(fidx, X)
Get the raw prediction of given feature idx.
- Parameters:
- fidx: tuple of int
The index of features
- X: np.ndarray
The input data.
- predict_interaction(x)
Returns numpy array of interactions’ raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- Returns:
- prednp.ndarray of shape (n_samples, n_interactions)
numpy array of interactions’ raw prediction.
- predict_interval(X)
Predict the prediction set for the given data based on the conformal prediction model.
This method computes the model prediction interval (regression) or prediction sets (classification) using conformal prediction.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- Returns:
- np.ndarray: The lower and upper bounds of the prediction intervals for each sample
in the format [n_samples, 2] for regressors or a flattened array for classifiers.
- Raises:
- ValueError: If fit_conformal has not been called to fit the conformal prediction model
before calling this method.
- predict_main_effect(x)
Returns numpy array of main effects’ raw prediction.
- Parameters:
- xnp.ndarray of shape (n_samples, n_features)
Data features.
- Returns:
- prednp.ndarray of shape (n_samples, n_features)
numpy array of main effects’ raw prediction.
- predict_proba(X, calibration: bool = True)
Predict (calibrated) probabilities for X.
- Parameters:
- Xnp.ndarray of shape (n_samples, n_features)
Feature matrix for prediction.
- calibrationbool, default=True
If True, will return calibrated probability if calibration is done. Otherwise, will return raw probability.
- Returns:
- np.ndarray: The (calibrated) predicted probabilities
- reset_calibrate_interval()
- reset_calibrate_proba()
- save(file_name: str)
Save the model into file system.
- Parameters:
- file_name: str
The path and name of the file.
- score(X, y, sample_weight=None)
Return the mean accuracy 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:
- Xarray-like of shape (n_samples, n_features)
Test samples.
- yarray-like of shape (n_samples,) or (n_samples, n_outputs)
True labels for X.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights.
- Returns:
- scorefloat
Mean accuracy of
self.predict(X)w.r.t. y.
- set_decision_function_request(*, calibration: bool | None | str = '$UNCHANGED$') MoGAMINetClassifier
Request metadata passed to the
decision_functionmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed todecision_functionif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it todecision_function.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.Added 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:
- calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
calibrationparameter indecision_function.
- Returns:
- selfobject
The updated object.
- set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGAMINetClassifier
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.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.Added 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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter infit.
- Returns:
- selfobject
The updated object.
- set_params(**params)
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:
- **paramsdict
Estimator parameters.
- Returns:
- selfestimator instance
Estimator instance.
- set_predict_proba_request(*, calibration: bool | None | str = '$UNCHANGED$') MoGAMINetClassifier
Request metadata passed to the
predict_probamethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredict_probaif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict_proba.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.Added 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:
- calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
calibrationparameter inpredict_proba.
- Returns:
- selfobject
The updated object.
- set_predict_request(*, calibration: bool | None | str = '$UNCHANGED$') MoGAMINetClassifier
Request metadata passed to the
predictmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed topredictif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it topredict.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.Added 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:
- calibrationstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
calibrationparameter inpredict.
- Returns:
- selfobject
The updated object.
- set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') MoGAMINetClassifier
Request metadata passed to the
scoremethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toscoreif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toscore.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.Added 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:
- sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
sample_weightparameter inscore.
- Returns:
- selfobject
The updated object.
- ACTIVATIONS = ['ReLU', 'Sigmoid', 'Tanh']
- property name
- property version