Skip to content

Commit

Permalink
Merge pull request #296 from Avvari1830S/main
Browse files Browse the repository at this point in the history
SyntheticDataGenerators
  • Loading branch information
udayRage authored Jan 31, 2024
2 parents 35b811b + 686e46e commit a9245c4
Show file tree
Hide file tree
Showing 8 changed files with 841 additions and 0 deletions.
108 changes: 108 additions & 0 deletions notebooks/extras/SyntheticDataGenerators/createGeoreferentialTemporal
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNI7p56TkPdMTcnUmTx0yHX",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Avvari1830S/PAMI/blob/main/notebooks/extras/SyntheticDataGenerators/createGeoreferentialTemporal\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"source": [
"import random as _rd\n",
"import sys as _sys\n",
"\n",
"\n",
"class createGeoreferentialTemporalDatabase:\n",
" \"\"\"\n",
" This class create synthetic geo-referential temporal database.\n",
"\n",
" Attribute:\n",
" ----------\n",
" totalTransactions : int\n",
" No of transactions\n",
" noOfItems : int or float\n",
" No of items\n",
" avgTransactionLength : str\n",
" The length of average transaction\n",
" outputFile: str\n",
" Name of the output file.\n",
"\n",
" Methods:\n",
" --------\n",
" createGeoreferentialTemporalDatabase(outputFile)\n",
" Create geo-referential temporal database and store into outputFile\n",
"\n",
" Credits:\n",
" ---------\n",
" The complete program was written by P.Likhitha under the supervision of Professor Rage Uday Kiran.\n",
"\n",
" \"\"\"\n",
"\n",
" def __init__(self, transactions: int, items: int, avgTransaction: int) -> None:\n",
" self._totalTransactions = transactions\n",
" self._noOfItems = items\n",
" self._avgTransactionLength = avgTransaction\n",
"\n",
" def createGeoreferentialTemporalDatabase(self, outputFile: str) -> None:\n",
" \"\"\"\n",
" create transactional database and return outputFileName\n",
" :param outputFile: file name or path to store database\n",
" :type outputFile: str\n",
" :return: outputFile name\n",
" \"\"\"\n",
" writer = open(outputFile, 'w+')\n",
" items = []\n",
" count = 1\n",
" for i in range(self._noOfItems):\n",
" lat = _rd.randint(1, self._noOfItems)\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" if lat == lon:\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" stt = '(' + str(lat) + ' ' + str(lon) + ')'\n",
" items.append(stt)\n",
" for i in range(self._totalTransactions):\n",
" length = _rd.randint(1, self._avgTransactionLength + 20)\n",
" st = str(count)\n",
" for i in range(length):\n",
" rd = _rd.randint(0, len(items) - 1)\n",
" item = items[rd]\n",
" st = st + str(item) + '\\t'\n",
" writer.write(\"%s \\n\" % st)\n",
" count += 1\n",
"\n",
"if __name__ == \"__main__\":\n",
" _ap = str()\n",
" _ap = createSyntheticGeoreferentialTemporal(100000, 870, 10)\n",
" _ap.createGeoreferentialTemporalDatabase(\"T10_geo_temp.txt\")\n",
"else:\n",
" print(\"Error! The number of input parameters do not match the total number of parameters provided\")"
],
"metadata": {
"id": "Ki5GoZnNoGAD"
},
"execution_count": null,
"outputs": []
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyM6EuNv+Gl3hUE5pVRiqaTa",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Avvari1830S/PAMI/blob/main/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialTransactions\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "JOpIZF41aqsp"
},
"outputs": [],
"source": [
"import random as _rd\n",
"import sys as _sys\n",
"\n",
"\n",
"class createSyntheticGeoreferentialTransaction:\n",
" \"\"\"\n",
" This class create synthetic geo-referential transaction database.\n",
"\n",
" Attribute:\n",
" ----------\n",
" totalTransactions : int\n",
" No of transactions\n",
" items : int\n",
" No of items\n",
" avgTransactionLength : str\n",
" The length of average transaction\n",
" outputFile: str\n",
" Name of the output file.\n",
"\n",
" Methods:\n",
" --------\n",
" createGeoreferentialTransactionDatabase(outputFile)\n",
" Create geo-referential transactional database and store into outputFile\n",
"\n",
"\n",
" Credits:\n",
" ---------\n",
" The complete program was written by P.Likhitha under the supervision of Professor Rage Uday Kiran.\n",
"\n",
" \"\"\"\n",
"\n",
" def __init__(self, transactions, items, avgTransaction):\n",
" self._totalTransactions = transactions\n",
" self._noOfItems = items\n",
" self._avgTransactionLength = avgTransaction\n",
"\n",
" def createGeoreferentialTransactionalDatabase(self, outputFile):\n",
" \"\"\"\n",
" create transactional database and return outputFileName\n",
" :param outputFile: file name or path to store database\n",
" :type outputFile: str\n",
" :return: outputFile name\n",
" \"\"\"\n",
" writer = open(outputFile, 'w+')\n",
" items = []\n",
" for i in range(self._noOfItems):\n",
" lat = _rd.randint(1, self._noOfItems)\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" if lat == lon:\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" stt = '(' + str(lat) + ' ' + str(lon) + ')'\n",
" items.append(stt)\n",
" for i in range(self._totalTransactions):\n",
" length = _rd.randint(1, self._avgTransactionLength + 20)\n",
" st = str()\n",
" for i in range(length):\n",
" rd = _rd.randint(0, len(items) - 1)\n",
" item = items[rd]\n",
" st = st + str(item) + '\\t'\n",
" writer.write(\"%s \\n\" % st)\n",
"\n",
"if __name__ == \"__main__\":\n",
" _ap = str()\n",
" _ap = createSyntheticGeoreferentialTransaction(100000, 870, 10)\n",
" _ap.createGeoreferentialTransactionalDatabase(\"T10_geo.txt\")\n",
"else:\n",
" print(\"Error! The number of input parameters do not match the total number of parameters provided\")"
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyNQFi8Ix9MUHg+zbJ3JkvBd",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/Avvari1830S/PAMI/blob/main/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialUncertainTransaction\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "47uCALmhbxOB"
},
"outputs": [],
"source": [
"import random as _rd\n",
"import sys as _sys\n",
"\n",
"\n",
"class createSyntheticGeoreferentialUncertainTransaction:\n",
" \"\"\"\n",
" This class is to create synthetic geo-referential uncertain transaction database.\n",
"\n",
" Attribute:\n",
" ----------\n",
" totalTransactions : int\n",
" No of transactions\n",
" noOfItems : int\n",
" No of items\n",
" avgTransactionLength : int\n",
" The length of average transaction\n",
" outputFile: str\n",
" Name of the output file.\n",
"\n",
" Methods:\n",
" --------\n",
" createGeoreferentialuncertainTransactionDatabase(outputFile)\n",
" Create geo-referential transactional database store into outputFile\n",
"\n",
" Credits:\n",
" ---------\n",
" The complete program was written by P.Likhitha under the supervision of Professor Rage Uday Kiran.\n",
"\n",
"\n",
"\n",
"\n",
"\n",
" \"\"\"\n",
"\n",
" def __init__(self, transactions: int, items: int, avgTransaction: int) -> None:\n",
" self._totalTransactions = transactions\n",
" self._noOfItems = items\n",
" self._avgTransactionLength = avgTransaction\n",
"\n",
" def createGeoreferentialUncertainTransactionalDatabase(self, outputFile: str) -> None:\n",
" \"\"\"\n",
" create transactional database and return outputFileName\n",
" :param outputFile: file name or path to store database\n",
" :type outputFile: str\n",
" :return: outputFile name\n",
" \"\"\"\n",
" writer = open(outputFile, 'w+')\n",
" items = []\n",
" for i in range(self._noOfItems):\n",
" lat = _rd.randint(1, self._noOfItems)\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" if lat == lon:\n",
" lon = _rd.randint(1, self._noOfItems)\n",
" stt = '(' + str(lat) + ' ' + str(lon) + ')'\n",
" items.append(stt)\n",
" for i in range(self._totalTransactions):\n",
" length = _rd.randint(1, self._avgTransactionLength + 20)\n",
" st = str()\n",
" st1 = str()\n",
" for i in range(length):\n",
" rd = _rd.randint(0, len(items) - 1)\n",
" item = items[rd]\n",
" probability = _rd.uniform(0, 1)\n",
" st = st + str(item) + '\\t'\n",
" st1 = st1 + str(probability) + '\\t'\n",
" writer.write(\"%s\" % st)\n",
" writer.write(\":\")\n",
" writer.write(\"%s \\n\" % st1)\n",
"\n",
"if __name__ == \"__main__\":\n",
" _ap = str()\n",
" _ap = createSyntheticGeoreferentialUncertainTransaction(100000, 870, 10)\n",
" _ap.createGeoreferentialUncertainTransactionalDatabase(\"T10_geo_un.txt\")\n",
"else:\n",
" print(\"Error! The number of input parameters do not match the total number of parameters provided\")"
]
}
]
}
Loading

0 comments on commit a9245c4

Please sign in to comment.