Introduction

I obtained this Fort Lauderdale Police Department data from the City of Fort Lauderdale via the Fort Lauderdale Civic Hackathon.

See my blog post about my participation in the hackathon.

This is my first Pelican blog post using a Jupyter notebook made possible by this plug-in.

Use this notebook.

This notebook and Docker, and Docker Compose files are available in this GitHub repo.

Download most current version of this notebook from my blog repository.

Import some tools from Python standard library.


In [53]:
import logging
import timeit

Use PyMongo Python distribution containing tools for working with MongoDB.


In [54]:
from pymongo import MongoClient
from bson.son import SON

Import some Jupyter notebook related objects to display HTML in the notebook.


In [55]:
from IPython.core.display import HTML, display
from ipy_table import render, make_table, set_column_style

Use Python logging module to log info in this notebook.


In [56]:
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
# seems IPthon adds a stream handler. Might as well use it.
stream_handler = logger.handlers.pop(0) \
    if logger.handlers else logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
logger.addHandler(stream_handler)
assert logger.handlers
logger.debug("The logger is working.")


The logger is working.

Define text formatting constants.


In [57]:
(
    CR,
    SPACE,
    COLON_SPACE,
    COMMA,
) = (
    '\n',
    ' ',
    ': ',
    ',',
)

Instantiate a MongoDB client.


In [58]:
client = MongoClient()

Define a database of interest.

'app' is the name of the MongoDB database set in this line of the Dockerfile and this line of the Dockerfile when the database was seeded.


In [59]:
db = client.app

Define contants.


In [60]:
collection_names = (
    CITATIONS,
    ACCIDENTS,
) = (
    'citations',
    'accidents',
)

Define collections via Python built-in function getattr.


In [61]:
collections = citations, accidents = [
    getattr(db, database_name) 
    for database_name 
    in collection_names
]

How many records are in each collection?

I recognize this code may be hard to read for those unfamiliar with list comprehensions. It's a one-off comprehension so I am not going to take extra time to refactor it. It runs once and serves its logging purpose.


In [62]:
logger.info(
    CR.join(SPACE.join((COLON_SPACE.join((
                collection_name,
                format(collection.count(), COMMA),
            )), 'records'))
            for collection_name, collection 
            in zip(collection_names, collections))
)


citations: 92,912 records
accidents: 26,944 records

Define the field of interest that is in the citations collection.


In [63]:
CITATION_CHARGE = 'Citation Charge'

Set up the comparison.

MongoDB is still new to me so I consulted this StackOverflow post to learn how to count occurrances of a value in a set of documents.

Define variables.

Define what I am calling 'dollar_keys' for a pipeline.


In [64]:
dollar_keys = (
    'group',
    CITATION_CHARGE,
    'sum',
    'sort',
)

Add '$' in front of dollar_keys contants and define them. They will be used in a pipeline created later.


In [65]:
dollar_keys_ = (
    _GROUP,
    _CITATION_CHARGE,
    _SUM,
    _SORT,
) = [
     '${}'.format(dollar_key) for dollar_key in dollar_keys
]
logger.info(dollar_keys_)


['$group', '$Citation Charge', '$sum', '$sort']

Define some contants for the pipeline that do not have '$' prefix.


In [66]:
(
    _ID,
    COUNT,
) = (
    '_id',
    'count',
)

Define the pipeline for the MongoDb query.

Recall that SON was imported from bson.son package. See the bson docs.


In [67]:
pipeline = [
    {_GROUP: {_ID: _CITATION_CHARGE, COUNT: {_SUM: 1}}},
    {_SORT: SON([(COUNT, -1), (_ID, -1)])},
]
logger.info(pipeline)


[{'$group': {'_id': '$Citation Charge', 'count': {'$sum': 1}}}, {'$sort': SON([('count', -1), ('_id', -1)])}]

In [68]:
aggregated_data = list(
    (citation[COUNT], citation[_ID].lower()) 
    for citation 
    in citations.aggregate(pipeline)
)

Define a new pipeline without counts. Only Citation Charges are retrieved and sorted.


In [69]:
pipeline = [
    {_GROUP: {_ID: _CITATION_CHARGE, COUNT: {_SUM: 1}}},
    {_SORT: SON([(_ID, 1)])}
]

Define functions to use in timeit.

  • citations is the MongoDB collection.
  • Calling find with citations.find() returns all the records.
  • The {} is a list comprehension literal in Python that creates a set.
  • sorted is a built-in function in Python that returns a sorted list from certain iterables.

In [70]:
def test_sorted_set():
    return sorted({
            citation[CITATION_CHARGE]
            for citation in citations.find()
        })

Use MongoDb aggregate.


In [71]:
def test_aggregation():
    return list(
        citation['_id']
        for citation in citations.aggregate(pipeline)
    )

Test that the functions return the same data.


In [72]:
assert test_find() == test_aggregation(), "The sets of sorted citations differ."
# An AsssertionError is thrown if the assertion fails.
logger.info("The set of citations obtained via 2 different ways have produced equal sets.")


The set of citations obtained via 2 different ways have produced equal sets.

Define some constants.


In [73]:
SECONDS = 'seconds'
LOOPS = 10
RECORD_COUNT = '92,912'

Time MongoDB aggregate repeated 3 times with 10 loops and log it.


