09.10.2023 Views

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 1

Introduction

(pred4,prob4) = self.get_score(f,

value)

return (pred1 + pred2 + pred3 + pred4),

(prob1 + prob2 + prob3 + prob4)

if f == 'client_time':

value = str(self.get_hour(int(value)))

if f == 'domain':

conn = sqlite3.connect('multiplier.db')

cursor = conn.execute("SELECT high,low from

multiplier where domain='" + value + "'")

row = cursor.fetchone()

if row is not None:

self.high = row[0]

self.low = row[1]

return self.get_score(f, value)

def on_post(self, req, resp):

input_json = json.loads(req.stream.

read(),encoding='utf-8')

input_json['ip'] = unicode(req.remote_addr)

pred = 1

prob = 1

with ThreadPoolExecutor(max_workers=8) as pool:

future_array = { pool.submit(self.get_

value,f,input_json[f]) : f for f in

input_json}

for future in as_completed(future_array):

pred1, prob1 = future.result()

pred = pred + pred1

prob = prob - prob1

resp.status = falcon.HTTP_200

21

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

Saved successfully!

Ooh no, something went wrong!