dice_ml.data_interfaces package — DiCE 0.7 documentation

# dice_ml.data_interfaces package

## Submodules

## dice_ml.data_interfaces.base_data_interface module

Module containing base class for data interfaces for dice-ml.

## dice_ml.data_interfaces.private_data_interface module

Module containing meta data information about private data.

class `dice_ml.data_interfaces.private_data_interface.` `PrivateData`(params)

  Bases: `dice_ml.data_interfaces.base_data_interface._BaseData`

  A data interface for private data with meta information.

  `create_ohe_params`()
  `de_normalize_data`(df)

    De-normalizes continuous features from [0,1] range to original range.

  `from_dummies`(data, prefix_sep='_')

    Gets the original data from dummy encoded data with k levels.

  `from_label`(data)

    Transforms label encoded data back to categorical values

  `get_data_params_for_gradient_dice`()

    Gets all data related params for DiCE.

  `get_decimal_precisions`()

    “Gets the precision of continuous features in the data.

  `get_decoded_data`(data, encoding='one-hot')

    Gets the original data from encoded data.

  `get_encoded_categorical_feature_indexes`()

    Gets the column indexes categorical features after one-hot-encoding.

  `get_indexes_of_features_to_vary`(features_to_vary='all')

    Gets indexes from feature names of one-hot-encoded data.

  `get_inverse_ohe_min_max_normalized_data`(transformed_data)

    Transforms one-hot-encoded and min-max normalized data into raw user-fed data format. transformed_data should be a dataframe or an array

  `get_mads`(normalized=True)

    Computes Median Absolute Deviation of features.

  `get_minx_maxx`(normalized=True)

    Gets the min/max value of features in normalized or de-normalized form.

  `get_ohe_min_max_normalized_data`(query_instance)

    Transforms query_instance into one-hot-encoded and min-max normalized data. query_instance should be a dict, a dataframe, a list, or a list of dicts

  `get_valid_mads`(normalized=False, display_warnings=False, return_mads=True)

    Computes Median Absolute Deviation of features. If they are <=0, returns a practical value instead

  `normalize_data`(df, encoding='one-hot')

    Normalizes continuous features to make them fall in the range [0,1].

  `one_hot_encode_data`(data)

    One-hot-encodes the data.

  `prepare_df_for_ohe_encoding`()

    Create base dataframe to do OHE for a single instance or a set of instances

  `prepare_query_instance`(query_instance)

    Prepares user defined test input(s) for DiCE.

## dice_ml.data_interfaces.public_data_interface module

Module containing all required information about the interface between raw (or transformed) public data and DiCE explainers.

class `dice_ml.data_interfaces.public_data_interface.` `PublicData`(params)

  Bases: `dice_ml.data_interfaces.base_data_interface._BaseData`

  A data interface for public data. This class is an interface to DiCE explainers and contains methods to transform user-fed raw data into the format a DiCE explainer requires, and vice versa.

  `check_features_to_vary`(features_to_vary)
  `check_mad_validity`(feature_weights)

    checks feature MAD validity and throw warnings. TODO: add comments as to where this is used if this function is necessary, else remove.

  `check_permitted_range`(permitted_range)
  `create_ohe_params`()
  `de_normalize_data`(df)

    De-normalizes continuous features from [0,1] range to original range.

  `from_dummies`(data, prefix_sep='_')

    Gets the original data from dummy encoded data with k levels.

  `from_label`(data)

    Transforms label encoded data back to categorical values

  `get_data_params_for_gradient_dice`()

    Gets all data related params for DiCE.

  `get_data_type`(col)

    Infers data type of a continuous feature from the training data.

  `get_decimal_precisions`(output_type='list')

    “Gets the precision of continuous features in the data.

  `get_decoded_data`(data, encoding='one-hot')

    Gets the original data from encoded data.

  `get_encoded_categorical_feature_indexes`()

    Gets the column indexes categorical features after one-hot-encoding.

  `get_features_range`(permitted_range_input=None)
  `get_indexes_of_features_to_vary`(features_to_vary='all')

    Gets indexes from feature names of one-hot-encoded data.

  `get_inverse_ohe_min_max_normalized_data`(transformed_data)

    Transforms one-hot-encoded and min-max normalized data into raw user-fed data format. transformed_data should be a dataframe or an array

  `get_mads`(normalized=False)

    Computes Median Absolute Deviation of features.

  `get_minx_maxx`(normalized=True)

    Gets the min/max value of features in normalized or de-normalized form.

  `get_ohe_min_max_normalized_data`(query_instance)

    Transforms query_instance into one-hot-encoded and min-max normalized data. query_instance should be a dict, a dataframe, a list, or a list of dicts

  `get_quantiles_from_training_data`(quantile=0.05, normalized=False)

    Computes required quantile of Absolute Deviations of features.

  `get_valid_feature_range`(feature_range_input, normalized=True)

    Gets the min/max value of features in normalized or de-normalized form. Assumes that all features are already encoded to numerical form such that the number of features remains the same.

    # TODO needs work adhere to label encoded max and to support permitted_range for both continuous and discrete when provided in _generate_counterfactuals.

  `get_valid_mads`(normalized=False, display_warnings=False, return_mads=True)

    Computes Median Absolute Deviation of features. If they are <=0, returns a practical value instead

  `normalize_data`(df)

    Normalizes continuous features to make them fall in the range [0,1].

  `one_hot_encode_data`(data)

    One-hot-encodes the data.

  `prepare_df_for_ohe_encoding`()

    Create base dataframe to do OHE for a single instance or a set of instances

  `prepare_query_instance`(query_instance)

    Prepares user defined test input(s) for DiCE.

## Module contents