In [74]:
logger.info(
    CR.join([SPACE.join((
        str(trial_time),
        SECONDS,
        "for MongoDB to aggregate data on {} records.".format(RECORD_COUNT)
    ))
     for trial_time in
     timeit.repeat(
        "test_aggregation()", 
        setup="from __main__ import test_aggregation",
        number=LOOPS
    )])
)


2.6035960060107755 seconds for MongoDB to aggregate data on 92,912 records.
2.9738499480008613 seconds for MongoDB to aggregate data on 92,912 records.
3.048110834992258 seconds for MongoDB to aggregate data on 92,912 records.

Time Python built-in functions sorted and set repeated 3 times with 10 loops and log it.


In [75]:
logger.info(
    CR.join([SPACE.join((
        str(trial_time),
        SECONDS,
        "for Python to aggregate data on {} records using a sorted set.".format(RECORD_COUNT)
    ))
     for trial_time in
     timeit.repeat(
        "test_sorted_set()", 
        setup="from __main__ import test_sorted_set",
        number=LOOPS
    )])
)


21.351897979999194 seconds for Python to aggregate data on 92,912 records using a sorted set.
21.370903400005773 seconds for Python to aggregate data on 92,912 records using a sorted set.
23.723268539994024 seconds for Python to aggregate data on 92,912 records using a sorted set.

It is safe to say that MongoDB is optimized for sorting sets of large data and is approximately almost 10 times faster than Python built-in functions.

Learning to use capabilities of a database like MongoDB has its speed benefits.

In-notebook display of the citations and their counts.

Replace empty citations with "None specified." for display in an HTML table in this notebook.


In [76]:
citation_counts = [
    (
        count, 
        citation or "None specified",
    ) for count, citation in aggregated_data
]

NB: A Pelican plug-in I am using to create posts with notebooks is adding extra ';' characters likely secondary to HTML escaping during rendering.

It is still easier on the eyes than reading a list of tuples!

The following code is particular to Jupyter notebooks for displaying HTML.


In [77]:
# add headers
citation_counts_ = [('Count', CITATION_CHARGE, ), ] + citation_counts
# create table with make_table
make_table(citation_counts_)
# apply some styles to the table after it is created
set_column_style(0, width='100', bold=True, color='hsla(225, 80%, 94%, 1)')
set_column_style(1, width='100')
display(HTML(render()._repr_html_()))


CountCitation&nbspCharge
13746unlawful&nbspspeed&nbspposted&nbspmunicip/countyrd
9728failure&nbspto&nbspuse&nbspdue&nbspcare
6344operating&nbspnon-cmv&nbspnot&nbspproperly&nbspinsured&nbspproof&nbspof&nbspins&nbsprequired
4310fail&nbspwear&nbspsafety&nbspbelt/operator
3510unl/speed&nbspin&nbspschool&nbspzone
3382expired&nbsptag&nbspless&nbspthan&nbsp6&nbspmos
3324ran&nbspstop&nbspsign
3072drive&nbspwhile&nbsplicense&nbspsusp&nbspw/o&nbspknowledge
2790disobey/avoid&nbsptraffic&nbspdevice
2546fail&nbspto&nbspdisplay&nbspveh&nbspreg
2412improper&nbspchange&nbspof&nbsplane-&nbsppull&nbspin&nbspfront&nbspof&nbspveh&nbspsame&nbspdirection
2172None&nbspspecified
2096operate&nbspmotor&nbspvehicle&nbspwo&nbspvalid&nbsplicens
1666disobey/avoid&nbspred&nbsplight
1590drive&nbspwhile&nbsplicense&nbspsuspended/revoked/canceled/w/knowledge
1532oper&nbspveh&nbspunsafe/improp&nbspequip
1398improper&nbspbacking
1252fail&nbspto&nbspchange&nbspaddress&nbspon&nbspdl
1222license&nbspnot&nbspcarried/exhibit
1060ftyrow&nbspwhen&nbspturning&nbspleft
1012expired&nbspmtr&nbspveh&nbspregistration&nbspover&nbsp6&nbspmonths&nbsp1st&nbspoff
748side&nbspwind/rest&nbspsunscreen
674unlawful&nbspspeed&nbspschool&nbspzone
616fail&nbspdrive&nbspin&nbspsingle&nbsplane
578attach&nbsptag (license&nbspplate)&nbspnot&nbspassigned
576following&nbsptoo&nbspclosely
562crash-driv&nbspfail&nbsprpt&nbspcrash&nbspw&nbspinj/death/damage&nbspto&nbsplea ($500)
544learners&nbspdrivers&nbsplic&nbspviol
522careless&nbspdriving
510fail&nbspto&nbspregister&nbspmotor&nbspveh
494disobey/avoid&nbspred&nbsplight/turning
406tag&nbspunsecured/obscured/improper&nbspdisplay/defaced/none
402driving&nbspw/&nbspexp&nbsplic >&nbsp6mo
402drive&nbspwhile&nbsplic&nbspsusp&nbsp1st&nbspoff
386imp&nbspstop&nbspun/load&nbsppasg&nbsplimt&nbspacs
382driver&nbsppresent&nbspnon&nbspcurrent&nbspinsurance
374crash&nbspleave&nbspscene&nbspw/o&nbspgiving&nbspinformation (specify&nbspdamage $$)
354unlawful&nbspspeed&nbspposted&nbspstate/intersct
330fnt&nbspst&nbsppass/ovr&nbsp18/seat-belt&nbspviolation
308exceed&nbspspeed&nbsplim&nbspin&nbspwork&nbspzone
304fty/s&nbspat&nbspsidewalk-&nbspalley/bldg/priv&nbsprd/drive&nbspway&nbspto&nbspveh&nbspappr
300child&nbsprestraint&nbsprequired
284u-turn:&nbspimproper/unsafe/prohibited
264crash&nbsp-&nbspno&nbspproof&nbspinsurance&nbspall&nbspparties (24&nbsphr&nbspclock&nbsprule)
252block&nbspintersection/crosswalk
248improper&nbspright&nbspturn
242improper&nbspchange&nbspof&nbsplane-pass&nbspwhen&nbspmeeting&nbsponcoming&nbspveh
240slow&nbspspeed/impede&nbsptraffic
238drive&nbspveh&nbspunsafe/defect&nbspequip
214no&nbsptag&nbsplight
214must&nbsphave&nbsppip&nbspins&nbspcard
212improper&nbspleft&nbspturn
212florida&nbspseat&nbspbelt&nbsplaw&nbspviolation
212expired&nbspd/l&nbspless&nbspthan&nbsp6&nbspmonths
208fail&nbspuse&nbspdesignated&nbsplane
208fail&nbspturn&nbspas&nbspdirected
198expired&nbsptag/less&nbspthan&nbsp6&nbspmonths
186fail&nbspto&nbspuse&nbspdesignated&nbsplane/drive&nbspw/i&nbspsingle&nbsplane
184overtaking&nbspand&nbsppassing&nbspa&nbspbicycle (improp&nbspdistance)
182no&nbspsafety&nbspbelts-&nbspoperator/passg&nbspunder&nbsp18
176license&nbspnot&nbspcarried/exhibited
176improper&nbspuse&nbsphov&nbsplane
166ped&nbspfail&nbspto&nbspcross&nbspin&nbspx-walk
156improper&nbsppass/lane&nbspchange
154drive&nbspon&nbspsidewalk/bike&nbsppath
150ped&nbspleave&nbspplace&nbspof&nbspsafety
148failure&nbspto&nbspobey&nbsprestrictions&nbspplaced&nbspon&nbspdl
146riding&nbspbike&nbspwith&nbspno/imp&nbsplight
146drive&nbspwhile&nbsplic&nbspsusp&nbsp2nd&nbspoff
140drive&nbspwhile&nbsplic&nbspsusp&nbsphabitual&nbspoffende
140disobeyed&nbspstop/yield&nbspsign
128reckless&nbspdriving-drives&nbspany&nbspveh&nbspwillful&nbspdisregard&nbspfor&nbspsafety
124driving&nbspwrong&nbspway&nbspdown&nbspone-way
118bike&nbspregulations&nbspviolations
116tail&nbsplights&nbspnone/improper
116operate&nbspmotorcycle&nbspwo&nbsplicense
114fail&nbspchange&nbspaddress/name
110speed&nbspzone&nbspviolation
110fail&nbspto&nbspdrive&nbspin&nbspsingle&nbsplane
106head&nbsplamp&nbspviolation
102drive&nbspwhile&nbsplic&nbspsusp&nbsp3rd&nbspor&nbspsubsq&nbspoff
98expired&nbspmtr&nbspveh&nbspreg&nbspover&nbsp6&nbspmos&nbspsubsq
96operate&nbspmotor&nbspvehicle&nbspw/o&nbspdrivers&nbsplicense
96failed&nbspto&nbspyield&nbsp-&nbspapproach/enter&nbspintersection
94veh&nbspw/o&nbsplights&nbspnight
94failed&nbspto&nbspyield&nbspat&nbspa&nbspfour-way&nbspstop-intersection
92overtaking&nbspand&nbsppassing&nbspa&nbspveh (cutting&nbspin)
92imp&nbspsunscrn&nbspat&nbsptop&nbspof&nbspwndshld
88moving&nbsptraffic&nbspviol-drive&nbspon&nbsppermanently&nbsprevoked&nbspdriver&nbsplice
86mcycle&nbspoper&nbspbetween&nbsplane/veh
84restrction&nbspfor&nbspwndow&nbspbehnd&nbspdrv
80too&nbspfast&nbspfor&nbspconditions
80dui&nbspalcohol&nbspor&nbspdrugs &nbsp1st&nbspoffense
80drive&nbspwhile&nbsplicense&nbspsuspended &nbsprevoked &nbspcancelled&nbspw/know
78stand&nbspin&nbsprd/&nbspsolict&nbspride/busns
78no&nbsplamps/illuminating&nbspdevices
76leave&nbsphighway&nbspavoid&nbsptraff&nbspdev
76forgery&nbspof-alter&nbspveh&nbspregis&nbspsticker&nbspcertif&nbspobscure&nbspplate
74turned&nbspwhen&nbspunsafe/no&nbspsignal
72driving&nbspw/o&nbsplights
68operating&nbspwhile&nbspdl&nbspsuspended/cancelled/revoked-no&nbspprior
68improper&nbspcenter&nbsplane&nbspuse
62failed&nbspto&nbspyield/stop&nbspat&nbspa&nbspyield&nbspintersection
62fail&nbspto&nbspstop&nbspsteady&nbspred&nbspindication
58open&nbspcontainer&nbspor&nbspconsumption&nbspof&nbspalcohol&nbspin/on&nbspvehicle
56traffic&nbspoffense-dui&nbspalcohol&nbspor&nbspdrugs
56drive&nbspwrong&nbsplane&nbspor&nbspside
54wearing&nbspheadset/listening&nbspdev
54pedestrain&nbspobstructing&nbsptraffic
52improper&nbspstop/stand/park
52failed&nbspto&nbspyield&nbspto&nbspemergency&nbspvehicle
52crash-fail&nbspto&nbspleave&nbspinfo&nbspunattended&nbspvehicle&nbsp-&nbspprop&nbspdamage
52crash&nbsp-&nbspdiabled&nbspveh&nbspobstruct&nbsptraffic&nbsp-&nbspdriv&nbspfail&nbspto&nbspmove&nbspveh
50texting&nbspwhile&nbspdriving
50permit&nbspunauthorized&nbspperson&nbspto&nbspdrive
50mcycle&nbspw/o&nbspeye&nbspprotection
50learners&nbspdrivers&nbsplicense&nbspviol
50ftyrow&nbspto&nbspped&nbspat&nbspcrosswalk&nbspwith&nbspsignage
48violation&nbspnonresident&nbsprequirements&nbspfor&nbspdrivers&nbsplic
48traffic&nbspoffense-dui&nbspand&nbspdamage&nbspproperty
48improper&nbspparking/two&nbspway&nbsproad
48improper&nbspparking&nbspunincorp&nbsparea
48dui&nbspw/dam&nbspto&nbspprop&nbspor&nbspperson&nbspof&nbspanother
46windshield&nbspviolation
46restricton&nbspfor&nbspwndow&nbspbehnd&nbspdrv
46mcycle&nbsppass&nbspwithin&nbspoccup&nbsplane
46improper&nbsppassing&nbspon&nbspright&nbsp-&nbspdriving&nbspof&nbsppavement
42resist&nbspofficer-fail&nbspto&nbspobey&nbsppolice&nbspor&nbspfire&nbspdepartment
42opening&nbspdoor&nbspinto&nbsptraffic
42fail&nbspuse&nbspsidewalk/ped
42equip&nbspviolation/migrant&nbsptransp
40veh&nbspfail&nbspuse&nbspdue&nbspcare-ped/bike
40riding&nbspbike&nbspwith&nbspno&nbspor&nbspimproper&nbsplight
40parked&nbspin&nbspno&nbsppark&nbspzone
40park/obstruct&nbspdisable&nbsppk&nbspspace
40dui&nbspubal>.15&nbspor&nbspaccom&nbspby&nbsppers <&nbsp18yoa
40driving&nbspwrong&nbsplane&nbspor&nbspside
38improper&nbspstop/rr&nbsptrack
36no&nbsphelmet/insurance&nbspmotorcycle
36fty/s&nbspat&nbspsidewalk-&nbspalley/bldg/priv&nbsprd/dr&nbspwy&nbspto&nbspveh/ped&nbspappro
36fail&nbspdim&nbspheadlghts/imp&nbspadjust
34load&nbspnot&nbspsecure/supports&nbsptruck
34disobey&nbspsteady&nbspred&nbsplight&nbspftyrow&nbspone&nbspway&nbspst
32two&nbsplighted&nbsplamps&nbspmin&nbsprequired
32registration&nbsprequired
32ped&nbspfail&nbspto&nbspyield&nbspto&nbsptraffic
32park&nbsphandicapped&nbspzone
32headlights&nbsprequired /&nbsptinted
30unnecessary&nbspuse&nbspof&nbsphorn
30speed&nbsptoo&nbspfast/conditions
30ped&nbspfail&nbspobey&nbsptraffic&nbspsig
30obstruct&nbsptraffic
30no/improper&nbspturn/stop&nbspsignal&nbspgiven
30engine&nbsprun/key/set&nbspbrake
30drv&nbspsafe/dist&nbsprr&nbspafter&nbspsignal
28ride&nbspw/o&nbsphands&nbspon&nbsphandle&nbspbar
28litter&nbsppub&nbsphghwy/mot&nbspveh
28flee/elude&nbsppolice-flee&nbspw&nbspdisregard&nbspof&nbspsafety&nbspto&nbsppers&nbspor&nbspprop
28flee/elude&nbsppolice-fail&nbspto&nbspobey&nbspleo&nbsporder&nbspto&nbspstop
28fail&nbspto&nbspsignal&nbspturn&nbspproperly
28drive&nbsparound&nbspdetour/barricade
28disobey&nbsplane&nbspcontrol&nbspdevice
26imp&nbspstart&nbspfrom&nbsppark/stop&nbspposit
26green&nbsplight&nbspveh&nbspfacing&nbspfailed&nbspto&nbspyld&nbsprow&nbspwhile&nbspturning
26fty/stop&nbspat&nbspsidewalk&nbspfrom&nbspalley/bldg/priv&nbsprd/drive&nbspway
26drv&nbspleft&nbspside&nbspin&nbspno&nbsppass&nbspzone
26crash&nbsp-&nbspdriv&nbspfail&nbspto&nbsprpt&nbspcrash&nbspw&nbspinjury/death/damage&nbspto&nbsplea
24traffic&nbspoffense-refuse&nbspto&nbspsubmit&nbspdui&nbsptest&nbspafter&nbsplic&nbspsusp
24imp&nbspstop&nbspon&nbspsidewalk
24driv&nbspon&nbspwrong&nbspside&nbspdivided&nbsphwy
24disobey&nbspno&nbsppass&nbspzone&nbspsign
22ped/fail&nbspobey&nbsptraf&nbspsig/intersc
22operator&nbspboating&nbspsafety&nbspid&nbspcard&nbspand&nbspphoto&nbspid
22misrepresentation&nbspof&nbspinsurance
20pass&nbspstopped&nbspschool&nbspbus
20operate&nbspagainst&nbspdl&nbsprestrictions-spec&nbspmech&nbspcontrol&nbspdevice&nbspreq
20municipal&nbspordinance&nbspviol
20ftyrow&nbspto&nbspped&nbspat&nbspintersection&nbspwith&nbsptraffic&nbspctrl&nbspdevice
20ftyrow&nbspenter&nbspstate&nbsphighwy
20fail&nbspto&nbspstop&nbspremain&nbspaccdnt&nbspinvolv&nbspnon-ser&nbspinjry
20fail&nbspto&nbspobey&nbsppolice&nbspor&nbspfire&nbspdepartment
20fail&nbspdim&nbsplights&nbspfrom&nbsprear
20dl&nbsppossession/display/permitting&nbspuse&nbspof&nbspsusp/rev/canc/dq&nbspdl
20crash&nbsp-&nbspno&nbspproof&nbspof&nbspinsurance
18unsecured&nbspload /&nbsptruck
18temporary&nbsptag&nbsp-&nbspexpired&nbsp7&nbspdays&nbspor&nbspless
18speed/busn/resid/intrstate/4ln
18park/prohib/by&nbsptraffic&nbspdevice
18op&nbspveh&nbspunsafe/improper&nbspequip
18improper&nbsppass&nbsp-&nbspnot&nbspspecified
18improper&nbspor&nbspunsafe&nbspequip /&nbspcmv
18fty&nbsp-&nbspvehichle&nbspin&nbspintersections (all&nbspothers&nbspmust&nbspyield)
18fail&nbspto&nbspnotify&nbsphsmv&nbspchg&nbspof&nbspaddress
18dui&nbspalcohol&nbspor&nbspdrugs  &nbsp2nd&nbspoffense
18drop /&nbspshift /&nbspleak&nbspload
16fail&nbspto&nbspobey&nbspsign/signal
16drive&nbspround/railroad&nbspgate/barr
16coast&nbspguard&nbspsafety&nbspequipment&nbsprequired
16all&nbspon&nbspboard&nbsppwc&nbspshall&nbspwear&nbspapproved&nbsppfd
14viol&nbspdrivers&nbsplic/restriction
14resist&nbspofficer-flee&nbspelude&nbspleo&nbspwith&nbsplights&nbspsiren&nbspactive
14overtaking/passing&nbspa&nbspveh-fail&nbspto&nbspgive&nbsprow&nbspto&nbspovertaking&nbspveh
14no&nbspstop&nbsplamp
14no&nbsphead&nbsplamps&nbsprain/fog/smk/ect
14failure&nbspto&nbspmove&nbspover/slow&nbspdown&nbspfor&nbspemg&nbspveh
14disobey&nbspstop/yield&nbspsign
14crash&nbsp-&nbspfail&nbspreport&nbspinfo&nbspto&nbspinjured&nbspperson
12unauthor/disp/blue/red&nbsplight
12stand/parking&nbspprohib/driveway
12speed&nbspto&nbspfast&nbspcond/special&nbsphaz
12permit&nbspunlicensed&nbspminor&nbspto&nbspdrive
12litter&nbspless&nbsp15lb/27&nbspcubic&nbspft
12learner&nbspdl/operate&nbspinvalid&nbsphrs
12improper/no&nbspbike&nbspbrake
12failure&nbspto&nbspobey&nbspdl&nbsprestrictions&nbspordered&nbspby&nbspcourt
12fail&nbspto&nbspobey&nbspcmv&nbsprules
12engine&nbsprun/key&nbspin&nbspignition
12drive&nbspacross&nbspdivided&nbspsection
12disobey&nbspred&nbspflashing&nbspsignal
12disobey&nbspflashing&nbspsignals/red
12crash&nbsp-&nbspleave&nbspscene&nbspinvolving&nbspinjury&nbspw/o&nbsprendering&nbspaid
10vessels:&nbspno&nbspregistration&nbspcertificate
10two&nbsplgtd&nbspheadlamp/req/m/v
10splash /&nbspspray&nbspsuppressant&nbspdev
10poss&nbspof&nbspopen&nbspcont&nbspin&nbspm/v&nbspdrive
10passing&nbspwithin&nbsp100`&nbspof&nbspintersct&nbspapproach
10opn&nbspcontnr&nbspon&nbspin/stop/prk&nbspveh
10mcycle/moped&nbsphead/eye&nbspdevice
10mcycle&nbspno/imp&nbsprearview&nbspmirror
10leaving&nbspscene&nbspof&nbspany&nbspaccident
10failure&nbspto&nbspmove&nbspover&nbspfor&nbspemergency&nbspvehicle
10fail&nbspto&nbspdim&nbspheadlights
8wrong&nbsplane/rotary/one-way
8wrong&nbspheadlight&nbspnbr/loc
8walk&nbspleft&nbspside&nbspwhen&nbspno&nbspsidewlk
8violation&nbspof&nbspsafety&nbspequipment&nbspregulations
8unlawfully&nbspoperate&nbspatv&nbspon&nbsppublic&nbsproad &nbspstreet/hway
8unlawful&nbspnumber&nbspperson&nbspon&nbspbike
8r/r&nbspcrossing&nbsp-&nbspfail&nbspto&nbspobey&nbsptraffic&nbspcontrol&nbspdevice
8public&nbsporder&nbspcrimes-viol&nbspnonresident&nbspexemption&nbspfrom&nbspregis
8possess&nbspmore&nbspthan&nbspone&nbspvalid&nbspdrivers&nbspl
8no/fail&nbspcarry&nbspphysical&nbspexam
8loud /&nbspharsh&nbsphorn
8improper&nbsptowing
8improper&nbspstop&nbspon&nbspcrosswalk
8improper&nbsphorn/warning&nbspdev
8ftyrow&nbspto&nbspped&nbspwhen&nbspno&nbspsignal
8failure&nbspto&nbspslow&nbspdown&nbspfor&nbspemergency&nbspveh/wrecker
8fail&nbspto&nbspchange&nbspname&nbspon&nbspdl
8fail&nbspdrive&nbspto&nbspright/slow
8fail&nbspcover/secure&nbspload
8driving&nbspon&nbspairless&nbsptire
8display&nbspof&nbspregistration&nbspnumbers&nbspand&nbspletters
6violation&nbsprestricted&nbsparea
6vessels:&nbspexpired&nbspvessel&nbspregistration
6sudden&nbspstop&nbspwithout&nbspsignal
6stand/park&nbspproh/fire&nbsphydrant
6speeding/schoolbus&nbspres/busn/in
6passing&nbspin&nbspno&nbsppassing&nbspzone
6pass&nbspin&nbspno&nbsppassing&nbspzone
6operate&nbspw/illegal&nbspsunscreen
6no&nbspturn&nbspsignal&nbsplight
6no&nbspbrake/turn/signals&nbsplighted
6mcycle&nbspw/o /&nbspimp&nbsptail&nbsplamp
6mcycle&nbspw/o /&nbspimp&nbspstop&nbsplamp
6mcycle&nbspw/o /&nbspimp&nbspred&nbspreflector
6mcycle&nbspw/o /&nbspimp&nbsphead&nbsplamp
6inadequate&nbspserv/brakes
6improper&nbsptemporary&nbsptag&nbspunlawful&nbspuse
6improper&nbspstop&nbspon&nbspbike&nbsppath
6improper&nbsppass&nbspveh&nbspproceeding&nbspopposite&nbspdirection
6improper&nbsppass&nbspovertake&nbspright
6improper&nbsppass&nbspon&nbspright
6health-safety-tamper&nbspwith&nbsppollution&nbspcontrol&nbspdevice&nbspsubsq&nbspoff
6fraud-imperson-display&nbsppossess&nbspfictitious&nbspidentification&nbspcar
6flee/elude&nbsppolice-flee&nbspelude&nbspleo&nbspat&nbsphigh&nbspspeed
6fail&nbspto&nbspstop&nbspremain&nbspaccdnt&nbspinvolving&nbspserious&nbspinjry
6emit&nbspexcess&nbspexhaust&nbspfumes
6dui-unlaw&nbspbld&nbspalch-.15&nbspor >&nbspor&nbspaccom&nbspby&nbsppers <&nbsp18y/o&nbsp1st&nbspoff
6driving&nbspunder&nbspthe&nbspinfluence
6driving&nbspthru&nbspsafety&nbspzone
6drive&nbspwrong&nbspside&nbspof&nbsproadway
6drive&nbspw&nbspsus&nbsprev&nbspdl&nbsphabit&nbsptraffic&nbspoff
6drive&nbspacross/on&nbspmedian
6display/obscur&nbspunauth&nbsptraf&nbspdev
6display&nbspof&nbspregistration&nbspdecal
4violation&nbspof&nbspnavigation&nbsprules
4veh&nbspdeprive&nbspmcycle&nbspof&nbsplane
4unlaw&nbspnumber&nbspof&nbspperson&nbspon&nbspbike
4unlaw&nbspdisp&nbspblue&nbsplights
4traffic&nbspoffense-participate&nbspin&nbspunlawful&nbsprace
4traffic&nbspoffense-dui&nbspalcohol&nbspor&nbspdrugs&nbsp3rd&nbspviol&nbspw/in&nbsp10&nbspyears
4sunscrn/sign/covering&nbspon&nbspwndsh
4stand/park&nbspprohibit&nbspby&nbspsign
4speed/racing&nbspon&nbsphighway
4speed&nbspto&nbspfast&nbspfor&nbspcond /&nbspcurve
4slow&nbspbike&nbspfail&nbspride&nbspright&nbspcurb
4public&nbsporder&nbspcrimes-obstruction&nbspof&nbsppublic&nbspstreets&nbspwo&nbsppermit
4public&nbsporder&nbspcrimes-fail&nbspto&nbspregister&nbspmoped
4projecting&nbspload&nbspon&nbsppassg&nbspveh
4poss&nbspof&nbspopen&nbspcont&nbspin&nbspm/v
4ped&nbspcross&nbspintersect&nbspdiagonally
4passing&nbspwithin&nbsp100`&nbspof&nbsprr&nbspcrossing&nbspapproach
4passg&nbspriding&nbspon&nbspexterior&nbspof&nbspvehicle
4parent/guardian&nbspallow&nbspbike&nbspviolation
4operate&nbsp1/2&nbsphr&nbspafter&nbspsunset
4op&nbspexh&nbspsysm&nbspnoise/abate&nbspmodify
4obstruct/dig&nbspup/distrib&nbsproad
4none/improper&nbspbrakes
4mtrcycle/moped:&nbsptag&nbspimproperly&nbspaffixed &nbspconcealed &nbspobscured
4moving&nbsptraffic&nbspviol-reckless&nbspdriving&nbsp1st&nbspoff
4mcycle /&nbspno&nbspheadgear
4maximum&nbspbumper&nbspheights/none
4litter&nbspon&nbspprivate&nbspland
4learners&nbspdrivers&nbsplicense&nbspvio
4improper&nbsppassing&nbspon&nbspright
4improper&nbsppass&nbspveh&nbspproceed&nbspopp&nbspdir-ea&nbspmust&nbspgive&nbsphalf&nbsproadway
4imp/no&nbsprear&nbspstop/lamps
4imp&nbspstop&nbsproadway/xsection
4imp&nbsppark/agnst&nbspflow/curb&nbsp1&nbspway
4imp&nbsppark&nbspone/two&nbspway&nbsprd/angle
4hazardous&nbspwithout&nbspcomply&nbspw&nbspfederal&nbspregulations
4ftyrow&nbspx/county&nbsppaved&nbsproad
4fty-violation&nbspveh&nbspon&nbspleft&nbspyields&nbspto&nbspveh&nbspon&nbspright
4fty&nbspx/sec&nbspinoperative&nbspsignal
4fraud-improper&nbsptemporary&nbsptag&nbspunlawful&nbspuse
4fraud-imperson-non&nbspblind&nbspperson&nbspcarry&nbspwhite&nbspcane
4fraud-display&nbsphandicap&nbsppark&nbspprmt&nbspthat&nbspbelongs&nbspanoth
4follow&nbspfire&nbspapparatus&nbspto&nbspclose
4fail&nbspgive&nbspturn/stop&nbspsignal
4dui&nbspalcohol&nbspor&nbspdrugs &nbsp3rd&nbspoffense&nbspwithin&nbsp10&nbspyears
4drv&nbspw/o&nbsplghts&nbsptwilght/fog/rain
4drive&nbspwo&nbspvalid&nbspcomml&nbspdrivers&nbsplicense
4drive&nbspwhile&nbsplic&nbspsusp&nbspcomml&nbspveh&nbsp1st&nbspof
4drive&nbspw&nbspsusp&nbsprevkd&nbspdl&nbspfor&nbspftp&nbspchild&nbsps
4driv&nbsppermit&nbspriding&nbspon&nbspexterior
4driv&nbspone-way&nbspstreet
4dl&nbspsuspended/&nbspfinancial&nbspresponsibility
4disobey&nbspyellow&nbsplight
4crash&nbsp-give&nbspfalse&nbspinformation&nbspor&nbspreports&nbspto&nbsppol
4crash&nbsp-&nbspfailure&nbspof&nbspveh&nbspoccup&nbspto&nbspmake&nbspreport&nbspif&nbspdriv&nbspunable
4crash&nbsp-&nbspfail&nbspremove&nbspobstruct&nbspattended&nbspveh&nbsp-&nbspprop&nbspdam
4child&nbspunder&nbsp6&nbspyoa&nbspshall&nbspwear&nbspapproved&nbsppfd
4careless&nbspoperation
4altered&nbspexhaust&nbspsystem
2windshld&nbspnone/uprght/fixed/gls
2violation&nbspof&nbsprestricted&nbspareas
2violate&nbspdrivers&nbsplicense&nbsplaw
2veh&nbspdamage&nbsproad&nbspsurface
2under&nbsp16/no&nbspmcycle/150&nbspcm&nbspdisp
2tv&nbspreceivers&nbspin&nbspdrivers&nbspview
2transporter&nbsplicense&nbspplates
2traffic&nbspviolation/animal
2traffic&nbspoffense-dui&nbspalcohol&nbspor&nbspdrugs&nbsp3rd&nbspviol&nbspmore&nbspthan&nbsp10&nbspy
2to&nbspfast&nbspfor&nbspcond&nbspnarow/wind&nbsprd
2texting&nbspwhile&nbspdriving&nbspsecondary&nbspoffense
2stnd/park&nbspprohib&nbspbike&nbsplane
2splash/spray&nbspsuppressant&nbspdev
2skate/coaster/toy&nbspon&nbsproadway
2resist&nbspofficer-refuse&nbspto&nbspaccept&nbspsign&nbspcitation&nbspor&nbsppost&nbspbond
2reckless&nbspoperation
2rear&nbspwindow&nbspnontransparent
2rear&nbsplamp/reflector&nbspcolor&nbspimp
2r/r&nbspcrossing-&nbspinsufficient&nbspspace&nbspto&nbspdrive&nbspcompletely&nbspthrough
2propelling&nbspa&nbspmoped&nbspsidewalk
2possess&nbspstolen&nbspdl&nbspor&nbspid
2possess&nbspcounterfeit&nbspdl&nbspor&nbspid
2ped&nbspfailed&nbspto&nbspyield&nbspto&nbspemergency&nbspveh
2ped&nbspcros&nbsprd&nbspright&nbspangl/shortrt
2pass&nbspveh&nbspwhen&nbspyield&nbspto&nbsppedest
2over&nbspheight&nbspof&nbspload
2operation&nbspafter&nbspexpiration
2operate&nbspcommmercial&nbspvehicle&nbspwo&nbspvalid
2oper&nbspveh&nbspwith&nbspheadset&nbspon
2none/def&nbsprear&nbspview&nbspmirror
2no&nbspstoplight/turn&nbspind
2no&nbspstop/shift&nbspat&nbsprr&nbspcrossing
2no&nbsplamp/flag&nbspon&nbspprojected&nbspload
2neglect&nbspchild-unattended&nbspchild&nbspin&nbspmtr&nbspveh&nbspexcess&nbspof&nbsp15&nbspmins
2moving&nbsptraffic&nbspviol-reckless&nbspdrive&nbspdamage&nbspperson&nbspor&nbspproperty
2motocycle&nbspw/o&nbspproper&nbspheadlight
2misuse&nbspdealer&nbspor&nbspmanufacturer&nbsplicense
2mcycle/moped&nbspimp&nbspride/sitting
2mcycle&nbspwithout&nbspmultibeam&nbsplight
2mcycle&nbspw/o&nbspfootrest&nbsppassg
2mcycle&nbspnone/improper&nbspmuffler
2mcycle&nbspno/defective&nbspharsh&nbsphorn
2mcycle&nbspimproper&nbspriding
2mcycle&nbspimproper&nbsplane&nbspuse
2manatee&nbspprotection&nbspzones (mpz)
2loud&nbspdefective&nbspmuffler
2leave&nbspscene&nbspof&nbspvessel&nbspaccident&nbspor&nbspinjury
2injurious&nbspmaterial/road
2improper&nbsppass&nbsponcoming
2imp&nbsplens&nbspon&nbspred&nbsplight
2imp&nbspbacking&nbspsholder/lm&nbspacc&nbspfac
2illegal&nbspop&nbspof&nbspnonconform&nbspmoped
2green&nbsparrow&nbspveh&nbspfacing&nbspfailed&nbspto&nbspyld&nbsprow&nbspwhile&nbspturning
2golfcart&nbspimproper&nbspoperation&nbspof
2ftyrow&nbspto&nbsphighway&nbspworker
2fraud-unlawful&nbsplending&nbspof&nbspdrivers&nbsplicense
2fraud-misuse&nbspof&nbsptemp&nbsptag&nbspto&nbspavoid&nbspregistr&nbspveh
2fraud-imperson-false&nbspid&nbspgiven&nbspto&nbspleo
2following&nbspto&nbspclose&nbspw/tow/truck
2flee/elude&nbsppolice-aggrav&nbspfleeing&nbspw&nbspinjury&nbspor&nbspdamage
2failure&nbspof&nbspemergency&nbspvehicle&nbspto&nbspuse&nbspwarning&nbspdev
2fail&nbspto&nbspyield&nbspright-of-way&nbspto&nbsppedestrian
2fail&nbspto&nbspwear&nbspbike&nbsphelmet
2fail&nbspto&nbsplower&nbspdive&nbspflag
2fail&nbspdim&nbspheadlights/imp&nbspadjust
2dui-unlaw&nbspbld&nbspalch-bui&nbsp1st&nbspviolation
2dui-unlaw&nbspbld&nbspalch-bui&nbsp1st&nbspor&nbsp2nd&nbspviolation
2dui-unlaw&nbspbld&nbspalch-.15&nbspor >&nbspor&nbspaccom&nbspby&nbsppers <&nbsp18y/o&nbsp2nd&nbspoff
2drugs-possession&nbspof&nbspcontrolled&nbspsubstance
2drop&nbspor&nbspuncovered&nbspload
2drivers&nbspview&nbspobstructed
2driver&nbspview&nbspobstructed
2drive&nbspwo&nbsplic&nbspcauses&nbspdeath/serious&nbspinj
2drive&nbsplic&nbspsusp&nbspcomml&nbspveh&nbsp2nd&nbspor&nbspsubsq
2diving&nbspfrom&nbspany&nbsppublicly&nbspowned (road)&nbspbridge (not&nbspcsx)
2display&nbspspecial&nbspstate&nbspplates&nbspwo&nbspappli
2display&nbspof&nbsptruck&nbsptags:&nbspfront/rear&nbsptrucks&nbspcmv
2disobey&nbspno&nbspchange&nbspof&nbsplane&nbspsign
2disobey&nbspflashing&nbspsignal/yellow
2defective&nbspwindshield&nbspwipers
2damage&nbspprop-crim&nbspmisch-intrf&nbspw&nbsptrf&nbspcont&nbspdev <&nbsp200&nbspdols
2counterfeiting&nbspof-lic&nbspplates&nbspvalidation&nbspstickers&nbspmobile&nbsphome
2careless&nbspoperation&nbspof&nbspvessel
2atv/safety&nbspequip/accd/under&nbsp16

There are other blog posts about this dataset.