MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
MyCaffe.db.temporal.MyCaffeTemporalDatabase Class Reference

[Temporal Database] The MyCaffeTemporalDatabase provides an enhanced in-memory temporal database used for quick temporal data retrieval. More...

Inheritance diagram for MyCaffe.db.temporal.MyCaffeTemporalDatabase:
System.ComponentModel.Component MyCaffe.basecode.IXTemporalDatabaseBase MyCaffe.basecode.IXDatabaseBase

Public Member Functions

 MyCaffeTemporalDatabase (Log log, PropertySet prop)
 The constructor. More...
 
 MyCaffeTemporalDatabase (IContainer container)
 The constructor. More...
 
void CleanUp (int nDsId=0, bool bForce=false)
 Cleanup all resources used by the dataset specified (or all when no dataset is specified). More...
 
void Reset ()
 Reset the database indexes. More...
 
int GetTotalSize (int nDsId, Phase phase, int nHistoricalSteps, int nFutureSteps)
 Returns the total number of blocks in the database where one block is a set of (historical and future steps). More...
 
DatasetDescriptor GetDatasetById (int nDsId)
 Return the dataset descriptor of the dataset with the specified ID. More...
 
DatasetDescriptor GetDatasetByName (string strDs)
 Return the dataset descriptor of the dataset with the specified dataset name. More...
 
int GetDatasetID (string strDs)
 Return the dataset ID of the dataset with the specified dataset name. More...
 
double GetDatasetLoadedPercentById (int nDatasetID, out double dfTraining, out double dfTesting)
 Return the load percentage for dataset ID. More...
 
double GetDatasetLoadedPercentByName (string strDataset, out double dfTraining, out double dfTesting)
 Return the load percentage for a dataset. More...
 
string GetDatasetName (int nDsId)
 Returns the dataset name given its ID. More...
 
Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHODGetSelectionMethod ()
 Returns the item and value selection method used. More...
 
SourceDescriptor GetSourceById (int nSrcId)
 Get the source given its ID. More...
 
SourceDescriptor GetSourceByName (string strSrc)
 Get the source given its name. More...
 
int GetSourceID (string strSrc)
 Get the source ID given its name. More...
 
string GetSourceName (int nSrcId)
 Get the source name given its ID. More...
 
bool ReloadDataset (int nDsId)
 Reload the dataset with the specified dataset ID. More...
 
bool UnloadDatasetById (int nDsId)
 Unload the dataset specified by the dataset ID. More...
 
bool UnloadDatasetByName (string strDataset)
 Unload the dataset specified by the dataset name. More...
 
DB_VERSION GetVersion ()
 Returns the version of the database (e.g., TEMPORAL). More...
 
void SetInitializationProperties (PropertySet prop)
 Set the initialization properties to use when initializing a dataset. More...
 
bool InitializeWithDsId1 (SettingsCaffe s, int nDataSetID, string strEvtCancel=null, int nPadW=0, int nPadH=0, PropertySet prop=null)
 Initialize the database with the specified dataset ID. More...
 
bool InitializeWithDs1 (SettingsCaffe s, DatasetDescriptor ds1, string strEvtCancel=null, PropertySet prop=null)
 Initialize the database with the specified dataset descriptor. More...
 
bool InitializeWithDsName1 (SettingsCaffe s, string strDs, string strEvtCancel=null, PropertySet prop=null)
 Initialize the database with the specified dataset name. More...
 
bool LoadDatasetByID1 (int nDsId, string strEvtCancel=null)
 Load the dataset specified by the dataset ID. More...
 
bool LoadDatasetByName1 (string strDs, string strEvtCancel=null)
 Load the dataset specified by the dataset name. More...
 
SimpleTemporalDatumCollection QueryTemporalItem (int nQueryIdx, int nSrcId, ref int? nItemIdx, ref int? nValueIdx, DB_LABEL_SELECTION_METHOD? itemSelectionOverride=null, DB_ITEM_SELECTION_METHOD? valueSelectionOverride=null, bool bEnableDebug=false, string strDebugPath=null)
 Returns a block of static, observed and known data from the database where one block is a set of (historical and future steps). More...
 
