Monday, August 26, 2019

Versioning Data Science

Data science, being a relatively new field, has no go-to version control standard. In this post I discuss data science cycles, its unique versioning strategy, and some possible solutions.

Data Science Cycles

Data science is different from traditional software development, especially so for stages such as exploratory data analysis, feature engineering, machine learning model training & validation. While both data science and software development involve writing code, data science tends to be more iterative and cyclical, where one cycle often starts with some initial understanding of the data (and hence questions), and then moves to collecting, exploring, cleaning, and transforming the data, and finally to building, validating, and deploying machine learning models, which in turn leads to better data understanding and the start of the next cycle.
data-science-cycle
Image credit: DataScience.LA
Data science is also more interactive, and we can see this from the tools data scientists use: typically not just an IDE, but notebooks (e.g., JupyterZeppelin, or Beaker), which in its nature is more interactive and enables shorter code-result cycles.
This asks for a different version control paradigm, because simply copying software development VCS (version control system) to data science won’t work (anyone who tried to naively git an .ipynb file knows how painful and inflexible it could be). Data science needs its own versioning system so data scientist & engineers can better collaborate, test, share, and reuse.
Currently, although we are seeing some progress, data science version control is still relatively immature and has a lot of room for improvement. In the rest of this blog post I’ll discuss data science unique versioning strategy.

Versioning Strategy

Reproducibility

The guiding principle of doing data science is that people need to be able to easily see and replicate each other’s work. Cookiecutter Data Science has a great comment on this:
A well-defined, standard project structure means that a newcomer can begin to understand an analysis without digging in to extensive documentation. It also means that they don’t necessarily have to read 100% of the code before knowing where to look for very specific things.
Reproducibility entails that for every result, keep track of how it was produced, and for analysis that includes randomness, note the underlying random seeds. All custom scripts need to be version controlled.
One crucial thing to realize (yet sometimes overlooked) is that in order to ensure data science reproducibility, it’s not just code that we need to version control (for code versioning tools like GitHubBitbucket, and GibLab should suffice). There are two additional dimensions that need version control as well: data and models.

Data versioning

Compared with code, data is usually harder to version control simply due to one fact: size. One should feel lucky if the data is around a couple of GB, since in this big data age it’s not uncommon to have data at TB or PB in size.
One good practice is to treat data (objects, not that sits in a SQL database) as immutable, meaning don’t ever naively edit or overwrite your raw data, and keep only one version of the raw data.
Sometimes we might want to dump intermediate data to disk, if the data results from some heavy-processing and time-consuming scripts. Be sure to mark well the generating scripts and its version. Also, try not to change data path once it sits in the system otherwise all scripts/notebooks pointing to the data will break.
There are both open-source and commercial solutions for data version control. E.g, cloud vendors like as Amazon and Google provide versioning options in their S3 and cloud storage services so that data scientists can easily recover from unintended actions and app failures. Also, Git Large File Storage is an open source Git extension for versioning large files, and can be set up on a local server. One thing to keep in mind though is that changing a raw file and saving an updated version can easily use up your disk in version control systems (say you have a 5GB file and even changing 1 byte will eat you another 5GB).

Models versioning

Models should be treated as immutable as well. Models can have exponentially many versions as a result of feature engineering, parameter tuning, new data coming in etc., and therefore entails more specifics in version control. Typically, it’s a good idea to follow these rules:
  • Specify a name, version, and the training scripts of the model. Having a uniform naming convention helps: e.g., (datetime)-(model name)-(model version)- (training script id)
  • Make sure file names are unique (to avoid accidental overwriting)
  • Have a global json file to store model names and score mapping (e.g., key being the model name and value being a 3-element tuple, storing training/validation/test set scores)
  • Have a script to serve & rotate models according to a policy (e.g., test set score), and clean up legacy models (those at the bottom x% according to the policy or haven’t been served for x months/years)

Notebook versioning

