API

Functions

available_metrics() Return a list of metrics that can be used in customer intelligence.
analyse(postcodes[, metrics, num_jobs]) Analyse a set of postcodes with customer intelligence.
sherlockml_extras.customerintelligence.available_metrics()

Return a list of metrics that can be used in customer intelligence.

Returns:
list of str
sherlockml_extras.customerintelligence.analyse(postcodes, metrics=None, num_jobs=None)

Analyse a set of postcodes with customer intelligence.

Parameters:
postcodes : array-like of str

The postcodes to analyse

metrics : array-like of str

Census metrics to use for analysis. Must be a subset of those returned by available_metrics().

num_jobs : int, optional

The number of parallel jobs to use while training the model

Classes

class sherlockml_extras.customerintelligence.AnalysisResult(outputareas, similarity_scores)

Methods

dump(fp) Produce a JSON serialization of the report.
load(fp) Create an AnalysisResult from a report saved in JSON format.
similarity_map([aggregation, limit, bins, …]) Show similarity score on a map.
similarity_score(aggregation[, sort]) Area similarity scores for a specified aggregation.
dump(fp)

Produce a JSON serialization of the report.

Parameters:
fp : file-like

Buffer to write the report to.

classmethod load(fp)

Create an AnalysisResult from a report saved in JSON format.

Parameters:
fp : file-like

Buffer from which the report can be read.

Returns:
AnalysisResult
similarity_map(aggregation='parliamentaryconstituency', limit=None, bins=5, colourmap='viridis')

Show similarity score on a map.

Parameters:
aggregation : str, optional

Aggregation level - can be one of ‘parliamentaryconstituency’ ‘outputarea’, ‘localauthority’, ‘lsoa’ or ‘msoa’ (default: ‘parliamentaryconstituency’)

limit : int, optional

Display only this number of most similar areas

bins : int or array-like, optional

Number of bins or their edges (default: 5)

colourmap : str, optional

Name of the matplotlib colour map to use (http://matplotlib.org/users/colormaps.html, default: ‘viridis’)

similarity_score(aggregation, sort=False)

Area similarity scores for a specified aggregation.

Parameters:
aggregation : str

Aggregation level - can be one of ‘outputarea’, ‘parliamentaryconstituency’, ‘localauthority’, ‘lsoa’, ‘msoa’, ‘postcode’, ‘outcode’ or ‘postcodesector’

sort : bool, optional

Sort the output by descending similarity score (default: False)

Returns:
pandas.DataFrame

Two columns, the first with the aggregation, the second with the similarity score