void SetConnection (ConnectInfo ci)
 Set the database connection to use. More...
 
void SetSelectionMethod (DB_LABEL_SELECTION_METHOD? item, DB_ITEM_SELECTION_METHOD? value)
 Sets the label and image selection methods. More...
 
- Public Member Functions inherited from System.ComponentModel.Component
 Component ()
 

Static Public Member Functions

static void CreateDatabaseTables (ConnectInfo ci, bool bTemporalOnly)
 Create the database tables used by the MyCaffeTemporalDatabase. More...
 
static Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHODGetSelectionMethod (SettingsCaffe s)
 Returns the item/value selection methods based on the SettingsCaffe settings. More...
 
static Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHODGetSelectionMethod (ProjectEx p)
 Returns the item/value selection methods based on the ProjectEx settings. More...
 

Detailed Description

[Temporal Database] The MyCaffeTemporalDatabase provides an enhanced in-memory temporal database used for quick temporal data retrieval.

The MyCaffeTemporalDatbase manages a set of data sets, where each data sets comprise a pair of data sources: one source for training and another source for testing. Each data source contains a set of temporal data streams.
This organization allows for quick temporal data selection and is used with temporal models such as the Temporal Fusion Transformer (TFT).

Definition at line 29 of file MyCaffeTemporalDatabase.cs.

Constructor & Destructor Documentation

◆ MyCaffeTemporalDatabase() [1/2]

MyCaffe.db.temporal.MyCaffeTemporalDatabase.MyCaffeTemporalDatabase ( Log  log,
PropertySet  prop 
)

The constructor.

Parameters
logThe Log for output.
propSpecifies the initialization properties.

Definition at line 53 of file MyCaffeTemporalDatabase.cs.

◆ MyCaffeTemporalDatabase() [2/2]

MyCaffe.db.temporal.MyCaffeTemporalDatabase.MyCaffeTemporalDatabase ( IContainer  container)

The constructor.

Parameters
containerSpecifies the container for the component.

Definition at line 64 of file MyCaffeTemporalDatabase.cs.

Member Function Documentation

◆ CleanUp()

void MyCaffe.db.temporal.MyCaffeTemporalDatabase.CleanUp ( int  nDsId = 0,
bool  bForce = false 
)

Cleanup all resources used by the dataset specified (or all when no dataset is specified).

Parameters
nDsIdSpecifies the dataset to cleanup, or 0 for all datasets.
bForceNot used.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 76 of file MyCaffeTemporalDatabase.cs.

◆ CreateDatabaseTables()

static void MyCaffe.db.temporal.MyCaffeTemporalDatabase.CreateDatabaseTables ( ConnectInfo  ci,
bool  bTemporalOnly 
)
static

Create the database tables used by the MyCaffeTemporalDatabase.

Parameters
ciSpecifies the connection information for the database (recommended value: db = 'DNN', server = '.')
bTemporalOnlySpecifies to only update the temporal tables.

Definition at line 92 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetById()

DatasetDescriptor MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetById ( int  nDsId)

Return the dataset descriptor of the dataset with the specified ID.

Parameters
nDsIdSpecifies the ID of the dataset to find.
Returns
The DatasetDescriptor is returned when found, or null.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 164 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetByName()

DatasetDescriptor MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetByName ( string  strDs)

Return the dataset descriptor of the dataset with the specified dataset name.

Parameters
strDsSpecifies the name of the dataset to find.
Returns
The DatasetDescriptor is returned when found, or null.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 178 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetID()

int MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetID ( string  strDs)

Return the dataset ID of the dataset with the specified dataset name.

Parameters
strDsSpecifies the dataset name.
Returns
The dataset ID is returned when found, or 0.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 195 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetLoadedPercentById()

double MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetLoadedPercentById ( int  nDatasetID,
out double  dfTraining,
out double  dfTesting 
)

Return the load percentage for dataset ID.

Parameters
nDatasetIDSpecifies the dataset ID.
dfTrainingSpecifies the training percent loaded.
dfTestingSpecifies the testing percent loaded.
Returns
Returns the total load percent.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 207 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetLoadedPercentByName()

double MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetLoadedPercentByName ( string  strDataset,
out double  dfTraining,
out double  dfTesting 
)

Return the load percentage for a dataset.

Parameters
strDatasetSpecifies the dataset name.
dfTrainingSpecifies the training percent loaded.
dfTestingSpecifies the testing percent loaded.
Returns
Returns the total load percent.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 227 of file MyCaffeTemporalDatabase.cs.

◆ GetDatasetName()

string MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetDatasetName ( int  nDsId)

Returns the dataset name given its ID.

Parameters
nDsIdSpecifies the dataset ID.
Returns
The dataset name is returned, or null if not found.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 237 of file MyCaffeTemporalDatabase.cs.

◆ GetSelectionMethod() [1/3]

Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHOD > MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSelectionMethod ( )

Returns the item and value selection method used.

Returns
A KeyValue containing the Item and Value selection method.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 288 of file MyCaffeTemporalDatabase.cs.

◆ GetSelectionMethod() [2/3]

static Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHOD > MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSelectionMethod ( ProjectEx  p)
static

Returns the item/value selection methods based on the ProjectEx settings.

Parameters
pSpecifies the project.
Returns
The item/value selection method is returned.

Definition at line 270 of file MyCaffeTemporalDatabase.cs.

◆ GetSelectionMethod() [3/3]

static Tuple< DB_LABEL_SELECTION_METHOD, DB_ITEM_SELECTION_METHOD > MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSelectionMethod ( SettingsCaffe  s)
static

Returns the item/value selection methods based on the SettingsCaffe settings.

Parameters
sSpecifies the caffe settings.
Returns
The item/value selection method is returned.

Definition at line 251 of file MyCaffeTemporalDatabase.cs.

◆ GetSourceById()

SourceDescriptor MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSourceById ( int  nSrcId)

Get the source given its ID.

Parameters
nSrcIdSpecifies the Source ID.
Returns
Returns the source descriptor or null if not loaded.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 298 of file MyCaffeTemporalDatabase.cs.

◆ GetSourceByName()

SourceDescriptor MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSourceByName ( string  strSrc)

Get the source given its name.

Parameters
strSrcSpecifies the Source Name.
Returns
Returns the source descriptor or null if not loaded.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 308 of file MyCaffeTemporalDatabase.cs.

◆ GetSourceID()

int MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSourceID ( string  strSrc)

Get the source ID given its name.

Parameters
strSrcSpecifies the Source Name.
Returns
Returns the source ID or 0 if not loaded.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 318 of file MyCaffeTemporalDatabase.cs.

◆ GetSourceName()

string MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetSourceName ( int  nSrcId)

Get the source name given its ID.

Parameters
nSrcIdSpecifies the Source Id.
Returns
Returns the source name or null if not loaded.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 332 of file MyCaffeTemporalDatabase.cs.

◆ GetTotalSize()

int MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetTotalSize ( int  nDsId,
Phase  phase,
int  nHistoricalSteps,
int  nFutureSteps 
)

Returns the total number of blocks in the database where one block is a set of (historical and future steps).

Parameters
nDsIdSpecifies the dataset ID.
phaseSpecifies the phase who's data size is to be returned.
nHistoricalStepsSpecifies the number of historical steps.
nFutureStepsSpecifies the number of future steps.
Returns
The total number of blocks is returned.

Implements MyCaffe.basecode.IXTemporalDatabaseBase.

Definition at line 134 of file MyCaffeTemporalDatabase.cs.

◆ GetVersion()