Notebooks are an integral part of data science job, and we need it to share results (especially plots and findings in exploratory phases).
jupyter
Image credit: Jupyter
Its JSON format, however, is a pain for version control. In practice, there are several ways to deal with this:
Removing notebook output. This can either be done manually by clearing all output cells, or programmatically with library such as nbstripout.
Refactor the good parts. Here the DIY (don’t repeat yourself) principle from software engineering also applies to data science, and data scientist shouldn’t write code to do the same task in multiple notebooks. Say we have some code to read in a .csv file and encode all the non numeric columns. In a notebook we would see something like this:
import pandas as pd

df = pd.read_csv('path/to/data')

### code block ### 
for c in df:
  if df[c].dtype == 'object':
    df[c] = df[c].factorize()[0]
##################
Standard transformation like this would certainly be reused, so instead of copying/pasting the code block into another notebook, we might want to create a utils.py file, refactor the script into a function, and import the function in notebooks next time we use it:
# uitls.py
def encode_object_col(df):
  # put code block here
# johndoe-eda-2017-02-30.ipynb
import pandas as pd
from utils import encode_object_col

df = pd.read_csv('path/to/data')
df =  encode_object_col(df)
Better still, as we add more processing steps, such as removing columns with % missing values, seeding and splitting the data etc., we can have another pipeline-like function to call all those refactored functions, paramterizing each step as binary or threshold and chaining them together:
# utils.py
def make_data_for_ml(*params):
  ... # read in data and process step by step
# johndoe-eda-2017-02-30.ipynb
from utils import make_data_for_ml
X_train, X_test, y_train, y_test = make_data_for_ml(*params)
This seems obvious but sometimes people (including me) are just to lazy to do it ( refactoring requires time and efforts too…). In the long run it will only do you harm, making data science projects messy and harder to manage. So refactor whenever you can, and bearing in mind that the principle is to make code in notebook files as high level as possible, while leveraging VCS to version the comparatively lower-level code in scripts.
The last thing I want to add is naming convention is crucial for notebooks files, since they are usually exploratory scripts we might revisit multiple time(thus requires searching). Common naming pattern is (date-author-topic.ipynb), so we can search by:
  • date (ls 2017-01-*.ipynb)
  • author (ls 2017*-johndoe-*.ipynb)
  • topic (ls *-*-feature_creation.ipynb)
All the fields of course need to follow a common standard (2017-01-30 or 01-30-2017, JohnDoe, JDoe, or jd).

Other good versioning practices

Set up branches. Borrowed from software engineering, branching can be used for data science in multiple-user and multiple-phase situations, where a typical data science phase (ingestion, eda, feature engineering etc.) can span multiple branches.
Use virtual environment. Installing all the software/packages needed can be quite time-consuming, and evolves over time as packages upgrade. Worse, sometimes dependencies break as a result of such upgrade. So it’s always a good idea to test & integrate virtual environment into your versioning system, e.g., using Data Science ToolboxVirtualenvAnaconda, or even Docker container to create a unified environment for versioning data science.
JSONify (hyper)parameters. No matter how tempting it is to put parameters in your scripts, don’t do it. Instead put them into a global JSON file. If seeds were created, put them in this file as well. Better, combine the model score JSON file with this one so your data project will have a single reference to track machine learning models performance, how different parameter settings affect performance, and how models evolve over time.
Create a domain knowledge stream. One thing that often gets overlooked, or at least ill managed, is the versioning of domain knowledge. A crucial part of data science is domain know-how, and how well it is used affects the quality of the data results. Instead of using Excel or Word to keep track of research findings or notes from SME, create a dedicated stream in the versioning system.

Data science versioning solutions

