Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Histogram aggregation of metrics in flowmachine #1075

Closed
maxalbert opened this issue Jul 17, 2019 · 1 comment · Fixed by #1099
Closed

Histogram aggregation of metrics in flowmachine #1075

maxalbert opened this issue Jul 17, 2019 · 1 comment · Fixed by #1099
Labels
enhancement New feature or request FlowMachine Issues related to FlowMachine

Comments

@maxalbert
Copy link
Contributor

maxalbert commented Jul 17, 2019

The SpatialAggregate class in flowmachine allows to aggregate metrics spatially - e.g. going from a location associated with each subscriber (such as daily_locations) to a subscriber count per admin region.

However, some metrics (e.g. subscriber-focused ones) don't allow intrinsic spatial aggregation. For example, Displacement or RadiusOfGyration associate a number (representing the distance of displacement / radius of gyration) with each subscriber but there is no way to intrinsically aggregate this to spatial units (without assigning a "reference location" for each subscriber - which is what JoinedSpatialAggregate allows to do).

For metrics of the latter kind it would be useful to support a histogram aggregation. This should accept a metric (such as Displacement, RadiusOfGyration, etc.) and the bins and range parameters as supported by numpy.histogram. The return value should be the same pair hist_values, bin_edges as returned by numpy.histogram. (This can then separately be fed into a plotting function or otherwise processed.)

For now, as a first prototype it should be ok to do the calculation in Python, although this won't work for large data amounts and we will soon want to push the calculation into Postgres (but let's address this in a separate issue). Also, we will want to expose this functionality through the API, which will also be tracked in a separate issue.

@maxalbert maxalbert added enhancement New feature or request FlowMachine Issues related to FlowMachine labels Jul 17, 2019
@greenape
Copy link
Member

Postgres' width_bucket seems like a good fit for this: https://www.postgresql.org/docs/current/functions-math.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request FlowMachine Issues related to FlowMachine
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants