AIModels.AIClasses module

Classes for the AI project

Classes

Field:

Class for fields

EarlyStopping:

Class for early stopping

TimeSeriesDataset:

Class for time series dataset

class AIModels.AIClasses.Field(name, levels, area, mr, dstart='1/1/1940', dtend='12/31/2022')[source]

Bases: object

Class for fields

Parameters:
  • name (string) -- Name of the field

  • levels (string) -- Level of the field

  • area (string) -- Area to be analyzed, possible values are

    • 'TROPIC': Tropics

    • 'GLOBAL': Global

    • 'PACTROPIC': Pacific Tropics

    • 'WORLD': World

    • 'EUROPE': Europe

    • 'NORTH_AMERICA': North America

    • 'NH-ML': Northern Hemisphere Mid-Latitudes

  • mr (float) -- Number of EOF retained

  • dstart (string) -- Start date for field

  • dtend (string) -- End date for field

Variables:
  • name (string) -- Name of the field

  • levels (string) -- Level of the field

  • area (string) -- Area of the field

  • mr (float) -- Number of EOF retained

  • dstart (string) -- Start date for field

  • dtend (string) -- End date for field

class AIModels.AIClasses.EarlyStopping(patience=5, verbose=False, delta=0)[source]

Bases: object

Class for early stopping

Parameters:
  • patience (int) -- Number of epochs to wait before stopping

  • verbose (boolean) -- If True, print the epoch when stopping

  • delta (float) -- Minimum change in loss to be considered an improvement

Variables:
  • patience (int) -- Number of epochs to wait before stopping

  • verbose (boolean) -- If True, print the epoch when stopping

  • delta (float) -- Minimum change in loss to be considered an improvement

  • counter (int) -- Number of epochs since last improvement

  • best_score (float) -- Best loss score

  • early_stop (boolean) -- If True, stop the training

class AIModels.AIClasses.TimeSeriesDataset(datasrc, datatgt, TIN, MIN, T, K, time_features=None)[source]

Bases: Dataset

Class for time series dataset. Includes time feature for transformers

Parameters:
  • datasrc (numpy array) -- Source data

  • datatgt (numpy array) -- Target data

  • TIN (int) -- Input time steps

  • MIN (int) -- Input variables size

  • T (int) -- Predictions time steps

  • K (int) -- Output variables size

  • time_features (numpy array (optional)) -- If not None contain Time Features

  • shift -- Overlap between source and target, for trasnformers overlap = 0 for LSTM overlap should be TIN-T

Variables:
  • datasrc (numpy array) -- Source data

  • datatgt (numpy array) -- Target data

  • time_features (numpy array) -- Time features

  • TIN (int) -- Input time steps

  • MIN (int) -- Input variables

  • T (int) -- Output time steps

  • K (int) -- Output variables