{ "info": { "author": "Nikki Marinsek", "author_email": "nikki.marinsek@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Science/Research", "License :: Free for non-commercial use", "Programming Language :: Python", "Topic :: Scientific/Engineering :: Information Analysis", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\n===========\nBURST DETECTION\n===========\n\nThis package implements Kleinberg\u2019s burst detection algorithm for batched data, as described in the paper \u201cBursty and Hierarchical Structure in Streams\u201d (2002). \n\nBurst detection identifies time periods in which a target event is uncharacteristically frequent, or \"bursty.\" You can use burst detection to detect bursts in a continuous stream of events (such as receiving emails) or in discrete batches of events (such as poster titles submissions to an annual conference). This package identifies bursts in discrete batched data. Scripts have already been written to identify bursts in continuous data (see: \"pybursts\" in Python or \"bursts\" in R). \n\n\nINSTALLATION\n=========\n\nDownload and install the package with pip::\n\n pip install burst_detection\n\n\nUSAGE\n=========\n\nYou\u2019ll want to read Kleinberg\u2019s paper, \u201cBursty and Hierarchical Structure in Streams,\u201d to gain solid understandings of the theory behind burst detection and how to use the following functions appropriately. \n\nburst_detection:\n~~~~~~~~~~~~~~~~\nThis function returns the optimal state sequence, q, of a two-state automaton for a sequence of observed target probabilities. The optimal state sequence q consists of an array of 0s and 1s (with length n), where 0 signifies that the system is in a baseline state and 1 signifies that the system is in a bursty state at time t. Burst detection is sensitive to noise, so you have the option of smoothing the time course of the target probabilities to reduce the effects of noise.\n\nINPUTS:\n - r: number of target events in each time period (nx1)\n - d: number of events in each time period (nx1)\n - n: number of timepoints\n - s: multiplicative distance between states\n - gamma: difficulty associated with moving up a state\n - smooth_win: width of smoothing window to temporally smooth target probabilities (use odd numbers; set smooth_win=1 to skip smoothing)\n\nOUTPUTS:\n - q: optimal state sequence (nx1)\n - d: number of events in each time period (nx1)\n - r: number of target events in each time period (nx1)\n - p: probabilities associated with each state (kx1)\n\nUSAGE:\n::\n q, d, r, p = burst_detection(r, d, n, s=2, gamma=1, smooth_win=3)\n\nenumerate_bursts:\n~~~~~~~~~~~~~~~~~\nThis function creates a list of all the bursts in an optimal state sequence q. \n\nINPUT: \n - q: optimal state sequence (nx1)\n\nOUTPUT:\n - bursts: a pandas dataframe containing the time points that each burst began and ended\n\nUSAGE:\n::\n bursts = enumerate_bursts(q)\n\nburst_weights:\n~~~~~~~~~~~~~~\nThis function computes the weight associated with each burst. \n\nINPUTS:\n - bursts: a pandas dataframe containing the time points that each burst began and ended\n - r: number of target events in each time period (nx1)\n - d: number of events in each time period (nx1)\n - p: expected proportion for each state (kx1)\n\nOUTPUT:\n - bursts: a pandas dataframe containing the weights of each burst, in order\n\nUSAGE:\n::\n weighted_bursts = burst_weights(bursts, r, d, p)\n\n\nEXAMPLE\n=========\n::\n\n import burst_detection as bd\n import numpy as np\n\n #number of target events at each time point\n r = np.array([0, 2, 1, 6, 7, 2, 8, 7, 2, 1], dtype=float)\n #total number of events at each time point\n d = np.array([9, 11, 12, 10, 10, 8, 12, 10, 13, 11], dtype=float)\n #number of time points\n n = len(r)\n\n #find the optimal state sequence (q)\n q, d, r, p = bd.burst_detection(r,d,n,s=2,gamma=1,smooth_win=1)\n\n #enumerate bursts based on the optimal state sequence\n bursts = bd.enumerate_bursts(q, 'burstLabel')\n\n #find weight of bursts\n weighted_bursts = bd.burst_weights(bursts,r,d,p)\n\n print 'observed probabilities: '\n print str(r/d)\n\n print 'optimal state sequence: '\n print str(q.T)\n\n print 'baseline probability: ' + str(p[0])\n\n print 'bursty probability: ' + str(p[1])\n\n print 'weighted bursts:'\n print weighted_bursts\n\nOUTPUT:\n::\n observed probabilities: \n [ 0.00 0.18 0.08 0.60 0.70 0.25 0.67 0.70 0.15 0.09]\n\n optimal state sequence: \n [[ 0. 0. 0. 0. 1. 0. 1. 1. 0. 0.]]\n\n baseline probability: 0.339\n\n bursty probability: 0.679\n \n weighted bursts:\n +---+------------+-------+------+----------+\n | | label | begin | end | weight |\n +---+------------+-------+------+----------+\n | 1 | burstLabel | 6 | 8 | 5.34226 |\n +---+------------+-------+------+----------+\n | 0 | burstLabel | 4 | 5 | 2.68563 |\n +---+------------+-------+------+----------+\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/nmarinsek/burst_detection", "keywords": "bursts burst bursty time series fads trends kleinberg streams timecourse", "license": "", "maintainer": "", "maintainer_email": "", "name": "burst_detection", "package_url": "https://pypi.org/project/burst_detection/", "platform": "", "project_url": "https://pypi.org/project/burst_detection/", "project_urls": { "Homepage": "http://github.com/nmarinsek/burst_detection" }, "release_url": "https://pypi.org/project/burst_detection/0.1.3/", "requires_dist": null, "requires_python": "", "summary": "Detect bursts in batched data using Kleinbergs (2002) algorithm.", "version": "0.1.3" }, "last_serial": 3463717, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "7a038a40f4c2119083cea1381d07fe08", "sha256": "785b95855fc41d4da39978dde096ffefe90febe4afcd289875b461e04dec0032" }, "downloads": -1, "filename": "burst_detection-0.1.tar.gz", "has_sig": false, "md5_digest": "7a038a40f4c2119083cea1381d07fe08", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2495, "upload_time": "2016-11-28T04:51:49", "url": "https://files.pythonhosted.org/packages/16/7f/af7352251f8c539aebe0413f2152ae7c3742888d84a23bc12834877a40c3/burst_detection-0.1.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "14c67261e5428dbe89d3ae960b7d6be2", "sha256": "27fab141feabfb6b6eb49d1c296718ac0ef3a619d44b5ea5b76620ce593f9252" }, "downloads": -1, "filename": "burst_detection-0.1.1.tar.gz", "has_sig": false, "md5_digest": "14c67261e5428dbe89d3ae960b7d6be2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4694, "upload_time": "2016-12-08T04:30:10", "url": "https://files.pythonhosted.org/packages/81/33/8b79ae985de1fb071b9273d4ad7f4815978409a5d90544b7ef4218545b1c/burst_detection-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "d7cc127a769147bbba3081d776491fa4", "sha256": "bcea0ed6b54787d1105bcb2b066a046527efddca0f7d58b9201010829d38928b" }, "downloads": -1, "filename": "burst_detection-0.1.2.tar.gz", "has_sig": false, "md5_digest": "d7cc127a769147bbba3081d776491fa4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4814, "upload_time": "2017-12-15T04:32:41", "url": "https://files.pythonhosted.org/packages/2f/e3/9c242322037ddd113359c3cfa34075d41a004fb09eb0c7652ccbce567443/burst_detection-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "3a7ef21fb55be098779963c316815418", "sha256": "08a0b8dc3ff1dadee1548dc2525196fad3ce5133c7d28a3151a9c9b3f17b9af9" }, "downloads": -1, "filename": "burst_detection-0.1.3.tar.gz", "has_sig": false, "md5_digest": "3a7ef21fb55be098779963c316815418", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4804, "upload_time": "2018-01-05T05:37:42", "url": "https://files.pythonhosted.org/packages/d8/f5/9cb197d3fcce8b72bf8661047b21a30caf91809596312c2c089f70ce81a0/burst_detection-0.1.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3a7ef21fb55be098779963c316815418", "sha256": "08a0b8dc3ff1dadee1548dc2525196fad3ce5133c7d28a3151a9c9b3f17b9af9" }, "downloads": -1, "filename": "burst_detection-0.1.3.tar.gz", "has_sig": false, "md5_digest": "3a7ef21fb55be098779963c316815418", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4804, "upload_time": "2018-01-05T05:37:42", "url": "https://files.pythonhosted.org/packages/d8/f5/9cb197d3fcce8b72bf8661047b21a30caf91809596312c2c089f70ce81a0/burst_detection-0.1.3.tar.gz" } ] }