DB_VERSION MyCaffe.db.temporal.MyCaffeTemporalDatabase.GetVersion ( )

Returns the version of the database (e.g., TEMPORAL).

Returns
The database version is returned.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 390 of file MyCaffeTemporalDatabase.cs.

◆ InitializeWithDs1()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.InitializeWithDs1 ( SettingsCaffe  s,
DatasetDescriptor  ds1,
string  strEvtCancel = null,
PropertySet  prop = null 
)

Initialize the database with the specified dataset descriptor.

Parameters
sSpecifies the initial settings that specify the load method and load limit.
ds1Specifies the dataset descriptor to load.
strEvtCancelOptionally, specifies the name of a global cancel event (default = null).
propOptionally specifies the properties for the initialization (default = null).
Returns
If the datset is loaded, true is returned, otherwise false.

You must call SetInitializationProperties before calling the InitializeWithDsId method.

Exceptions
ExceptionAn exception is thrown on error, e.g, when missing initialization properties.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 472 of file MyCaffeTemporalDatabase.cs.

◆ InitializeWithDsId1()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.InitializeWithDsId1 ( SettingsCaffe  s,
int  nDataSetID,
string  strEvtCancel = null,
int  nPadW = 0,
int  nPadH = 0,
PropertySet  prop = null 
)

Initialize the database with the specified dataset ID.

Parameters
sSpecifies the initial settings that specify the load method and load limit.
nDataSetIDSpecifies the dataset ID to load.
strEvtCancelOptionally, specifies the name of a global cancel event (default = null).
nPadWNot Used
nPadHNot Used
propOptionally specifies the properties for the initialization (default = null).
Returns
If the datset is loaded, true is returned, otherwise false.

You must call SetInitializationProperties before calling the InitializeWithDsId method.

Exceptions
ExceptionAn exception is thrown on error, e.g, when missing initialization properties.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 425 of file MyCaffeTemporalDatabase.cs.

◆ InitializeWithDsName1()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.InitializeWithDsName1 ( SettingsCaffe  s,
string  strDs,
string  strEvtCancel = null,
PropertySet  prop = null 
)

Initialize the database with the specified dataset name.

Parameters
sSpecifies the initial settings that specify the load method and load limit.
strDsSpecifies the name of the dataset to load.
strEvtCancelOptionally, specifies the name of a global cancel event (default = null).
propOptionally specifies the properties for the initialization (default = null).
Returns
If the datset is loaded, true is returned, otherwise false.

You must call SetInitializationProperties before calling the InitializeWithDsId method.

Exceptions
ExceptionAn exception is thrown on error, e.g, when missing initialization properties.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 489 of file MyCaffeTemporalDatabase.cs.

◆ LoadDatasetByID1()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.LoadDatasetByID1 ( int  nDsId,
string  strEvtCancel = null 
)

Load the dataset specified by the dataset ID.

Parameters
nDsIdSpecifies the datset ID of the dataset to load.
strEvtCancelOptionally, specifies the name of the global cancel event.
Returns
When loaded, true is returned, otherwise false.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 509 of file MyCaffeTemporalDatabase.cs.

◆ LoadDatasetByName1()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.LoadDatasetByName1 ( string  strDs,
string  strEvtCancel = null 
)

Load the dataset specified by the dataset name.

Parameters
strDsSpecifies the name of the dataset to load.
strEvtCancelOptionally, specifies the name of the global cancel event.
Returns
When loaded, true is returned, otherwise false.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 523 of file MyCaffeTemporalDatabase.cs.

◆ QueryTemporalItem()

SimpleTemporalDatumCollection MyCaffe.db.temporal.MyCaffeTemporalDatabase.QueryTemporalItem ( int  nQueryIdx,
int  nSrcId,
ref int?  nItemIdx,
ref int?  nValueIdx,
DB_LABEL_SELECTION_METHOD itemSelectionOverride = null,
DB_ITEM_SELECTION_METHOD valueSelectionOverride = null,
bool  bEnableDebug = false,
string  strDebugPath = null 
)

