Time Model

class flood_forecast.time_model.TimeSeriesModel(model_base: str, training_data: str, validation_data: str, test_data: str, params: Dict)[source]

An abstract class used to handle different configurations of models + hyperparams for training, test, and predict functions. This class assumes that data is already split into test train and validation at this point.

__init__(model_base: str, training_data: str, validation_data: str, test_data: str, params: Dict)[source]

Initializes the TimeSeriesModel class with certain attributes.

Parameters:

model_base – The name of the model to load. This MUST be a key in the model_dic

model_dict_function.py. :type model_base: str :param training_data: The path to the training data file :type training_data: str :param validation_data: The path to the validation data file :type validation_data: str :param test_data: The path to the test data file :type test_data: str :param params: A dictionary of parameters to pass to the model

abstract load_model(model_base: str, model_params: Dict, weight_path=None) object[source]

This function should load and return the model. This will vary based on the underlying framework used.

Parameters:
  • model_base (str) – The name of the model to load. This should be a key in the model_dict.

  • model_params – A dictionary of parameters to pass to the model

  • weight_path – The path to the weights to load

abstract make_data_load(data_path, params: Dict, loader_type: str) object[source]

Initializes a data loader based on the provided data_path.

This may be as simple as a pandas dataframe or as complex as a custom PyTorch data loader.

abstract save_model(output_path: str)[source]

Saves a model to a specific path along with a configuration report of the parameters and data info.

Parameters:

output_path (str) – The path to save the model to (should be a directory)

upload_gcs(save_path: str, name: str, file_type: str, epoch=0, bucket_name=None)[source]

Function to upload model checkpoints to GCS. :param save_path: The path of the file to save to GCS. :type save_path: str :param name: The name you want to save the file as. :type name: str :param file_type: The type of file you are saving. :type file_type: str :param epoch: The epoch number that saving occured at. :type epoch: int :param bucket_name: The name of the bucket to save the file to on GCS.

wandb_init() bool[source]

Initializes wandb if the params dict contains the wandb key or if sweep is present. :return: True if wandb is initialized, False otherwise. :rtype: bool

class flood_forecast.time_model.PyTorchForecast(model_base: str, training_data, validation_data, test_data, params_dict: Dict)[source]
__init__(model_base: str, training_data, validation_data, test_data, params_dict: Dict)[source]

Initializes the TimeSeriesModel class with certain attributes.

Parameters:

model_base – The name of the model to load. This MUST be a key in the model_dic

model_dict_function.py. :type model_base: str :param training_data: The path to the training data file :type training_data: str :param validation_data: The path to the validation data file :type validation_data: str :param test_data: The path to the test data file :type test_data: str :param params: A dictionary of parameters to pass to the model

load_model(model_base: str, model_params: Dict, weight_path: str = None, strict=True)[source]

This function should load and return the model. This will vary based on the underlying framework used.

Parameters:
  • model_base (str) – The name of the model to load. This should be a key in the model_dict.

  • model_params – A dictionary of parameters to pass to the model

  • weight_path – The path to the weights to load

save_model(final_path: str, epoch: int) None[source]

Function to save a model to a given file path.

make_data_load(data_path: str, dataset_params: Dict, loader_type: str, the_class='default')[source]

Initializes a data loader based on the provided data_path.

This may be as simple as a pandas dataframe or as complex as a custom PyTorch data loader.

flood_forecast.time_model.scaling_function(start_end_params: Dict, dataset_params: Dict) Dict[source]

Function to scale the data based on the parameters in the dataset_params dict :param start_end_params: The start_end_params dictionary :param dataset_params: The dataset_params dictionary :return: The start_end_params dictionary