open_cp.retrohotspot

retrohotspot

This is a traditional hotspotting technique. A window of past data (values around two months seem to be common) is used; the timestamps of the data are then ignored. Around each point we lay down a kernel: typically this is localised in space, e.g. a “quartic” kernel with a certain bandwidth. These are then summed to arrive at an overall relative risk.

Traditionally, a grid-based risk is produced, instead of a continuous kernel. (It seems likely this is due to limitations of historic technology, and not due to any belief in intrinsic superiority of this method). A grid is laid down, and in computing the weight assigned to each grid cell, the distance from the mid-point of that cell to each event is used.

To provide your work kernel / weight, subclass the abstract base class Weight.

class open_cp.retrohotspot.Quartic(bandwidth=200)

Bases: open_cp.retrohotspot.Weight

The classic “quartic” weight, which is the function \((1-d^2)^2\) for \(|d| \leq 1\). In general, we compute the distance from the origin and then divide by a bandwidth to create the variable \(d\).

Parameters:bandwidth – The maximum extend of the kernel.
class open_cp.retrohotspot.RetroHotSpot

Bases: open_cp.predictors.DataTrainer

Implements the retro-spective hotspotting algorithm. To change the weight/kernel used, set the weight attribute.

predict(start_time=None, end_time=None)

Produce a continuous risk prediction over the optional time range.

Parameters:
  • start_time – If given, only use the data with a timestamp after this time.
  • end_time – If given, only use the data with a timestamp before this time.
class open_cp.retrohotspot.RetroHotSpotGrid(region, grid_size=150)

Bases: open_cp.predictors.DataTrainer

Applies the grid-based retro-spective hotspotting algorithm. To change the weight/kernel used, set the weight attribute.

This applies a grid at the start of the algorithm, and so differs from using RetroHotSpot and then gridding the resulting continuous risk estimate.

Parameters:
  • region – An instance of :RectangularRegion: giving the region the grid should cover.
  • grid_size – The size of grid to use.
predict(start_time=None, end_time=None)

Produce a grid-based risk prediction over the optional time range.

Parameters:
  • start_time – If given, only use the data with a timestamp after this time.
  • end_time – If given, only use the data with a timestamp before this time.
class open_cp.retrohotspot.Weight

Bases: object

Base class for kernels / weights for the retrospective hotspotting algorithm.