Arcana Procedure

Submodules

arcana.procedures.config_handler module

This module contains the ConfigHandler class which is used to read the config files and set the config dataclasses.

class arcana.procedures.config_handler.ConfigHandler

Bases: object

Config handler class

get_data_config()

Get the data config

Returns:

DataConfig – data config

get_general_config()

Get the general config

Returns:

GeneralConfig – general config

get_model_config()

Get the model config

Returns:

ModelConfig – model config

get_procedure_config()

Get the procedure config

Returns:

ProcedureConfig – procedure config

class arcana.procedures.config_handler.DataConfig(data_headers: list | None = None, number_of_samples: int | None = None, test_sample: int | None = None, maximum_available_cycles: int | None = None, train_ratio: float | None = None, val_test_ratio: float | None = None, path_to_config: str = 'config/general_parameter.ini')

Bases: object

Data config dataclass

data_headers: list = None
maximum_available_cycles: int = None
number_of_samples: int = None
path_to_config: str = 'config/general_parameter.ini'
test_sample: int = None
train_ratio: float = None
val_test_ratio: float = None
class arcana.procedures.config_handler.GeneralConfig(test_id: str | None = None, input_data_folder: str | None = None, data_name: str | None = None, pretrained_model: str | None = None, scaler_model: str | None = None, path_to_config: str = 'config/general_parameter.ini')

Bases: object

General config dataclass

data_name: str = None
input_data_folder: str = None
path_to_config: str = 'config/general_parameter.ini'
pretrained_model: str = None
scaler_model: str = None
test_id: str = None
class arcana.procedures.config_handler.ModelConfig

Bases: object

Model config dataclass

read_tuning_conf(trial)

Read the tuning config file and set the model config attributes to the values in the config file :param trial: Trial object :type trial: optuna.trial.Trial

class arcana.procedures.config_handler.ProcedureConfig(naive_training: bool | None = None, predicting: bool | None = None, preprocess_data: bool | None = None, optuna_tuning: bool | None = None, learning_rate_type: str | None = None, attention_type: str | None = None, number_of_trials: int | None = None, transfer_learning: bool | None = None, path_to_config: str = 'config/general_parameter.ini')

Bases: object

Procedure config dataclass

attention_type: str = None
learning_rate_type: str = None
naive_training: bool = None
number_of_trials: int = None
optuna_tuning: bool = None
path_to_config: str = 'config/general_parameter.ini'
predicting: bool = None
preprocess_data: bool = None
transfer_learning: bool = None

arcana.procedures.finetuning module

This module contains the class for fine-tuning the model.

class arcana.procedures.finetuning.FineTuning(tl_strategy='decoder')

Bases: TrainProcedure

This class is the main class for fine-tuning the model. It inherits from the TrainProcedure class.

load_model()

Load the pre-trained model from the path

training(trial=None, model_folder=None)

Finetune the model depending on the transfer learning strategy

Parameters:
  • trial (optuna.trial) – optuna trial

  • model_folder (str) – model folder

unfreeze_decoder()

Unfreeze the decoder layer by making the autograd true for the decoder layer parameters.

unfreeze_fc_and_attention()

Unfreeze the fully connected layer and the attention layer in the decoder by making the autograd true for the parameters.

unfreeze_fully_connected()

Unfreeze the fully connected layer by making the autograd true for the parameters.

arcana.procedures.predicting module

This module is used to predict the model with the test data.

class arcana.procedures.predicting.PredictProcedure(arcana_procedure)

Bases: object

Predicting procedure

all_preparation()

Prepare the data for the prediction

get_pretrained_model()

Get the pretrained model

get_test_data()

Get the test data

predicting(model_folder=None)

Predict the model

Parameters:

model_folder (str) – model folder. Default is None.

predicting_all(fix_sequency_length, plot_prediction=True)

Predict the model

Parameters:
  • fix_sequency_length (int) – the length of the available sequence

  • plot_prediction (bool) – whether to plot the prediction or not

preparation()

Prepare the data for the prediction

arcana.procedures.training module

This module is the main module for training the model. It contains the TrainProcedure class which is the main class

class arcana.procedures.training.TrainProcedure

Bases: object

This class is the main class for training the model. It contains some of the necessary functions for training, predicting and finetuning the model. The class also contains all the parameters for the training, predicting and tuning of the model. It also contains the functions for saving the model parameters and the data splits.

data_splits()

Get the data splits for training, validation and testing

loader_initialization()

Initialize the data loaders

model_parameter_initialization()

Initialize the model parameters

save_data_splits()

Save the data splits

save_model_parameters(model_folder=None)

Save the model parameters

Parameters:

model_folder (str) – Path to the model folder

set_device()

Set the device for training the model

train_element_initialization()

Initialize the training elements

training(trial=None, model_folder=None)

Train the model

Parameters:
  • trial (optuna.trial.Trial) – Trial object

  • model_folder (str) – Path to the model folder

arcana.procedures.tuning module

This module contains the class for tuning the model. The tuning is done using the Optuna library.

class arcana.procedures.tuning.TuneProcedure(procedure)

Bases: object

This class is the main class for tuning the model. It contains some of the necessary functions for tuning the model. The class also contains all the parameters for the tuning of the model. It also contains the functions for saving the model parameters and the data splits. The Tuning is done using the Optuna library.

rename_trials()

Rename the trials folders according to their state. Pruned trials are deleted.

save_tuning_params()

Save the tuning parameters and the study

tuning()

Run the tuning. First create the study, then optimize the model, then prune the bad trials

Module contents