Just like VCS for software development, we face two options of versioning data science: hosted vs on-prem. However, versioning data science is a bit different since data & model privacy and compliance sometimes would complicate things and therefore make hosted solution not an option.
In most cases, hosted service such as Github or Bitbucket plus a cloud storage (S3 or Google Cloud Storage) would lay the foundation for most data science versioning. In case companies don’t want any of their data (even encrypted) sitting in another’s disk, they can set up Git and Git Large File Storage, or other distributed file systems such as HDFS on local servers to achieve the same goal.
No matter which path do we go down, a centralized versioning engine is necessary. Here are a few promising candidates:
Data Version Control (DVC). DVC is a new open source project that makes data science reproducible by automatically building data dependency graphs (DAG). It integrates with Git, AWS S3, Google Storage, and allows sharing code and data separately from a single DVC environment.
dvc
DVC sharing. Image credit: DVC
Pachyderm. Another option is Pachyderm, a tool for production data pipelines. Building on Docker and Kubernetes, Pachyderm can be installed locally and deployed on AWS, GCP, Azure, and more.
Cookiecutter Data Science. Yet a third option is Cookiecutter Data Science, which features as a logical, reasonably standardized, but flexible project structure for doing and sharing data science work. It’ll create a directory structure (a template) for data science project, and builds a DAG for your data flow. Can be installed locally as well.
LuigiLuigi, built by Spotify, is a Python module that helps you build complex pipelines of batch jobs. It handles dependency resolution, workflow management, visualization etc. It also comes with Hadoop support built in. Check out the source code for more.

Conclusion

Data science has its own uniqueness and therefore requires specific versioning strategy & solutions. Hopefully by now you’ve got a high-level picture of how to version data science projects. Time to get your hands dirty and apply those strategy & solutions to your next project. I am excited to learn what you’ll do!

How to version control your production Machine Learning models


Machine Learning is about rapid experimentation and iteration, and without keeping track of your modeling history you won’t be able to learn much. Versioning let’s you keep track of all of your models, how well they’ve done, and what hyperparameters you used to get there. This post will walk through why versioning is important, tools to get it done with, and how to version your models that go into production.

The Importance of Model Versioning

If you’ve spent time working with Machine Learning, one thing is clear: it’s an iterative process. There are so many different parts of your model – how you use your data, hyperparameters, parameters, algorithm choice, architecture – and the optimal combination of all of those is the holy grail of Machine Learning. But while there is some method to the madness, much of finding the right balance is trial and error. Even the best Machine Learning Engineers working on the most complex Deep Learning projects still need to tinker to get their models right.
With that in mind, here are some of the reasons why versioning is so important to Machine Learning projects:
1. Finding the best model
Throughout that iterative process of updating and tinkering with the different parts of your model, your accuracy on your dataset will vary accordingly. In order to keep track of the best models you’ve created and the associated tradeoffs, you need a versioning system.
2. Failure tolerance
When pushing models into production, they can fail for any number of reasons. You want to update your models to take new data into account or incorporate speed improvements, but it’s tough to be sure how they’ll perform in real time. If you do encounter an issue with a production model, you need to be able to revert quickly to the previous working version.
3. Increased complexity and file dependencies
With traditional software versioning, there are only a couple of types of files to keep track of – your code, and your dependencies. With Machine Learning though, things are a bit more complex. First and foremost, you have datasets (typically not part of a normal software deployment). You need to keep track of what data you train and test on, and if that changes over time.
Additionally, saving your models in most of the popular Deep Learning frameworks results in a file that you need to keep track of. Finally, models are often written in different languages and rely on multiple frameworks, which makes dependency tracking even more important.
4. Gradual, staged deployment
If and when you make significant updates to your production models, those changes are rarely deployed immediately and in one shot. To ensure failure tolerance and test appropriately, new models are typically rolled out gradually until teams can be sure that they’re working properly. Versioning gives you the tools to deploy the right versions at the right times.

Versioning Tools to Get The Job Done

