Skip to content

Noise Corruptions

Isabel edited this page May 27, 2023 · 15 revisions

Parameters:

model: object
     An object which manages the estimation and decoding of a model. Must either provide a fit and predict method, or these will have to be specified in custom_train and custom_predict.
corruption_list: dict or list of dicts
     Dict of noise corruptions to be performed. The key is a string (or list of strings) corresponding to feature name or index. Values are list of noise method and levels (where applicable). Pass a list of dicts to perform several noise corruptions. See <insert link to examples> for examples.
X_train: ndarray, dataframe or sparse matrix of shape (n_samples, n_features)
     The training input samples. Will be transformed to dataframe object (if it is not already) with column names from column_names property, or index values as names. Can contain the target values if label_name is specified.
X_test: ndarray, dataframe or sparse matrix of shape (n_samples, n_features)
     The testing input samples. n_features must be equal for X_train and X_test, and in the same order. Will use column_names as specified in the column_names property, or indexes. Can contain the target values if label_name is specified.
score_func: str or callable.
     Scoring method as string, use sklearn.metrics.get_scorer_names to find available scorers. If callable score function (or loss function) required signature is either score_func(y_pred, y_true) or (model, y_pred, y_true).
y_train: ndarray, dataframe or sparse of shape (n_samples,) or (n_samples, n_outputs), deafult=None
     The training target values, labels in classification, real numbers in regression. Required if label_name is None and if it is not included in X_train as a feature.
y_test: ndarray, dataframe or sparse of shape (n_samples,) or (n_samples, n_outputs), default=None**
     The testing target values. Required if label_name is None and if it is not included in X_test as a feature.
column_names: list, default=None
     List of column names for input samples. Values defaults to index values if None. Not required if X_train is a dataframe with column names.
label_name: str or int, deafult=None
     Column name or column index corresponding to the target values. Required if y_train or y_test are None and X_train is a DataFrame containg the target values.
measure: {None, "eli5", "lime", "shap"}, default=None
     If None default is either coef_ or feature_importances_ attributes where applicable, or permutation importance. Not available for models that use custom fit or predict methods. See further explanation of the other methods <link>here.
n_corruptions: int, default=10
     Number of corruptions to average over for each feature level. Decreasing the number of corruptions will decrease running time, but can make the results of Gaussian noise more vulnerable to outliers drawn from the distribution.
random_state: int, RandomState instance or None, deafult=None
     Controls randomness in sampling and noise addition.
Note: models with aspects of randomness in training or predicting are not affected by this property, and must be set on model initialization.
custom_train: callable, default=None
     Callable with signature train_func(model, X, y). Must return trained model object. Not required if model object has fit method with signature fit(X, y).
custom_predict: callable, default=None
     Callable with signature predict_func(model, X). Must return list, ndarray, tensor, or dataframe of same length as X. Not required if model object has predict method with signature predict(X).
show_plots: bool, default=True
     Determines whether plots of feature importances, variance and score are shown.

Returns:

result: Bunch or dict of such instances
Dictionary-like object, with the following attributes:
corrupted_df: DataFrame
     The noisy data as a result of all corruptions specified in corruption_list. If levels are specified as a range or list of values, corrupted_df will be a result of the final level.
corruption_result: DataFrame
     The value, variance and score (as defined by the scorer) for each feature and each level specified in corruption_list.
value_plot: Figure
     A plot showing the average value of the specified features for each noise corruption.
variance_plot: Figure
     A plot showing the average variance of the value of the specified features for each noise corruption.
score_plot: Figure
     A plot showing the average score of the specified features for each noise corruption.

Clone this wiki locally