09.10.2023 Views

Advanced Data Analytics Using Python_ With Machine Learning, Deep Learning and NLP Examples ( 2023)

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 7

Analytics at Scale

Elastic load balancer

System instance 1

Primary: Asia

Secondary: US

System instance 2

Primary: US

Secondary: Europe

System instance 3

Primary: Europe

Secondary: Asia

Figure 7-6. The system

In Chapter 1 I showed some example code of publishing a deep

learning model as a REST API. The following code is the implementation of

the same logic in a cloud environment where the other storage is replaced

by a Google data store:

import falcon

from falcon_cors import CORS

import json

import pygeoip

import json

import datetime as dt

import ipaddress

import math

from concurrent.futures import *

import numpy as np

from google.cloud import datastore

def logit(x):

return (np.exp(x) / (1 + np.exp(x)))

def is_visible(client_size, ad_position):

170

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!