How many of the functions are actually used?

In this notebook we'll import data about functions that we've harvested earlier and search for each of these functions in RecordSearch to see how many are actually used.

In [1]:
import json
import pandas as pd
from import tqdm
import altair as alt
from recordsearch_tools.client import RSAgencySearchClient

Load and prepare the data

In [2]:
# Load the JSON file we've already harvested
with open('data/functions.json', 'r') as json_file:
    functions = json.load(json_file)
In [3]:
def get_children(function):
    f_list = []
    if 'narrower' in function:
        for subf in function['narrower']:
            f_list += get_children(subf)
    return f_list

functions_list = []
for function in functions:
    functions_list += get_children(function)
In [4]:
# Get rid of duplicates
functions_list = set(functions_list)
# Sort terms
['accommodation services',
 'administrative decision appeal',
 'administrative decision review',
 'administrative law',
 'administrative services',
 'advertising standards',
 'aged persons services',
 'agricultural sciences',
 'air force',
 'air force administration',
 'air force commands',
 'air operations',
 'air safety',
 'air transport',
 'air transport safety',
 'aircraft standards',
 'airport services',
 'ambulance services',
 'analytical services',
 'animal and veterinary sciences',
 'applications for native title',
 'applied sciences',
 'archives administration',
 'army administration',
 'army commands',
 'artifact export regulation',
 'arts development',
 'arts funding',
 'arts incentive schemes',
 'arts promotion',
 'associations and corporate law',
 'atmospheric sciences',
 'australian capital territory',
 'australian defence forces (adf)',
 'biological sciences',
 'broadcasting standards',
 'built environment',
 'call centre administration',
 'carriage service providers',
 'carrier licensing',
 'censorship standards',
 'census collection',
 'ceremonial functions',
 'chemical and pesticide regulation',
 'child welfare',
 'civic infrastructure',
 'civic management',
 'civil engineering',
 'civil law',
 'climate information services',
 'coastal surveillance',
 'collection access',
 'collection accessioning',
 'collection acquisition',
 'collection management',
 'collection promotion',
 'collection storage',
 'colonial administration',
 'commissions of inquiry',
 'committees of inquiry',
 'commonwealth state relations',
 'community health services',
 'community policing',
 'community protection',
 'community services',
 'community support',
 'community transport',
 'compensation schemes',
 'conservation programs',
 'consular services',
 'consumer affairs',
 'copyright regulation',
 'coronial law',
 'corporate affairs',
 'corrective services',
 'counselling services',
 'courier services',
 'court reporting',
 'courts and tribunals',
 'courts martial',
 'criminal law',
 'crown land administration',
 'cultural affairs',
 'cultural awards and scholarships',
 'cultural festivals',
 'cultural gifts programs',
 'curriculum development',
 'customs regulations',
 'declaration of interests',
 'defence administration',
 'defence coordination',
 'defence estate management',
 'defence force careers',
 'defence forces',
 'defence forces assistance',
 'defence industries',
 'defence intelligence',
 'defence research',
 'defence service home schemes',
 'dental services',
 'detention programs',
 'development assistance programs',
 'diplomatic missions',
 'disability services',
 'disaster recovery',
 'disaster relief',
 'driving licenses administration',
 'early childhood education',
 'earth sciences',
 'education and training',
 'election campaigning',
 'electoral boundary assessment',
 'electoral matters',
 'electronic commerce',
 'electronic postal services',
 'emergency funding',
 'emergency management',
 'emergency services',
 'employment services',
 'energy resources',
 'environmental impact assessment',
 'environmental monitoring',
 'equipment licensing',
 'equity programs',
 'ethical compliance',
 'exchange rates',
 'export regulation',
 'exports and imports',
 'external security',
 'family law',
 'federal law',
 'field force (army)',
 'film production',
 'finance management',
 'financial assistance',
 'financial matters',
 'firefighting services',
 'fiscal policy',
 'fisheries regulation',
 'flight regulation',
 'foreign investment control',
 'foreign policy',
 'forensic analysis',
 'forestry regulation',
 'freight movement regulation',
 'goods and services',
 'government accommodation and catering',
 'government media',
 'government representation overseas',
 'governor general',
 'grants administration',
 'health care',
 'health insurance',
 'health services',
 'hearing services',
 'historic memorials',
 'historic relic protection',
 'home savings schemes',
 'hospitals and clinics',
 'house of representatives committees',
 'human rights',
 'human rights obligations',
 'import regulation',
 'income assessment',
 'indigenous affairs',
 'indigenous cultural heritage',
 'indigenous enterprises',
 'indigenous heritage conservation',
 'indigenous land rights',
 'indigenous settlements',
 'industrial relations',
 'information management standards',
 'information security',
 'inspection services',
 'intelligence liaison',
 'intelligence support',
 'internal security',
 'international affairs',
 'international liaison',
 'international relations',
 'international security liaison',
 'international trade agreements',
 'international treaty participation',
 'interpreter services',
 'interstate trade agreements',
 'justice administration',
 'juvenile justice',
 'labour market programs',
 'land transport',
 'land use',
 'land use planning',
 'land use zoning',
 'land valuation',
 'language services',
 'law enforcement',
 'legal aid',
 'legal aid services',
 'legal services',
 'literature funding',
 'litigation processes',
 'local laws and ordinances',
 'logistics (air force)',
 'logistics (army)',
 'logistics (defence)',
 'marine and rural regulation',
 'marine and rural support',
 'marine life protection programs',
 'marine science',
 'maritime commands (navy)',
 'maritime services',
 'market regulation',
 'mathematical sciences',
 'media ownership regulation',
 'mediation programs',
 'medical aids regulation',
 'medical and health sciences',
 'medical research',
 'medical research funding',
 'migrant accommodation services',
 'migrant services',
 'migrant settlements programs',
 'military operations',
 'mineral exploration',
 'mineral resources',
 'mobile telephone services',
 'multicultural heritage promotion',
 'national events',
 'national fitness',
 'national heritage',
 'national land use',
 'national parks',
 'national referral laboratory services',
 'national service',
 'native title claims',
 'natural disasters',
 'natural heritage protection',
 'naturalisation assessment',
 'navy administration',
 'navy commands',
 'navy support',
 'nursing services',
 'occupational health and safety',
 'oceans governance',
 'overseas aid programs',
 'overseas promotion',
 'overseas student scholarship programs',
 'parliamentary chamber administration',
 'parliamentary committees',
 'parliamentary legislation',
 'parliamentary matters',
 'passenger entry control',
 'passenger services',
 'passport services',
 'patent registration',
 'patents and trademarks',
 'peacekeeping forces',
 'pensions and benefits',
 'pharmaceuticals and medical aids',
 'physical sciences',
 'police administration',
 'police station',
 'pollutant prevention programs',
 'pollution emission control',
 'population-based research',
 'port authorities',
 'port regulation',
 'postal services',
 'preschool education',
 'presentation arrangements',
 'preservation services',
 'primary education',
 'primary industries',
 'prisoners of war',
 'privacy guideline monitoring',
 'property management',
 'prosecution services',
 'protective services',
 'public borrowing',
 'public service',
 'public utilities',
 'publishing and printing',
 'radio broadcasting',
 'radio communication',
 'rail harmonisation standards',
 'rail land acquisition regulation',
 'rail transport',
 'rail transport safety',
 'railway maintenance',
 'rationing and price control',
 'recordkeeping standards',
 'records of the government',
 'refugee services',
 'regional development',
 'repatriation hospitals',
 'rescue coordination',
 'research and development',
 'retail postal services',
 'retirement income',
 'revenue raising',
 'road safety',
 'road surface maintenance',
 'road traffic regulation',
 'road transport',
 'road transport safety',
 'royal commissions',
 'rural community development',
 'rural field day promotion',
 'rural partnership programs',
 'satellite communication',
 'scientific research',
 'sea safety',
 'sea transport',
 'seat of government',
 'secondary education',
 'secondary industries',
 'security and intelligence',
 'settlement negotiations',
 'social and economic research',
 'social justice and equity',
 'social welfare',
 'space science',
 'spatial information research',
 'standard setting',
 'strategic development',
 'strategic policy',
 'strategic support',
 'student assistance',
 'supreme court law',
 'supreme law',
 'surveillance, electronic',
 'survey and mapping',
 'tariff regulation',
 'taxation compliance',
 'telephone services',
 'television broadcasting',
 'territory administration',
 'tertiary education',
 'tourism industry development',
 'tourist event promotion',
 'trade development programs',
 'trade expositions',
 'trade practices',
 'trade skills assessment',
 'trade union training',
 'trademark registration',
 'training (air force)',
 'training (army)',
 'transport and storage',
 'transport infrastructure development',
 'travel authorisation',
 'travel missions',
 'urban development',
 'urban or regional development',
 'vehicle registration',
 'vehicle standards',
 "veterans' affairs",
 'vocational training schemes',
 'war memorials',
 'wartime security',
 'waste disposal',
 'water conservation plans',
 'water quality monitoring',
 'water resources',
 'water usage management',
 'waterway management',
 'weights and measures',
 'world heritage listings',

Search for agencies associated with each function

In RecordSearch, functions are performed by agencies. So when you search for a function you get back a list of agencies. Here we'll loop through the list of functions and search for associated agencies.

In [ ]:
function_totals = []
# Use the agency search code in my recordsearch_tools library
rsclient = RSAgencySearchClient()
for function in tqdm(functions_list):
    agencies = rsclient.search_agencies(function=function, results_per_page=0)
    # Get the total results from each search (replace None with 0)
    total = 0 if agencies['total_results'] == None else int(agencies['total_results'])
    function_totals.append({'function': function, 'total': total})

Explore the results

In [6]:
# Create a DataFrame with the results
df = pd.DataFrame(function_totals)
In [7]:
count 472.000000
mean 27.061441
std 52.553102
min 0.000000
25% 0.000000
50% 0.000000
75% 28.000000
max 419.000000

So 75% of all functions have less than 28 associated agencies.

How many are actiually used?

In [8]:
# How many functions are actually used
used = df.loc[df['total'] > 0].count()
In [9]:
percent_used = used['function'] / len(functions_list)
print('{:.1%} of the functions are used'.format(percent_used))
48.7% of the functions are used
In [10]:
# Most used function
df.loc[df['total'] == df['total'].max()]
function total
67 employment 419
In [11]:
# Top 20 by number of agencies
df.sort_values(by='total', ascending=False)[:20]
function total
67 employment 419
161 education 294
470 army commands 286
278 social welfare 270
346 indigenous affairs 268
241 training 232
376 housing 220
350 scientific research 216
334 migration 198
323 goods and services 195
373 customs 183
275 government representation overseas 176
43 community services 175
5 secondary industries 173
341 administrative law 169
252 broadcasting 169
363 logistics (army) 166
172 sea transport 163
123 health 161
338 air transport 157

Show how agencies are distributed across functions

In [12]:
# Bin the agencies to make it wasier to read
    x=alt.X('total:Q', bin=alt.Bin(step=10), title='Number of associated agencies'),
    y=alt.Y('count()', title='Number of functions'),
    tooltip=[alt.Tooltip('total:Q', bin=alt.Bin(step=10), title='Agencies'), alt.Tooltip('count()', title='Functions')]

Created by Tim Sherratt as part of the GLAM Workbench.