It’s hard to understate how nascent the field of production Machine Learning is, and that means the tools supporting this ecosystem are only starting to be fully developed. Here are some of the solutions that practitioners are currently using, and some new entrants too.
1. Git
Ah, ol’ reliable. Git is the versioning protocol used across the board to monitor and version software development and deployment. You might be familiar with GitHub or BitBucket, which are web-based commercial implementations of this open-source tool. Git tracks any changes made to your code and gives you a ton of functionality around implementing, storing, and merging those changes. Pretty much everyone uses it in one way or another.
Source: xkcd
But alas, Git is not without its issues. In addition to the often perplexing nature of using the actual protocol, its missing a lot of the functionality that you need for Machine Learning (because it wasn’t created for Machine Learning!). Git itself doesn’t allow you to track data, changes to model files, and model dependencies. There are extensions that can help, but those solutions are tough to implement and rarely complete.
2. Sandbox environments
Data Scientists often rave about Jupyter Notebooks, a sandbox-type environment that lets you run code in cells and insert Markdown in between (or at least I rave about them). Jupyter Notebooks are like writing a book with code in them: you can be detailed about what each cell does, and organize things in a visually pleasing way. Separating code into cells and sections is a viable way to version your different models.
When it comes to deployment and production though, versioning your models in a notebook doesn’t really cut it. Jupyter Notebooks are a tool for exploration and visualization, not for managing dependencies and tracking minute changes to hyperparameters.
3. Data Version Control (DVC)
Data Version Control (DVC) is a Git extension that adds functionality for managing your code and data together. It works directly with cloud storage (AWS S3 or Google GCP) to push your changes. According to their tutorial, “DVC streamlines large data files and binary models into a single Git environment and this approach will not require storing binary files in your Git repository.” It’s a streamlined version of combining Git with Machine Learning specific functionality.
For a tutorial on how to implement DVC in your project and why it’s so helpful, check out this walkthrough.
4. Commercial solutions
The traditional business wisdom tells us that if there’s a problem, there’s a business. There are a few companies starting out attempting to solve the versioning problem. Comet.ml is an automatic versioning solution that tracks and organizes all of your team’s modeling efforts. You can easily compare experiments, see the differences in code between two models, and invite team members to collaborate on a project.
5. Platforms as a Service and Algorithmia
Even once you’ve found a way to manage versioning during your training and experimentation process, much of the complexity resides in inference: deploying the right models in the right places at the right times. If you’re using a Platform as a Service to deploy your Machine Learning models, it might offer some functionality around versioning.
If you’re deployed on the Algorithmia platform, we productionize your models as independent microservices with individual endpoints. That means you can continue to reference historical versions of your models in production without having to worry about them breaking or getting deprecated. It’s as simple as appending the model name in our API with a version number.

Further Reading

How to Version Control your Machine Learning task (Towards Data Science) – “A component of software configuration management, version control, also known as revision control or source control, is the management of changes to documents, computer programs, large web sites, and other collections of information. Revisions can be compared, restored, and with some types of files, merged.
Version Control for Data Science (DataCamp) – “Keeping track of changes that you or your collaborators make to data and software is a critical part of any project, whether it’s research, data science, or software engineering. Being able to reference or retrieve a specific version of the entire project aids in reproducibility for you leading up to publication, when responding to reviewer comments, and when providing supporting information for reviewers, editors, and readers.
Managing and versioning Machine Learning models in Python (SlideShare) – “Practical machine learning is becoming messy, and while there are lots of algorithms, there is still a lot of infrastructure needed to manage and organize the models and datasets. Estimators and Django-Estimators are two python packages that can help version data sets and models, for deployment and effective workflow.”
Data Version Control: iterative machine learning (KDnuggets) – “Today, we are pleased to announce the beta version release of new open source tool — data version control or DVC. DVC is designed to help data scientists keep track of their ML processes and file dependencies. Your existing ML processes can be easily transformed into reproducible DVC pipelines regardless of which programming language or tool was used.

Friday, August 23, 2019

100 Udacity AWS DeepRacer Scholarships Challenge for International Students

Udacity AWS DeepRacer Scholarship Challenge for International Students
Udacity AWS DeepRacer Scholarship Challenge for International Students
Get the latest tech skills to advance your career. AWS and Udacity are highly encouraging students across the globe to participate in the Udacity AWS DeepRacer Course and DeepRacer League.
The AWS DeepRacer program is open to all students over the age of 18 who wants to strengthen their machine learning skills and test their skills in the global AWS DeepRacer League. The 200 top-performing students will go on to earn a full Machine Learning Nanodegree program scholarship.
Udacity provides lifelong learning for millions to acquire the new skills they need for the jobs they want. The DeepRacer Scholarship Challenge from Amazon Web Services (AWS) has helped tens of thousands of people across the world.
Amazon Web Services (AWS) and Udacity are teaming up to teach machine learning and prepare students to test their skills by participating in the world’s first autonomous racing league — the AWS DeepRacer League.
Application Deadline: October 31, 2019

