diff --git a/notebooks/extras/SyntheticDataGenerators/createGeoreferentialTemporal b/notebooks/extras/SyntheticDataGenerators/createGeoreferentialTemporal new file mode 100644 index 00000000..13709c3d --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createGeoreferentialTemporal @@ -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": [ + "\"Open" + ] + }, + { + "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": [] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialTransactions b/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialTransactions new file mode 100644 index 00000000..02cbd33f --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialTransactions @@ -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": [ + "\"Open" + ] + }, + { + "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\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialUncertainTransaction b/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialUncertainTransaction new file mode 100644 index 00000000..e3ff178c --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticGeoreferentialUncertainTransaction @@ -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": [ + "\"Open" + ] + }, + { + "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\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticTemporal b/notebooks/extras/SyntheticDataGenerators/createSyntheticTemporal new file mode 100644 index 00000000..84694d0b --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticTemporal @@ -0,0 +1,98 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyMuKfiZg/rnE3ytTXwxkCoO", + "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": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "TUSJp6cKb0kl" + }, + "outputs": [], + "source": [ + "import random as _rd\n", + "import sys as _sys\n", + "class createSyntheticTemporal:\n", + " \"\"\"\n", + " This class create synthetic temporal database.\n", + "\n", + " Attribute:\n", + " ----------\n", + " totalTransactions : int\n", + " No of transactions\n", + " noOfItems : 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", + " createTemporallDatabase(outputFile)\n", + " Create temporal database from DataFrame 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", + "\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 createTemporalDatabase(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", + " count = 1\n", + " writer = open(outputFile, 'w+')\n", + " for i in range(self._totalTransactions):\n", + " length = _rd.randint(1, self._avgTransactionLength + 20)\n", + " st = str(count) + '\\t'\n", + " for i in range(length):\n", + " item = _rd.randint(1, self._noOfItems)\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 = createSyntheticTemporal(100000, 870, 10)\n", + " _ap.createTemporalDatabase(\"temporal_T10.txt\")\n", + "else:\n", + " print(\"Error! The number of input parameters do not match the total number of parameters provided\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticTransactions b/notebooks/extras/SyntheticDataGenerators/createSyntheticTransactions new file mode 100644 index 00000000..451208a5 --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticTransactions @@ -0,0 +1,97 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyN97Pf6jYA+yOhaxccpgPXc", + "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": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "LcnZXu2wcRk1" + }, + "outputs": [], + "source": [ + "import random as _rd\n", + "import sys as _sys\n", + "class createSyntheticTransaction:\n", + " \"\"\"\n", + " This class create synthetic 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", + " createTransactionalDatabase(outputFile)\n", + " Create transactional 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", + " \"\"\"\n", + "\n", + " def __init__(self, totalTransactions: int, items: int, avgTransactionLength: int) -> None:\n", + " self._totalTransactions = totalTransactions\n", + " self._noOfItems = items\n", + " self._avgTransactionLength = avgTransactionLength\n", + "\n", + " def createTransactionalDatabase(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", + " for i in range(self._totalTransactions):\n", + " length = _rd.randint(1, self._avgTransactionLength + 20)\n", + " st = str()\n", + " for i in range(length):\n", + " item = _rd.randint(1, self._noOfItems)\n", + " st = st + str(item) + '\\t'\n", + " writer.write(\"%s \\n\" % st)\n", + "\n", + "if __name__ == \"__main__\":\n", + " _ap = str()\n", + " _ap = createSyntheticTransaction(100000, 870, 10)\n", + " _ap.createTransactionalDatabase(\"T10.txt\")\n", + "else:\n", + " print(\"Error! The number of input parameters do not match the total number of parameters provided\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTemporal b/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTemporal new file mode 100644 index 00000000..fff26162 --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTemporal @@ -0,0 +1,106 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyMYgc+UEGUU6P2W55nbp4ab", + "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": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "E1AT8uMycpRJ" + }, + "outputs": [], + "source": [ + "import random as _rd\n", + "import sys as _sys\n", + "\n", + "\n", + "class createSyntheticUncertainTemporal:\n", + " \"\"\"\n", + " This class create synthetic temporal database.\n", + "\n", + " Attribute:\n", + " ----------\n", + " totalTransactions : int\n", + " Total 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", + " createUncertainTemporalDatabase(outputFile)\n", + " Create temporal database from DataFrame 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", + " \"\"\"\n", + "\n", + " def __init__(self, totalTransactions: int, items: int, avgTransaction: int) -> None:\n", + " self._totalTransactions = totalTransactions\n", + " self._noOfItems = items\n", + " self._avgTransactionLength = avgTransaction\n", + "\n", + " def createUncertainTemporalDatabase(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", + " count = 1\n", + " for i in range(self._totalTransactions):\n", + " length = _rd.randint(1, self._avgTransactionLength + 20)\n", + " st = str(count) + '\\t'\n", + " st1 = str()\n", + " for i in range(length):\n", + " item = _rd.randint(1, self._noOfItems)\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(\"%s \\n\" % st1)\n", + " count += 1\n", + "\n", + "\n", + "if __name__ == \"__main__\":\n", + " _ap = str()\n", + " _ap = createSyntheticUncertainTemporal(50000, 870, 10)\n", + " _ap.createUncertainTemporalDatabase(\"T10_uncertain_temp.txt\")\n", + "else:\n", + " print(\"Error! The number of input parameters do not match the total number of parameters provided\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTransactions b/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTransactions new file mode 100644 index 00000000..91d69592 --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticUncertainTransactions @@ -0,0 +1,102 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyNDWANqCiSu7694y74TBwrO", + "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": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "Wy5dlYIgcoSl" + }, + "outputs": [], + "source": [ + "import random as _rd\n", + "import sys as _sys\n", + "\n", + "\n", + "class createSyntheticUncertainTransaction:\n", + " \"\"\"\n", + " This class create synthetic transaction database.\n", + "\n", + " Attribute:\n", + " ----------\n", + " totalTransactions : int\n", + " No of transactions\n", + " noOfItems : 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", + " Nethods:\n", + " --------\n", + " createUncertainTransactionalDatabase(outputFile)\n", + " Create uncertain transactional 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 createUncertainTransactionalDatabase(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", + " 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", + " item = _rd.randint(1, self._noOfItems)\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(\"%s \\n\" % st1)\n", + "\n", + "\n", + "if __name__ == \"__main__\":\n", + " _ap = str()\n", + " _ap = createSyntheticUncertainTransaction(100000, 870, 10)\n", + " _ap.createUncertainTransactionalDatabase(\"T10_uncertain.txt\")\n", + "else:\n", + " print(\"Error! The number of input parameters do not match the total number of parameters provided\")" + ] + } + ] +} \ No newline at end of file diff --git a/notebooks/extras/SyntheticDataGenerators/createSyntheticUtility b/notebooks/extras/SyntheticDataGenerators/createSyntheticUtility new file mode 100644 index 00000000..3371c8e5 --- /dev/null +++ b/notebooks/extras/SyntheticDataGenerators/createSyntheticUtility @@ -0,0 +1,108 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyPa9Z5IsqA99nzl8M/FT7Ap", + "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": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "RLFeRRqneKor" + }, + "outputs": [], + "source": [ + "import random as _rd\n", + "import sys as _sys\n", + "\n", + "\n", + "class createSyntheticUtility:\n", + " \"\"\"\n", + " This class create synthetic utility database.\n", + "\n", + " Attribute:\n", + " ----------\n", + " totalTransactions : int\n", + " No of transactions\n", + " noOfItems : int\n", + " No of items\n", + " maxUtilRange: int\n", + " Maximum utility range\n", + " avgTransactionLength : int\n", + " The length of average transaction\n", + " outputFile: str\n", + " Name of the output file.\n", + "\n", + " Nethods:\n", + " --------\n", + " createUtilitylDatabase(outputFile)\n", + " Create utility database from DataFrame 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, maxUtilRange: int, avgTransaction: int) -> None:\n", + " self._totalTransactions = transactions\n", + " self._noOfItems = items\n", + " self._maxUtilRange = maxUtilRange\n", + " self._avgTransactionLength = avgTransaction\n", + "\n", + " def createUtilityDatabase(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", + " for i in range(self._totalTransactions):\n", + " length = _rd.randint(1, self._avgTransactionLength + 20)\n", + " st = str()\n", + " st1 = str()\n", + " su = []\n", + " for i in range(length):\n", + " item = _rd.randint(1, self._noOfItems)\n", + " utility = _rd.randint(1, self._maxUtilRange)\n", + " st = st + str(item) + '\\t'\n", + " su.append(utility)\n", + " st1 = st1 + str(utility) + '\\t'\n", + " summation = sum([i for i in su])\n", + " st = st + \":\" + str(summation) + \":\"\n", + " writer.write(\"%s\" % st)\n", + " writer.write(\"%s \\n\" % st1)\n", + "\n", + "if __name__ == \"__main__\":\n", + " _ap = str()\n", + " _ap = createSyntheticUtility(100000, 870, 100, 10)\n", + " _ap.createUtilityDatabase(\"T10_util.txt\")\n", + "else:\n", + " print(\"Error! The number of input parameters do not match the total number of parameters provided\")" + ] + } + ] +} \ No newline at end of file