Blog post banner

How to Enable Public Health by Innovation in Predictive Analytics

Is there a way to let people know of a potential infection risk before even coming into contact with each other?

🗓️ Date:
⏱️ Time to read:
Table of Contents

This is a 2-part blog series co-authored by Team Egen and me. Click here to read the 1st part, authored by Team Egen.


The bubonic plague is perhaps one of the best known pandemics that occurred in the year 1350 AD. Also named The Black Death. It was responsible for the death of over one-third of the world population. In 1817, the first wave of Cholera pandemics began that would continue for at-least 150 years. The first three waves alone is estimated to have killed at-least 15 million people, despite having developed a vaccine at the time.

And there are several more that occurred over the span of several centuries, with well-documented gory accounts that would turn you into a compulsive germaphobe if you knew the details!

Let’s talk about the present. The most popular topic of the year 2020 award goes to

Screenshot of Google Trends for the year 2020

You guessed it — Coronavirus. The fact that Tom Hanks is on this list mostly because the actor got diagnosed with COVID-19 this year makes it all the more daunting! Here’s another search term that saw a massive surge in usage — covid contact tracing.

Screenshot of Google Trends showing covid contact tracing as a very popular search term in the year 2020

A bit unusual, but hardly surprising. Although a pandemic continues to affect us as much as it did in the year 1350 AD, the difference is that it’s now struck us in the Age of Information.

So naturally when COVID-19 hit us this year, governments and private organizations world have been attempting to come up with technology solutions to minimize the spread of disease.

Let’s explore some of the most popular tech solutions implemented for the COVID pandemic, and understand few of their potential problems.

Existing tech solutions

Digital contact-tracing by far seems to be the de-facto technology solution across most countries, at-least until a vaccine for COVID-19 is mass-produced.

Arogya Sethu — the Indian Government’s official contact-tracing service — crossed five million downloads within three days of its launch in April 2020, and was briefly made mandatory for all citizens to install the app on their phones. China deployed a similar service that is in use across more than 200 cities. And likewise, countries like Germany, United Kingdom, Canada and several others have also deployed similar services.

Most tech solutions have largely been around contact-tracing applications. The amount of data that is being collected is huge, and has understandably raised concerns around privacy and mass-surveillance. Most tech companies and government organizations have enthusiastically jumped on the technology bandwagon to implement smart-solutions in the hope that it would help with the pandemic.

In the scramble to be the first, not enough thought goes into discussing basic essentials, such as the usability, design and feasibility of solutions.

One of the biggest case-in-point being Arogya Sethu. Over the months, various security and privacy issues have been brought-up by security experts and exposed on social media. Initially dismissive of these concerns in the first few months, the Indian Government has since then launched a bug-bounty program, after the Supreme Court declared it illegal to mandate the use of the app. The app’s play-store rating had also dropped to 1 for collecting more information than necessary.

But that’s not the only concern. Here are several more that has been raised by both technologists and healthcare professionals:

  • Overwhelming amount of false-positives being reported, especially with digital-tracing solutions that involved bluetooth. False positives could result in needless self-isolation, or could cause users to ignore warnings if the warnings are perceived as unreliable.
  • For contact-tracing apps to be effective, there needs to be a minimum of 56–70% user adoption in the population.
  • A similar problem is the issue of false negatives, especially when a substantial percentage of the population don’t have the app installed or don’t even own a smartphone. For instance, smartphone penetration in the United States remains at about 81 percent — meaning that even if we had 100 percent installation of these apps (which is extremely unlikely without mandatory policies in place), we would still only see a fraction of the total exposure events (65% according to Metcalfe’s Law).

Amidst all these problems,

Regulating human behavior remains the biggest challenges of our times.

Rethinking from first principles

There exist many gaps to implement a holistic approach towards technology adoption from a strategy point-of-view. Here, the role of design thinking in Artificial Intelligence comes into play.

In our previous blog, you learned how the role of predictive analytics can be leveraged to implement business, policy, and travel decisions. Building prediction models is a great start. But like any other technology, an AI model can only be truly effective if it is well-implemented.

To ensure successful AI implementations, organizations must first figure out why, where, and how they can apply technology to specific business problems. At Egen, we began with the most basic question —

Is there a way to let people know of a potential infection risk before even coming into contact with each other?

In our previous blog, you learned how to predict COVID-19 risk factors for a location on a certain date. We explored how to train a regression model using Amazon Sagemaker, and storing them on Amazon S3 bucket. We also describe how to use AWS Lambda to fetch the latest trained models from a bucket based on the location and date provided.

Let’s explore in detail now on how you can build an App that best leverages our Covid-19 predictor model.

App look-and-feel

Here’s how we built V1 of the Covid Recommendation System mobile app at Egen, a.k.a CoRS:

Once you’re past the initial landing page, the app shows an interface with a set of input fields, and a map:

Screenshot of the CoRus mobile app

