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

Except Falcon-specific changes, you should note the major changes in

parallelizing the calling get_score function using a thread pool class.

import falcon

from falcon_cors import CORS

import json

from sqlalchemy import *

from sqlalchemy.orm import sessionmaker

import pygeoip

from pymongo import MongoClient

import json

import datetime as dt

import ipaddress

import math

from concurrent.futures import *

from sqlalchemy.engine import Engine

from sqlalchemy import event

import sqlite3

@event.listens_for(Engine, "connect")

def set_sqlite_pragma(dbapi_connection, connection_record):

cursor = dbapi_connection.cursor()

cursor.execute("PRAGMA cache_size=100000")

cursor.close()

class Predictor(object):

def __init__(self,domain):

db1 = create_engine('sqlite:///score_' + domain +

'0test.db')

db2 = create_engine('sqlite:///probability_' +

domain +'0test.db')

db3 = create_engine('sqlite:///ctr_'+ domain +

'test.db')

18

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

Saved successfully!

Ooh no, something went wrong!