utils and helper

utils

all(user[, groupby, summary, network, …]) Returns a dictionary containing all bandicoot indicators for the user, as well as reporting variables.
flatten(d[, parent_key, separator]) Flatten a nested dictionary.

helper.group

filter_user(user[, using, interaction, …]) Filter records of a User objects by interaction, part of week and day.
positions_binning(records) Bin records by chunks of 30 minutes, returning the most prevalent position.
group_records_with_padding(records[, groupby])
group_records(records[, groupby]) Group records by year, month, week, or day.
infer_type(data) Infer the type of objects returned by indicators.
statistics(data[, summary, datatype]) Return statistics (mean, standard error, standard error and median, min and max) on data metrics.
grouping([f, interaction, summary, user_kwd]) grouping is a decorator for indicator functions, used to simplify the
spatial_grouping([f, user_kwd, summary, …])
recharges_grouping([f, summary, user_kwd])

helper.tools

CustomEncoder(*[, skipkeys, ensure_ascii, …])

Methods

OrderedDict

Methods

advanced_wrap(f, wrapper) Wrap a decorated function while keeping the same keyword arguments
Colors() The Colors class stores six codes to color a string.
ColorHandler([stream])
Attributes:
percent_records_missing_location(user[, method]) Return the percentage of records missing a location parameter.
percent_overlapping_calls(records[, min_gab]) Return the percentage of calls that overlap with the next call.
antennas_missing_locations(user[, Method]) Return the number of antennas missing locations in the records of a given user.
pairwise(iterable) Returns pairs from an interator: s -> (s0,s1), (s1,s2), (s2, s3)…
AutoVivification Implementation of perl’s autovivification feature.

helper.maths

mean(data) Return the arithmetic mean of data.
kurtosis(data) Return the kurtosis for data.
skewness(data) Returns the skewness of data.
std(data)
moment(data, n)
median(data) Return the median of numeric data, unsing the “mean of middle two” method.
minimum(data)
maximum(data)
SummaryStats(mean, std, min, max, median, …) Data structure storing a numeric distribution.
summary_stats(data) Returns a SummaryStats object containing statistics on the given distribution.
entropy(data) Compute the Shannon entropy, a measure of uncertainty.
great_circle_distance(pt1, pt2) Return the great-circle distance in kilometers between two points, defined by a tuple (lat, lon).

helper.stops

Building spatial indicators with both coarse (cell towers) and fine-grained (GPS) positions is not trivial. This modules helps cluster GPS locations and update the positions of given records to the closest cluster:

  1. cluster_and_update() clusters records and updates their location,
  2. fix_location() updates the position of all records based on closest cluster found, to avoid having both antennas from cell towers and from clusters.

Algorithms implemented in this module were designed by Andrea Cuttone [CUT2013].

cluster_and_update(records[, group_dist, eps]) Update records, by clustering their positions using the DBSCAN algorithm.
fix_location(records[, max_elapsed_seconds]) Update position of all records based on the position of the closest GPS record.
compute_distance_matrix(points) Return a matrix of distance (in meters) between every point in a given list of (lat, lon) location tuples.

Low-level functions

dbscan(points, eps, minpts) Implementation of [R88932d92178e-DBSCAN] (A density-based algorithm for discovering clusters in large spatial databases with noise).
get_neighbors(distance_matrix, source, eps) Given a matrix of distance between couples of points, return the list of every point closer than eps from a certain point.
get_stops(records, group_dist) Group records arounds stop locations and returns a list of dict(location, records) for each stop.

References

[CUT2013]Cuttone, A. (2013). SensibleJournal: A Mobile Personal Informatics System for Visualizing Mobility and Social Interactions. ISO 690