Returns a block of static, observed and known data from the database where one block is a set of (historical and future steps).

Parameters
nQueryIdxSpecifies the index of the query within a batch.
nSrcIdSpecifies the source ID of the data source.
nItemIdxSpecifies the item index override when not null, returns the item index used.
nValueIdxSpecifies the value index override when not null, returns the index used with in the item.
itemSelectionOverrideOptionally, specifies the item selection method used to select the item (e.g., customer, station, stock symbol)
valueSelectionOverrideOptionally, specifies the value selection method used to select the index within the temporal data of the selected item.
bEnableDebugOptionally, specifies to enable debug output (default = false).
strDebugPathOptionally, specifies the debug path where debug images are placed when 'EnableDebug' = true.
Returns
A tuple containing the static, observed and known data is returned.

Implements MyCaffe.basecode.IXTemporalDatabaseBase.

Definition at line 560 of file MyCaffeTemporalDatabase.cs.

◆ ReloadDataset()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.ReloadDataset ( int  nDsId)

Reload the dataset with the specified dataset ID.

Parameters
nDsIdSpecifies the dataset ID.
Returns
If reloaded successfully, returns true.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 346 of file MyCaffeTemporalDatabase.cs.

◆ Reset()

void MyCaffe.db.temporal.MyCaffeTemporalDatabase.Reset ( )

Reset the database indexes.

This method is only used when using sequential selection.

Implements MyCaffe.basecode.IXTemporalDatabaseBase.

Definition at line 118 of file MyCaffeTemporalDatabase.cs.

◆ SetConnection()

void MyCaffe.db.temporal.MyCaffeTemporalDatabase.SetConnection ( ConnectInfo  ci)

Set the database connection to use.

Parameters
ciSpecifies the dataase connection information to use.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 574 of file MyCaffeTemporalDatabase.cs.

◆ SetInitializationProperties()

void MyCaffe.db.temporal.MyCaffeTemporalDatabase.SetInitializationProperties ( PropertySet  prop)

Set the initialization properties to use when initializing a dataset.

Parameters
propSpecifies the initialization properties (see remarks).

The initialization properties for the dataset must include the following properties: NormalizeData (bool) - whether or not to use the normalized data or raw data. HistoricalSteps (int) - value > 0 specifiying the number of historical steps to use. FutureSteps (int) - value > 0 specifiying the number of future steps to use. Chunks (int) - Optional, value > 0 specifying the number of chunks to use (default = 1024).

Implements MyCaffe.basecode.IXTemporalDatabaseBase.

Definition at line 406 of file MyCaffeTemporalDatabase.cs.

◆ SetSelectionMethod()

void MyCaffe.db.temporal.MyCaffeTemporalDatabase.SetSelectionMethod ( DB_LABEL_SELECTION_METHOD item,
DB_ITEM_SELECTION_METHOD value 
)

Sets the label and image selection methods.

Parameters
itemSpecifies the item selection method or null to ignore.
valueSpecifies the value selection method or null to ignore.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 584 of file MyCaffeTemporalDatabase.cs.

◆ UnloadDatasetById()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.UnloadDatasetById ( int  nDsId)

Unload the dataset specified by the dataset ID.

Parameters
nDsIdSpecifies the dataset ID.
Returns
Returns true if unloaded successfully.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 357 of file MyCaffeTemporalDatabase.cs.

◆ UnloadDatasetByName()

bool MyCaffe.db.temporal.MyCaffeTemporalDatabase.UnloadDatasetByName ( string  strDataset)

Unload the dataset specified by the dataset name.

Parameters
strDatasetSpecifies the dataset name.
Returns
Returns true if unloaded successfully.

Implements MyCaffe.basecode.IXDatabaseBase.

Definition at line 381 of file MyCaffeTemporalDatabase.cs.


The documentation for this class was generated from the following file: