PAMI.extras.generateDatabase package

Submodules

PAMI.extras.generateDatabase.generateSpatioTemporalDatabase module

class PAMI.extras.generateDatabase.generateSpatioTemporalDatabase.generateTemporalDatabase(numOfTransactions: int, avgLenOfTransactions: int, numItems: int, outputFile: str, x1, y1, x2, y2, percentage: int = 50, sep: str = '\t', typeOfFile: str = 'Database')[source]

Bases: object

Description:

generateTemporalDatabase creates a temporal database and outputs a database or a frame depending on input

Attributes:
param numOfTransactions:

int number of transactions

param avgLenOfTransactions:

int average length of transactions

param numItems:

int number of items

param outputFile:

str output file name

param percentage:

int percentage of coinToss for TID of temporalDatabase

param sep:

str seperator for database output file

param typeOfFile:

str specify database or dataframe to get corresponding output

Methods:
getFileName():

returns filename

createTemporalFile():

creates temporal database file or dataframe

getDatabaseAsDataFrame:

returns dataframe

performCoinFlip():

Perform a coin flip with the given probability

tuning():

Tune the arrayLength to match avgLenOfTransactions

createTemporalFile():

create Temporal database or dataframe depending on input

Importing this algorithm into a python program

from PAMI.extras.generateDatabase import generateTemporalDatabase as db

numOfTransactions = 100
numItems = 15
avgTransactionLength = 6
outFileName = 'temporal_ot.txt'
sep = '     '
percent = 75
frameOrBase = "dataframe" # if you want to get dataframe as output
frameOrBase = "database" # if you want to get database/csv/file as output

temporalDB = db.generateTemporalDatabase(numOfTransactions, avgTransactionLength, numItems, outFileName, percent, sep, frameOrBase )
temporalDB.createTemporalFile()
print(temporalDB.getDatabaseAsDataFrame())
createTemporalFile() None[source]

create Temporal database or dataframe depending on input :return: None

generateArray(nums, maxItems, sumRes) list[source]

Generate a random array of length n whose values average to m

Parameters:
  • nums (int) – number of values

  • maxItems (int) – maximum value

  • sumRes (float) – Resultant sum

Returns:

random array

Return type:

list

getDatabaseAsDataFrame() DataFrame[source]

return dataframe :return: dataframe :rtype: pd.DataFrame

getFileName() str[source]

return filename :return: filename :rtype: str

getPoint(x1, y1, x2, y2)[source]
performCoinFlip(probability: float) bool[source]

Perform a coin flip with the given probability. :param probability: probability to perform coin flip :type probability: float :return: True if coin flip is performed, False otherwise :rtype: bool

tuning(array, sumRes) list[source]

Tune the array so that the sum of the values is equal to sumRes

Parameters:
  • array (list) – list of values

  • sumRes (int) – the sum of the values in the array to be tuned

Returns:

list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes

Return type:

list

PAMI.extras.generateDatabase.generateTemporalDatabase module

class PAMI.extras.generateDatabase.generateTemporalDatabase.generateTemporalDatabase(numOfTransactions: int, avgLenOfTransactions: int, numItems: int, outputFile: str, percentage: int = 50, sep: str = '\t', typeOfFile: str = 'Database')[source]

Bases: object

Description:

generateTemporalDatabase creates a temporal database and outputs a database or a frame depending on input

Attributes:
param numOfTransactions:

int number of transactions

param avgLenOfTransactions:

int average length of transactions

param numItems:

int number of items

param outputFile:

str output file name

param percentage:

int percentage of coinToss for TID of temporalDatabase

param sep:

str seperator for database output file

param typeOfFile:

str specify database or dataframe to get corresponding output

Methods:
getFileName():

returns filename

createTemporalFile():

creates temporal database file or dataframe

getDatabaseAsDataFrame:

returns dataframe

performCoinFlip():

Perform a coin flip with the given probability

tuning():

Tune the arrayLength to match avgLenOfTransactions

createTemporalFile():

create Temporal database or dataframe depending on input

Importing this algorithm into a python program

from PAMI.extras.generateDatabase import generateTemporalDatabase as db

numOfTransactions = 100
numItems = 15
avgTransactionLength = 6
outFileName = 'temporal_ot.txt'
sep = '     '
percent = 75
frameOrBase = "dataframe" # if you want to get dataframe as output
frameOrBase = "database" # if you want to get database/csv/file as output

temporalDB = db.generateTemporalDatabase(numOfTransactions, avgTransactionLength, numItems, outFileName, percent, sep, frameOrBase )
temporalDB.createTemporalFile()
print(temporalDB.getDatabaseAsDataFrame())
createTemporalFile() None[source]

create Temporal database or dataframe depending on input :return: None

generateArray(nums, maxItems, sumRes) list[source]

Generate a random array of length n whose values average to m

Parameters:
  • nums (int) – number of values

  • maxItems (int) – maximum value

  • sumRes

Returns:

random array

Return type:

list

getDatabaseAsDataFrame() DataFrame[source]

return dataframe :return: dataframe :rtype: pd.DataFrame

getFileName() str[source]

return filename :return: filename :rtype: str

performCoinFlip(probability: float) bool[source]

Perform a coin flip with the given probability. :param probability: probability to perform coin flip :type probability: float :return: True if coin flip is performed, False otherwise :rtype: bool

tuning(array, sumRes) list[source]

Tune the array so that the sum of the values is equal to sumRes

Parameters:
  • array (list) – list of values

  • sumRes (int) – the sum of the values in the array to be tuned

Returns:

list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes

Return type:

list

PAMI.extras.generateDatabase.generateTransactionalDatabase module

class PAMI.extras.generateDatabase.generateTransactionalDatabase.generateTransactionalDatabase(numLines, avgItemsPerLine, numItems)[source]

Bases: object

:Description Generate a transactional database with the given number of lines, average number of items per line, and total number of items

Attributes:

numLines: int
  • number of lines

avgItemsPerLine: int
  • average number of items per line

numItems: int
  • total number of items

Methods:
create:

Generate the transactional database

save:

Save the transactional database to a file

getTransactions:

Get the transactional database

create() None[source]

Generate the transactional database :return: None

generateArray(nums, avg, maxItems) list[source]

Generate a random array of length n whose values average to m

Parameters:
  • nums (list) – number of values

  • avg (float) – average value

  • maxItems (int) – maximum value

Returns:

random array

Return type:

list

getTransactions() DataFrame[source]

Get the transactional database

Returns:

the transactional database

Return type:

pd.DataFrame

save(sep, filename) None[source]

Save the transactional database to a file

Parameters:
  • sep (str) – separator

  • filename (str) – name of the file

Returns:

None

tuning(array, sumRes) list[source]

Tune the array so that the sum of the values is equal to sumRes

Parameters:
  • array (list) – list of values

  • sumRes (int) – the sum of the values in the array to be tuned

Returns:

list of values with the tuned values and the sum of the values in the array to be tuned and sumRes is equal to sumRes

Return type:

list

Module contents