Brief Description

  • University or Organization: AWS and Udacity
  • Department: NA
  • Course Level: Machine Learning Nanodegree
  • Award: fully-funded programmes
  • Access Mode: Online
  • Number of Awards: 200
  • Nationality: International

Eligibility

  • Eligible Countries: Application are accepted from worldwide
  • Acceptable Course or Subjects: Machine Learning Nanodegree program
  • Admissible Criteria: To be eligible, the applicants must meet all the following:
  • All students or learners all around the globe
  • Must be at least 18 years of age or older
  • Must be interested in machine learning and have a basic knowledge of Python
  • Residents of a restricted country designated by the United States Treasury’s Office of Foreign Assets Control are not eligible to participate in this program.

How to Apply

  • How to Apply: You can sign up and start building in the AWS DeepRacer console. While you will need a credit card to create an AWS account, you will not be charged to create the account.
  • To qualify for entry to the AWS DeepRacer Scholarship Challenge you must be registered with Udacity for the challenge and you need to submit your model to the AWS DeepRacer League Virtual Circuit leaderboard between August 1 and October 31, 2019.
  • Admission Requirements: Students must have a basic knowledge of Python
Benefits: 200 full opportunities are available to the Machine Learning Engineer Nanodegree programs that guaranteed for program participants.

Apply Now


How to build a winning technology team

Building the right tech team can be tricky. These best practices will help CIOs reinvigorate their IT department

When it comes to developing a successful IT strategy, products, services and vendors can only do so much. If you don’t have the right people in place to bring all those elements together and help to evolve your processes in the future, it’s unlikely your IT strategy will ever get off the ground.
Unfortunately, the growing IT skills gap makes it increasingly difficult for CIOs to staff their IT departments with the necessary talent. Furthermore, for those who are able to fill all their job vacancies, the 2018 CIO Gartner agenda reports that challenges around culture and people continue to hamper efforts to deliver digital transformation.
Here, we outline four best practices to help CIOs overcome these challenges and build the best possible technology team.

Embrace emerging technology

Your business can’t be an early adopter of every emerging technology and in truth, some scepticism and a healthy amount of research before you jump on the latest bandwagon makes good business sense.
However, that doesn’t mean you should sit back and watch every trend pass you by. If something excites you, talk to your team. Is there a business case for investing in the technology? How would it benefit your IT strategy? What value will it bring to the organisation?
BP’s chief digital innovation officer, Morag Watson , has already overseen the adoption of technologies such as  and augmented intelligence and is excited about the opportunities quantum and cognitive computing could afford the company in the future.
“Normally, we invest to either accelerate a technology, because without our investment it wouldn’t get to the use case that we could see for it, or because it would give us some business competitive advantage,” she told CIO UK.
When  first emerged, many organisations were reluctant to adopt the technology because of security concerns. While it’s right you should exercise some level of caution about emerging tech, if you shun everything not only will your organisation be outpaced by peers but your IT department will be severely lacking in experience and skills.

Upskill your current employees

According to data gathered from 2019 CIO 100, 77 percent of CIOs are finding it difficult to recruit the talent they need to drive transformation. Unsurprisingly, the struggle to fill job vacancies has left CIOs thinking outside the box to help find the talent they need, with many CIOs now using IT apprenticeships or upskilling their current workforce to meet departmental needs.
“Very often it’s easier to upskill them into new technologies and even new languages, rather than bringing in people who have the languages and teaching them about the business and data within the people,” says Southern Water CDO, Peter Jackson.[…]

Thursday, August 22, 2019

AI pilot projects: How to choose wisely

A few years ago, I was listening to a vendor pitch with a group of enterprise IT veterans.

The sell focused on features of an intrusion detection software product and the value of  . The vendor said techniques allowed the product to automatically detect threats.
Discussing the pitch afterward, the general sentiment of the group was “I don’t buy it. There is no such thing as magic!” I agreed. As a student of enterprise software, I understood two key things:
  1. Vendors hype the “next great thing” to make it seem more valuable.
  2. Software is very specific. Code has specific instructions and performs exactly as told.
Based on our past software experience, the vendor pitch seemed like snake oil. In our world, software did not figure things out for you. It just followed the rules set for it.
We did not understand the power of , which is turning traditional software development on its head. I’m now convinced that using  will quickly become as common as today’s use of databases. Far from viewing it as snake oil, I now understand that  is essential to bring businesses to the next level.

How to select the right  project – and beat resistance

Selecting the right  pilot project is a vital first step because success with  is different than with traditional software development. Rather than software performing exactly what it’s told to do, an  system learns what it needs to do. That is the opposite of what we are used to, and that creates resistance to investing in .
Start by finding examples of outcomes you want (and you need many of these examples) so the software can learn what it needs to do. This means you must be prepared to explore and be comfortable not knowing why or how something works.
The best way to curb your own resistance to  is to work on a use case. For example, a recommendation engine project served as a starting point for one company’s experience. Initially, it was hard to get product managers to attend meetings and provide feedback. But as the project progressed and the managers understood the approach, they all identified multiple opportunities within their own area of responsibility and sought to launch their own  efforts.
They began to recognize how  could be useful in their roles. This is why selecting the initial  project is vital. It demonstrates the power of  and  and how it can be applied broadly across the business.
 is about changing routines, and that will always meet resistance. The recommendation engine successfully connected technology and people to show how  can help people achieve objectives.[…]

Top Challenges and Benefits of AI Chatbots (Infographic)

Did you know that 69% of the consumers prefer to communicate with chatbots for effective, and quick interaction with brands?

This indicates how popular chatbots, and their popularity will continue to increase.
The reason behind this is the tremendous growth and development of  chatbots are responsible for significant structural changes in many organizations. It’s enabling businesses to provide excellent customer services without increasing the number of employees.
There are some amazing benefits of using  chatbots in business. Such as 24/7 services and improved customer satisfaction. Having said that, there are some challenges of Artificial Intelligence () chatbots, such as it’s not easy to design an effective chatbot.
Before we talk about the benefits and challenges of chatbots in detail, let’s take a closer look at the different types of chatbots. So, let’s dive in.

Types of Chatbots

Basically, there are two types of chatbots – Fixed Chatbots and  Chatbots.
    1. Fixed Chatbots – As you can guess by the name itself, the information in these type of chatbots is fixed. As a result, they offer limited assistance. Fixed chatbots are usually used to solve repetitive questions or for customers who have limited access to customer services. The major downside of Fixed  is that they cannot understand human emotions and behavior. Hence, they are not as popular as  Chatbots.
    2.  Chatbots – Thanks to  technology, these chatbots are able to learn and improve. Also, they are constantly improved and updated based on interactions and communication with customers. When compared to Fixed Chatbots,  Chatbots are intelligent. That’s because they are designed based on advanced technology and offer a positive UX. 
So, these are the two important types of chatbots. Now, let’s move on and take a closer look at the benefits of using chatbots in business.

Benefits of  Chatbots

The following are some of the vital benefits of chatbots which businesses can leverage.

1. Available 24/7

It’s irritating when you are kept on hold for a long time by a customer care agent and forced to listen to the annoying music. Usually, people don’t like to spend a long time on the phone before they can talk with a customer care agent.
Now, with the introduction of  chatbots, customers don’t have to wait for so long to get answers or clarification from you. You can design an  chatbot and replace customer care agents (not totally) with customer care services or emails.
 chatbots are virtual robots, so they never run out of energy to communicate with your customers. Hence, they can operate 24/7, follow your commands, and help you improve customer satisfaction.

2.  Chatbots Can Handle More Customers

Humans are capable of doing multiple things. However, the number of things we can do at the same time is limited. Even if we push ourselves hard and try to manage more tasks, often we end up making errors.[…]

Why the police should use machine learning – but very carefully

