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

if row is not None:

prob = prob + float(row['Probability'])

return pred, prob

def get_value(self, f, value):

if f == 'ip':

ip = str(ipaddress.IPv4Address(ipaddress.

ip_address(value)))

geo = self.gi.country_name_by_addr(ip)

pred1, prob1 = self.get_score('geo', geo)

res = self.db.frequency.find_one({"ip" : ip})

freq = 1

if res is not None:

freq = res['frequency']

pred2, prob2 = self.get_score('frequency',

str(freq))

return (pred1 + pred2), (prob1 + prob2)

if f == 'root':

s = self.ctr.select(self.ctr.c.root == value)

rs = s.execute()

row = rs.fetchone()

if row is not None:

ctr = row['ctr']

avv = row['avt']

avt = row['avv']

(pred1,prob1) = self.get_score

('ctr', ctr)

(pred2,prob2) = self.get_score

('avt', avt)

(pred3,prob3) = self.get_score

('avv', avv)

20

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

Saved successfully!

Ooh no, something went wrong!