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.

faculty_extras.customerintelligence.available_metrics()

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

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

Analyse a set of postcodes with customer intelligence.

Parameters
postcodesarray-like of str

The postcodes to analyse

metricsarray-like of str

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

num_jobsint, optional

The number of parallel jobs to use while training the model

Classes

class faculty_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
fpfile-like

Buffer to write the report to.

classmethod load(fp)

Create an AnalysisResult from a report saved in JSON format.

Parameters
fpfile-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
aggregationstr, optional

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

limitint, optional

Display only this number of most similar areas

binsint or array-like, optional

Number of bins or their edges (default: 5)

colourmapstr, 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
aggregationstr

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

sortbool, 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