The debate over the police using machine learning is intensifying – it is considered in some quarters as controversial as stop and search.
Stop and search is one of the most contentious areas of how the police interact with the public. It has been heavily criticised for being discriminatory towards black and minority ethnic groups, and for having marginal effects on reducing crime. In the same way, the police use of machine learning algorithms has been condemned by human rights groups who claim such programmes encourage racial profiling and discrimination along with threatening privacy and freedom of expression.
Broadly speaking, machine learning uses data to teach computers to make decisions without explicitly instructing them how to do it. Machine learning is used successfully in many industries to create efficiency, prioritise risk and improve decision making.
Although they are at a very early stage, the police in the UK are exploring the benefits of using machine learning methods to prevent and detect crime, and to develop new insights to tackle problems of significant public concern.
It is true that there are potential issues with any use of probabilistic machine learning algorithms in policing. For instance, when using historic data, there are risks that algorithms, when making predictions, will discriminate unfairly towards certain groups of people. But if the police approach the use of this technology in the right way, it should not be as controversial as stop and search and could go a long way towards the police being more effective in preventing and solving crimes.

A modern-day policing challenge

Consider the case of the recent public concern about drill music videosand their unique lyrical content being allegedly used to inspire, incite and glorify serious violence.
Drill music has, over the past few years, spread to major cities in the UK. Social media platforms such as YouTube and Instagram have, at the same time, witnessed a significant increase in drill music videos uploaded online. Many of the videos, which feature male rappers wearing face masks, using violent, provocative and nihilistic language, receive millions of views.
The most senior police officer in the UK, Commissioner Cressida Dick, has publicly criticised drill music videos, stating they are used to glamorise murder and serious violence and escalate tensions between rival street gangs.

Many people disagree with the police blaming of drill music. Supporters of this music genre argue that murder and violence are not a new phenomena, and should not be considered causal to drill artists who rap about the harsh realities of their lived experiences. Some academics are also concerned that the current police approach “is leading to the criminalisation of everyday pursuits” and that “young people from poor backgrounds are now becoming categorised as troublemakers through the mere act of making a music video”.
Nevertheless, to the police, this is an important issue: they have a statutory responsibility to protect life and manage risk to the public. As such, detecting harmful online content which, for example, might contain a threat to a person’s life, is both a contemporary operational policing problem, and an intractable technological problem that the police need to be able to solve.

Developing machine learning tools

Police officers manually viewing large amounts of videos to identify and discern harmful and criminal content from legitimate creative expression is hugely inefficient. As such, it should be automated. Yes, there are presently significant technical challenges for machine learning algorithms to understand such unique lyrical content. But this type of problem, for researchers, does fit neatly into the growing machine learning field of natural language processing. This is a field that uses computational techniques to understand human language and speech.
More broadly, there is a lack of research about the social impact of the police using machine learning to prevent and detect crime. So in the meantime, to avoid controversy the police should not rely on opaque off-the-shelf “black box” machine learning models that have not been tested in an operational policing context to automate the analysis of large amounts of data. Black box models are rightly controversial because they do not show their internal logic nor the processes used to make decisions.
A better way forward is for the police to work with experts and build machine learning models specifically designed for policing purposes that make better use of data to tackle problems, such as those inherent with drill music videos. Durham Constabulary, for example, have recently worked with scientists from the University of Cambridge to develop an algorithmic risk assessment tool to help with decisions about future offending when a person is arrested by the police.
In this way, machine learning tools can be established on widely accepted scientific principles – with a level of transparency that can be used to galvanise public support in ways that stop and search has been unable to do.

Concerns over transparency

In a recent report, the British defence and security think tank RUSI raised more specific concerns about the concept of the police using machine learning algorithms to make predictions and support decision making. Notably, it talks about the concept of “algorithmic transparency” and the difficulty for non-experts to understand how complex statistical models are used to make decisions.
The report does make an important point: if machine learning is used in any form of criminal justice setting, non-experts should be able to understand how decisions have been made and determine whether the outcomes are accurate and fair.
All things considered, the principal of the police using machine learning to identify risk and support decision making, is not – and should not – be considered as a new form of totalitarianism that seeks to erode democratic rights, prevent free speech, marginalise black and minority ethnic groups.
With rising crime in the UK now being the most significant issue facing the British public after Brexit, machine learning – within an appropriate ethical, regulatory and public trust framework – should have a place in the modern-day policing toolbox to prevent crime and protect the public.

Racial bias in a medical algorithm favors white patients over sicker black patients

A widely used algorithm that predicts which patients will benefit from extra medical care dramatically underestimates the health needs of...