Machine Learning

Multi-Cloud Machine Learning with data from on-premises and training with Google Cloud Vertex platform (Part 2 of 2)

In part 1 of the blog series we introduced the components of the solution. In this part we will look at the use cases and the key takeaways.

 

Use Case 1: COVID-19 Detection Application (HealthCare)

The massive COVID-19 pandemic resulted in the collapse of many healthcare systems as it entirely consumed all financial and healthcare resources. In response to the resource crisis has turned to less expensive and more precise detection methods for COVID-19. Computer Image recognition COVID-19 detection leveraging Deep learning has gained popularity as an important tool for diagnosis.

 

 

The training leverages the COVID-19 (SARS-CoV-2) lung CT scan dataset, containing total of 8,439 CT scans which consists of 7,495 positive cases (COVID-19 infection) and 944 negative ones (normal and non-COVID-19. (Source: https://www.kaggle.com/mehradaria/covid19-lung-ct-scans) Further details can be found related paper at: Deep Convolutional Neural Network–Based Computer-Aided Detection System for COVID-19 Using Multiple Lung Scans: https://www.jmir.org/2021/4/e27468 authored by Ghaderzadeh M, Asadi F, Jafari R, Bashash D, Abolghasemi H, Aria M. The Design and Implementation Study Code is also available at: https://github.com/MehradAria/COVID-19-CAD

Figure 4: CT Scan based COVID19 detection

 

COVID19 Training in Google Vertex Platform:

The following steps were performed to train a COVID19 detection model based on CT scans.

  1. The Kaggle dataset consisting of lung CT scans used in the solution was downloaded and used as the initial dataset for training. The images were replicated to a Google Cloud VMware Engine instance connected to the example customer network. Some statistics regarding the CT Scans are shown below.
  1. A total of 8,439 CT scans which consists of 7,495 positive cases (COVID-19 infection) and 944 negative ones (normal and non-COVID-19).
  2. The dataset was then copied to Google cloud storage from GCVE for training use with Google Vertex
  3. Covid19 image datasets were read and used as Pandas dataframes.
  4. We then split the set of files into train, validate and test images resulting in the following distribution:
    •   Training images count: 5400
    •   Validating images count: 1351
    •   Testing images count: 1688
  1. We then process the training, test datasets by decoding, converting, and resizing the scan images followed by shuffling of the dataframes.
  2. DenseNet-201 is a convolutional neural network that is 201 layers deep. We make use of DenseNet-201 with preloaded weights from the ImageNet database.
  3. Then we fit the model based on the training dataset over 50 epochs (iterations).
  4. We then finetuned the model over 100 epochs.
  5. This finetuned model is then used to showcase predictions on actual previously unseen patient CT scans.

 

Figure 5: COVID19 related CT-Scan images stored in Google Cloud Storage

 

Google Cloud Vertex Infrastructure

The Google vertex platform was used for training on the stock market data. The training was done leveraging a Jupyter notebook backed by a machine instance with four vCPUs and one NVIDIA v100 GPU. created a notebook with 4 vCPUs, 1 NVIDIA V100 GPU and TensorFlow 2.6. The vertex platform provided the option to automatically choose the appropriate NVIDIA driver. The machine type used was n1-standard-4 with 4 vCPUs, 15 GB memory and the NVIDIA v100 GPU.

 

Figure 6: Code snippet used in COVID19 model training

COVID19 Inference:

Unused CT Scan images were used to test the generated model by Google Vertex leveraging the code referenced above. The results from the inference are shown below. The model can accurately identify COVID19 positive and negative chest CT scans with potential use for the healthcare organization to quickly analyze patient scans for signs for COVID.

 

 

Figure 7: COVID19 inference and prediction for test images with the trained model

 

Use Case 2: Stock Market Prediction model:

The second use case in this solution leverages data from a Microsoft SQL server running in a Google Cloud VMware Engine (GCVE) instance. The stock market data is replicated from an enterprise MS SQL database to the SQL instance running in GCVE.

Figure 8: GCVE Environment with Microsoft SQL server instance for stock market data

The stock market data is extracted nightly in CSV format from the database into a Google Cloud Storage bucket as shown.

Figure 9: Stock market data exported to Google Cloud Storage

 

Stock Market Data and Modeling:

The stock market data used in this solution is sourced from Yahoo finance which has well-structured and clean historical data on stock prices. Financial institutions like Banks are making use of Machine learning and Deep Learning Technology to develop strategies on pricing, trading recommendations, etc. The main target of these companies is to ride the volatility as well as the highs and lows in the market to provide strategies for a positive return on investment.

Long short-term memory (LSTM) models are well-suited to classifying, processing and making predictions based on time series data, since there can be lags of unknown duration between important events in a time series. We have adapted a LSTM model – a type of recurrent neural network used in deep learning and can learn the order of dependence between items in sequence. This sample code learns the parameters required to predict in time series problems. This is a basic program and not aimed to be used to gain any significant profits. This is more to illustrate how such predictions related programs work. For example, this model doesn’t take into account factors like market sentiment (from sources like tweets from Twitter, articles in financial publications like Bloomberg, WSJ, etc.).

The tooling available in Google Cloud Vertex is used to train an LSTM stock price prediction model through a notebook interface as shown.

Figure 10: Google vertex for stock market modeling

 

Data Preparation and Training:

We plot the data to figure out if a straight 80-20 split of data is possible. In case there is significant variations in the last 20% of the data, then the model may not work fine. We use the “Adjusted Close” price (which takes care of stock-splits/merges). The data was split 80% for training and 20% for test as shown below.

Figure 11: Stock Market Data split for training and testing

The basic logic behind LSTM is that the data taken from previous day(s) is used to predict the next day data. In our sample code, we take the previous 80 days’ data to make prediction for the next day.

 

Google Vertex Infrastructure for Stock prediction modeling:

The Google vertex platform was used for training on the stock market data. The training was done leveraging a Jupyter notebook backed by a machine instance with four vCPUs and one NVIDIA v100 GPU. created a notebook with 4 vCPUs, 1 NVIDIA V100 GPU and TensorFlow 2.6. The vertex platform provided the option to automatically choose the appropriate NVIDIA driver. The machine type used was n1-standard-4 with 4 vCPUs, 15 GB memory and the NVIDIA v100 GPU. GPUs were actively leveraged during the training as shown below

Figure 12: Leveraging GPUs through Google Vertex for training

When we trained our model with the data, we ran for a small number of epochs as our idea is to illustrate the model fit and prediction.

Figure 13: Snippet showing training in GCP Vertex

The code used in the model was obtained from Source: Medium.com This model converged quite well even with just 10 epochs. This model was saved to the file system as highlighted in the image below.

Figure 14: Stock Prediction model available for export

 

Inference Testing:

The model was then tested against the test data for two different stocks MSFT (Microsoft) and FB (Facebook) A plot of predicted Vs actual values is shown separately for MSFT and FB.

 

Figure 15: Facebook (FB) Actual vs Predicted stock price

Figure 16: Microsoft (MSFT) Actual vs Predicted stock price

The results clearly show that the model is very accurate in predicting the next day closing price for common stocks.

Key Takeaways:

By leveraging high performance GPU compute in the cloud and using on-premises data for two different industry cases, we have effectively demonstrated a strong value proposition for multi-cloud environments. We demonstrated the use of the Google Cloud Vertex platform for training with high performance hardware.

Here are the key takeaways:

  • A VMware powered Multi-Cloud Platform can be effectively used to mix and match applications and data between on-premises and the public cloud.
  • Google Cloud Platform can be leveraged for specialized high-performance compute instances with GPUs necessary for AI/ML training
  • Many of the best of breed AI/ML capabilities of Google Cloud Vertex AI can be accessed and leveraged effectively by data scientists and ML engineers
  • VMware based multi-cloud platform provides for efficient distribution of AI/ML models developed in Google Cloud across disparate edges and endpoints
  • Google Cloud VMware Engine is an easy conduit for data from the enterprise to the cloud