explainable_rl.data_handler package
Submodules
explainable_rl.data_handler.data_handler module
- class DataHandler(hyperparam_dict, dataset, test_dataset=None)[source]
Bases:
objectData Handler which stores and preprocesses data needed for training.
- __init__(hyperparam_dict, dataset, test_dataset=None)[source]
Initialise the DataHandler.
- Parameters
hyperparam_dict (dict) – Dictionary of hyperparameters.
dataset (pd.DataFrame) – Training dataset.
test_dataset (pd.DataFrame) – Test dataset.
- _get_labels(label_dict)[source]
Get the labels from the label dictionary.
- Parameters
label_dict (dict) – The label dictionary.
- Returns
The labels.
- Return type
list
- _inverse_transform_col(col_name: str)[source]
Reverse the normalisation of one column of the dataset.
- Parameters
col_name (str) – The column name.
- _transform_col(col_name: str)[source]
Normalise one column of the dataset.
- Parameters
col_name (str) – The column name.
- get_actions(split='train')[source]
Get the actions taken in the dataset.
- Parameters
split (str) – Specifies train or test split.
- Returns
Actions.
- Return type
pd.DataFrame
- get_rewards(split='train')[source]
Get the rewards taken in the dataset.
- Parameters
split (str) – Specifies train or test split.
- Returns
The rewards.
- Return type
pd.DataFrame
- get_states(split='train')[source]
Get the states taken in the dataset.
- Parameters
split (str) – Specifies train or test split.
- Returns
The states.
- Return type
pd.DataFrame
- normalise_dataset(cols_to_norm=None)[source]
Normalise the dataset to centre with mean zero and variance one.
- Parameters
cols_to_norm (list) – The column names that need normalising.
- prepare_data_for_engine(cols_to_normalise=None)[source]
Prepare the data to be given to the engine.
- Parameters
cols_to_normalise (list) – List of columns to normalise.
- preprocess_data(normalisation=True, columns_to_normalise=None)[source]
Preprocess data into state, action and reward spaces.
Preprocessing applies shuffling, normalisation (if selected) and splits the dataset into states, actions and rewards.
- Parameters
normalisation (bool) – True if normalisation is to be applied.
columns_to_normalise (list) – Columns on which to apply normalisation. If left empty all columns will be normalised.