Skip to content

flowmachine.features.subscriber.meaningful_locations

Class MeaningfulLocations

MeaningfulLocations(*, clusters: flowmachine.features.subscriber.hartigan_cluster.HartiganCluster, scores: flowmachine.features.subscriber.scores.EventScore, labels: Dict[str, Dict[str, Any]], label: str) -> None
Source: flowmachine/features/subscriber/meaningful_locations.py

Infer 'meaningful' locations for individual subscribers (for example, home and work) based on a clustering of the cell towers they use, and their usage patterns for those towers. Return a count of meaningful locations at some unit of spatial aggregation. Generates clusters of towers used by subscribers' over the given time period, scores the clusters based on the subscribers' usage patterns over hours of the day and days of the week. Each subscriber then has a number of clusters, each of which has a score for hourly usage, and day of week usage. These clusters are then labelled based on whether they overlap with the regions of that space defined in the labels parameter. This is an extension of work by Isaacman et al.1 by Flowminder in collaboration with the World Bank2.

Attributes

Parameters

  • clusters: flowmachine.features.subscriber.hartigan_cluster.HartiganCluster

    Per subscriber clusters of towers

  • scores: flowmachine.features.subscriber.scores.EventScore

    Per subscriber, per tower scores based on hour of day and day of week of interactions with the tower

  • labels: typing.Dict[str, typing.Dict[str, typing.Any]]

    Labels to apply to clusters given their usage pattern scoring

  • label: str

    Meaningful label to extract clusters for

Methods

cache

cache
Source: flowmachine/core/query.py

Returns
  • bool

    True is caching is switched on.

column_names

column_names
Source: flowmachine/features/subscriber/meaningful_locations.py

Returns the column names.

Returns
  • typing.List[str]

    List of the column names of this query.

column_names_as_string_list

column_names_as_string_list
Source: flowmachine/core/query.py

Get the column names as a comma separated list

Returns
  • str

    Comma separated list of column names

dependencies

dependencies
Source: flowmachine/core/query.py

Returns
  • set

    The set of queries which this one is directly dependent on.

fully_qualified_table_name

fully_qualified_table_name
Source: flowmachine/core/query.py

Returns a unique fully qualified name for the query to be stored as under the cache schema, based on a hash of the parameters, class, and subqueries.

Returns
  • str

    String form of the table's fqn

index_cols

index_cols
Source: flowmachine/core/query.py

A list of columns to use as indexes when storing this query.

Returns
  • ixen: list

    By default, returns the location columns if they are present and self.spatial_unit is defined, and the subscriber column.

Examples
daily_location("2016-01-01").index_cols
[['name'], '"subscriber"']

is_stored

is_stored
Source: flowmachine/core/query.py

Returns
  • bool

    True if the table is stored, and False otherwise.

query_id

query_id
Source: flowmachine/core/query.py

Generate a uniquely identifying hash of this query, based on the parameters of it and the subqueries it is composed of.

Returns
  • str

    query_id hash string

query_state

query_state
Source: flowmachine/core/query.py

Return the current query state.

Returns
  • QueryState

    The current query state

query_state_str

query_state_str
Source: flowmachine/core/query.py

Return the current query state as a string

Returns
  • str

    The current query state. The possible values are the ones defined in flowmachine.core.query_state.QueryState.

table_name

table_name
Source: flowmachine/core/query.py

Returns a uniquename for the query to be stored as, based on a hash of the parameters, class, and subqueries.

Returns
  • str

    String form of the table's fqn


  1. S. Isaacman et al., "Identifying Important Places in People's Lives from Cellular Network Data", International Conference on Pervasive Computing (2011), pp 133-151. 

  2. Zagatti, Guilherme Augusto, et al. "A trip to work: Estimation of origin and destination of commuting patterns in the main metropolitan regions of Haiti using CDR." Development Engineering 3 (2018): 133-165.