The first input allows the user to type in a location, and the other allows you to select a date from a dropdown menu. Upon entering these details and hitting search, the app fetches the COVID-risk predictions for that place and displays it on the map.

Goa is a popular spot in India for its extravagant beach parties, especially during new year’s time! Let’s see what our app shows us for Goa during 31st December:

Screenshot of CoRus app showing risk predictions for Goa

Overall, there are about 32,000 official Covid cases with an infection rate of 148%! Not recommended to visit!

Darn it! Maybe I shouldn’t have booked the ticket after all. 😂

Tech Stack

Let’s explore what core technologies and design choices go behind building this mobile app:

Front-end

React Native is a framework that helps you build native mobile applications for both the Android as well as iOS platforms. It leverages the power of React, a JavaScript library for building dynamic user interfaces in JavaScript. It’s open-source and has a wide community support.

Along with React-native, we also make use of a couple of other modules:

  • React Native Google Places Autocomplete: A customizable autocomplete component for the React Native platform. It allows you to bind Google Places API to your location search input box in-order to auto-suggest places as you type, and to capture the latitude and longitude information of the place.
  • React Native Modal Datetime Picker: For displaying a date-picker and time-picker inside a modal when the user selects the date-input.
  • React Native Maps: For displaying and interacting with maps.
Screenshot of the Corus app showing the React Native Maps, Datetime picker, and Google Places Autocomplete in action

Back-end

NestJS: A Node framework for building server-side applications using TypeScript. Having the same language (JavaScript/TypeScript) for both the front-end and back-end speeds up development time and allow you to quickly build and deploy a cross-platform application.

MongoDB: A cross-platform document-oriented database. It is pretty versatile, and provides a lot of querying capabilities, including geo-spatial information.

Along with these, you’ll also use a few other modules on the server side:

Google Maps Services: This node module makes use of Google’s Maps service to fetch information of a place from a given set of coordinates.

Amazon EC2: For hosting the backend microservice.

Here’s how you can put together all the core technologies into a full-functional mobile app!

Building the App control flow and logic

  1. Upon typing in the location in the UI, the app extracts the latitude and longitude information using the google places autocomplete module. Similarly, the date-time picker also allows the user to select the date. Upon hitting search, the UI sends this information to our back-end microservice hosted on EC2.
  2. Upon receiving the request, the NestJS backend uses the Google Maps NodeJS client’s reverse geocoding API to fetch the address of the place using the latitude and longitude information.
  3. Next, the backend sends the address and date information to our AWS Lambda Predict endpoint.
  4. The control flow now goes to AWS. Our predict function in Lambda fetches the latest machine learning model from AWS S3 and runs predictions.
  5. The results of the predictions are sent back to the backend and is stored in the database MongoDB.
  6. The backend sends the prediction results back to the React-Native client.
  7. Finally, the client shows the travel recommendations to the user.

Backend — Building the recommendations microservice

Each microservice in NestJS lies in its own module. In-order to create a module, open your terminal, cd to your NestJS project folder and type nest generate module recommendations to scaffold a new module recommendations in your project.

Step #1: Setting up the service

First, you run nest generate service recommendations . This will create a new file recommendations.service.ts within the recommendations module folder. Next, you’ll add the following code:

Here’s how the structure of the Recommendation object result looks like

export type Recommendation = {
    predictionModelId: string;
    userId: string;
    date: Date;  
    location: {
        address: string;
        city: string;
        state: string;
    };
    result: {
        infectionRate: number;
        growthRate: number;
        confirmCases: number;
        status: string;
    };
};

Step #2: Expose the service via an endpoint

Once the service is added, you’ll expose it via an endpoint. The routing logic for this in NestJS is done by adding a controller. Run nest g controller recommendations — this will create a file recommendations.controller.ts. Next, add the following code:

Front-end

The main app screen consists of a presentation-view layer Corus.tsx. This component in-turn will import GooglePlacesAutocomplete, DateTimePickerModal and the MapView components and contain the presentation logic to render them.

Once the recommendations have been fetched, you can display the information using your own custom-created component, such as a Card or a Modal.

Conclusion

With the advent of the internet age, improvements in computing, cloud technology and Artificial Intelligence in the last couple of decades, several tech companies are focusing on including AI into their processes and applications. While predictive analytics give us immense power, one needs to understand the problem from first principles in-order to fully leverage these technologies.

Pandemics are global phenomena that affects countries worldwide. While some countries have managed to contain the spread of disease, others have been unsuccessful because they’ve been unable to foresee what lies ahead in the coming months.

Throughout history, humans have always been prone to letting their feelings and prejudices cloud their judgement. But we no longer need to go down that path. Predictive platforms like CoRS, that can provide location-and-date based recommendations can help eliminate needless bias that goes behind business and government policy decision making.

Predicting the future is the single most biggest advantage that we have over the dark ages.

It’s a pretty lofty goal, but it’s one worth pursuing!


Originally published in Egen Engineering.