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)[source]¶ Bases:
dice_ml.data_interfaces.base_data_interface._BaseData
A data interface for private data with meta information.
-
de_normalize_data
(df)[source]¶ De-normalizes continuous features from [0,1] range to original range.
-
from_dummies
(data, prefix_sep='_')[source]¶ Gets the original data from dummy encoded data with k levels.
-
get_encoded_categorical_feature_indexes
()[source]¶ Gets the column indexes categorical features after one-hot-encoding.
-
get_indexes_of_features_to_vary
(features_to_vary='all')[source]¶ Gets indexes from feature names of one-hot-encoded data.
-
get_inverse_ohe_min_max_normalized_data
(transformed_data)[source]¶ 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_minx_maxx
(normalized=True)[source]¶ Gets the min/max value of features in normalized or de-normalized form.
-
get_ohe_min_max_normalized_data
(query_instance)[source]¶ 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)[source]¶ Computes Median Absolute Deviation of features. If they are <=0, returns a practical value instead
-
normalize_data
(df, encoding='one-hot')[source]¶ Normalizes continuous features to make them fall in the range [0,1].
-
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)[source]¶ 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_mad_validity
(feature_weights)[source]¶ checks feature MAD validity and throw warnings. TODO: add comments as to where this is used if this function is necessary, else remove.
-
de_normalize_data
(df)[source]¶ De-normalizes continuous features from [0,1] range to original range.
-
from_dummies
(data, prefix_sep='_')[source]¶ Gets the original data from dummy encoded data with k levels.
-
get_decimal_precisions
(output_type='list')[source]¶ “Gets the precision of continuous features in the data.
-
get_encoded_categorical_feature_indexes
()[source]¶ Gets the column indexes categorical features after one-hot-encoding.
-
get_indexes_of_features_to_vary
(features_to_vary='all')[source]¶ Gets indexes from feature names of one-hot-encoded data.
-
get_inverse_ohe_min_max_normalized_data
(transformed_data)[source]¶ 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_minx_maxx
(normalized=True)[source]¶ Gets the min/max value of features in normalized or de-normalized form.
-
get_ohe_min_max_normalized_data
(query_instance)[source]¶ 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)[source]¶ Computes required quantile of Absolute Deviations of features.
-
get_valid_feature_range
(feature_range_input, normalized=True)[source]¶ 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)[source]¶ Computes Median Absolute Deviation of features. If they are <=0, returns a practical value instead
-