Index

As this ebook edition doesn't have fixed pagination, the page numbers below are hyperlinked for reference only, based on the printed edition of this book.

Symbols

== symbol 37

= symbol 37

|= operator 536

| union operator 536, 540

3D plots

generating 163-165

__init__ method 177

**kwargs

using 111, 112

__str__ method 186, 187

adding, to Country class 187, 188

** symbol 5

A

Adaptive Boosting (AdaBoost) 476

using, to predict median house values in Boston 478, 479

using, to predict pulsars 477, 478

ahead-of-time (AOT) compilation 367

Anaconda Prompt 348

and operator 35

append method 64

application programming interface (API) 326

area of triangle

finding 17, 18

argparse

program creating, to accept input from user 363, 364

arguments

keyword arguments 179

positional arguments 179

array

creating, to implement NumPy computations 391-397

assertion error

using, with functions 145, 146

assertions

writing 144, 145

assignment expression 532

automated testing 316

test categorization 316, 317

test coverage 318

average 384

B

bar plots

plotting 151-154

Titanic dataset, visualizing with 168-170

basic list operations 61, 62

basic math operations 5, 6

big data

working with 408

binary search 105-107

Booleans 34

comparison operators 36, 37

logical operators, combining with 35, 36

Boolean variables 34

boosting algorithms 476

AdaBoost 476

XGBoost 476

Boston Housing dataset

correlation values, finding from 427-429

data insights, obtaining on 412-414

downloading, from GitHub 409

preparing, for deep learning 491-493

reading 410, 411

scatter plot, creating for 425, 426

used, for creating histogram 419-421

viewing 410, 411

box plots 433

creating 433, 434

branching 34

break keyword 45, 46

bubble sort 102

using, in Python 103

C

calculator

Python as 4

casting 10, 12, 27

working, with types 27, 28

ChainMap class 264-266

chess tournament

building 282

child processes

customizing, with env vars 244-246

class attributes 176

classes 172

Circle class, creating 178

creating 213

defining 175, 176

inheriting, from parent class 213

keyword arguments 179

Pet class, creating 176, 177

subclassing, from Python packages 202

templates 177

classification

neural networks, building 512-515

classification models 462, 463

classification report

for pulsar dataset 473-475

classifiers 468

class inheritance 199

classes, creating 213

classes, inheriting from parent class 213, 214

classes, subclassing from Python packages 202

consultation appointment system, creating 209-211

datetime.date class, subclassing 203

inheriting, from Person class 201, 202

method resolution order 212, 213

methods, overriding 204, 205

methods, overriding with super() 207, 208

multiple inheritances 209

parent method, calling with super() 206, 207

single inheritance 200, 201

class methods 191, 192

partial, using 273, 274

Pet class, extending with 192, 193

clock arithmetic 4

CNN kernel 519-521

code

deploying, into production 351, 352

profiling 371

refactoring, with defaultdict class 261-263

running, in parallel with multiprocessing 355, 356

code’s timing 122

calculating 122, 123

collections

ChainMap class 264-266

counter class 258

defaultdict class 259, 260

using, in Python 257

column types

casting 408

command-line arguments

parsing, in scripts 362, 363

command-line interface (CLI) tool 304

comma-separated values (CSV) 138, 409

comma separators 24

comments 16

displaying, ways 16, 17

company employee table data

storing, with dictionary 75

storing, with list 75

comparison operators 36, 37

practicing with 37, 38

used, for comparing strings 39

completedProcess instance 241

complex number types 10

reference link 10

conda server and local system

environments, sharing between 350, 351

conda virtual environment

creating, to install numpy 347-350

creating, to install pandas 347-350

setting up, to install numpy 347-350

setting up, to install pandas 347-350

conditionals 39

elif statement 42

if else 41

if syntax 39

confusion matrix 470

for pulsar dataset 473-475

pulsar percentage, finding from dataset 470-473

consultation appointment system

creating 209-211

continue keyword 53-55

contour plot

creating 160, 161

conversational bots

building, with Python 55, 56

convolution 520

convolutional neural networks (CNN) 516

building, to predict handwritten digits 521-523

MNIST 516

used, for classifying MNIST Fashion images 524

Coordinated Universal Time (UTC) 228

correlation 426, 427

correlation values

finding, from Boston Housing dataset 427-429

counter class 258

Country class

__str__ method, adding 187, 188

area of country, calculating with instance method 185, 186

creating, with keyword arguments 180, 181

cProfile 371

profiling with 372-378

CPython 369, 528

change, making with Git 334-337

cross-validation

used, for testing data 449

cross_val_score function

used, for obtaining accurate results on dataset 450, 451

customer names

formatting 112

Customer Relationship Management (CRM) 112

customer return rate accuracy

ML, using to predict 479, 480

custom iterators 289, 290

controlling 291, 292

creating 287

simplest iterator 288, 289

Cython 369

adopting, to find time taken to get list of prime numbers 369-371

D

dance genre list

tuple properties, exploring 78, 79

data

downloading 408

reading 409, 410

storing, from matrix with nested lists 66, 67

testing, with cross-validation 449

data analysis

performing, to find outliers 436

dataclasses 531

dataclass module

using 221, 222

DataFrame 398

using, to manipulate stored student test score data 398, 399

DataFrame computations 402-405

with student test score data 400, 401

dataset 408

data structures 57, 58

lists 59

data types

modifying 10, 12

selecting 85-87

dates

working with 225, 226

datetime

comparing, across time zones 227, 228

working with 232

datetime.date class

subclassing 203

datetime objects

time delta, calculating between 228-230

daylight saving time (DST) 226

debugging

preparing for 144

process 304-307

DecisionTreeClassifier

using, to predict accuracy in dataset 468-470

decision trees 457, 458

building 459

deep learning algorithms 486-490

deep learning model 490

Boston Housing dataset, preparing 491-493

Early Stopping 507

Keras models, tuning 499

libraries 490, 491

number of epochs 505

Sequential deep learning, using to predict accuracy of house values of our dataset 494-498

default dict

adopting 285-287

defaultdict

using, to obtain default values 285

defaultdict class 259, 260

used, for code refactoring 261- 263

defensive programming 144

density plot

generating 159, 160

dependency management 346, 347

destination inputs

accepting, from user with positional arguments 365, 366

dictionary (dicts) 398

keys 72, 73

manipulating, with zip() 79, 80

merge (|) syntax 536

properties 72

required keys 544

rules 73

unzipping, with zip() 79

update (|=) syntax 536

used, for storing company employee table data 75

using, to store movie record 73-75

values 72, 73

zipping, with zip() 79

dictionary comprehensions 282, 283

used, for building scorecard 284

using 284

dictionary methods 76

used, for accessing dictionary 76, 77

directory

glob pattern, used for listing files 237-240

Dispersion Measure (DM) 463

divisible code file

documenting 328-331

Docker 351

docstrings (document strings) 17, 94

adding, to my_module.py 94, 95

using, to create documentation 326, 327

documentation

complex documentation 331

creating 326

creating, with docstrings 326, 327

creating, with Sphinx 327, 328

Don’t Repeat Yourself (DRY) 126, 199, 200

double indentation 46

Dropout 509

using, in neural network to improve score 510-512

dummy variable 51

dynamic programming 120

Fibonacci function, using with 123, 124

E

Early Stopping 507

number of epochs, optimizing with 507-509

easier to ask forgiveness than permission (EAFP) 260

echo.py

example 222-225

electronic publication (EPUB) 327

elements 80

elif statement 42, 43

employee data

storing, with nested list 67, 68

environments

sharing, between conda server and local system 350, 351

env vars

used, for customizing child processes 244-246

errors 10

escape sequence 20

with quotes 20

execnet

multiprocessing with 356

working, to execute Python squaring program 356-358

Exploratory Data Analysis (EDA) 168

F

factorials, with iteration and recursion

creating 118, 119

Faster CPython 541

fatal logs 248

Fibonacci function

using, with dynamic programming 124

using, with iteration 115

using, with recursion 119

files

listing, within directory with glob pattern 237-240

reading 138

writing 141, 142

filter lambda

using 134

filters 253

finite sequence

turning, into infinite sequence and back again 295

Fizzbuzz tool

dockerizing 352-354

float 8-10

for loops 50

using 50-53

formatters 253

f-strings 24, 534

full name property 195, 196

function 107

adapting, with partial 271, 272

defining, and calling in Python script 108

defining, and calling in shell 107, 108

defining, with keyword arguments 110, 111

defining, with positional arguments 110, 111

early exit 114

exiting, during for loop 114, 115

importing, and calling from shell 109

functional or end-to-end (E2E) tests 317

functools

functools.lru_cache, caching with 267

lru_cache, using to speed up code 267-270

using 266

functools.cached_property 532, 533

G

GaussianNB

using, to predict accuracy in dataset 468-470

generator functions

evaluating with 295

random numbers, using to find value of Pi 297-299

Sieve, generating 296

Git 332, 340

used, for making change in CPython 334-337

GitHub

Boston Housing data, downloading from 409

Python, writing as team 341-346

Global Interpreter Lock (GIL) 356

global keyword 130

glob pattern

using, to list files within directory 237-240

Google Colaboratory Notebooks (Colab notebooks) 485

graphical processing units (GPUs) 485

graphs

extending 161, 162

plotting, don’ts 166-168

H

handlers 253

handwritten digits

CNN, building to predict 521-523

hashable objects 258

heatmap

generating 155-158

helper function 124, 125

using, for currency conversion 126, 127

hidden files

listing, in home directory 240

hidden layers 499

high-level modules 217-219

examples 218

histogram 419

creating, with Boston Housing dataset 419-421

histogram functions

creating 421-424

home directory

hidden files, listing 240

hyperparameter 454

Hypertext Markup Language (HTML) 306

I

if else 41

using 41, 42

if __name__ == '__main__' statement 97

if syntax 39

using 40, 41

importlib.metadata 533

importlib.resources 531

indentation 40

index 59

indexing 30-32

infinite loops 45

infinite sequences

using 292-294

inheritance. See  class inheritance

input

accepting, from user with argparse 363, 364

input() function 28, 33

using 29, 30

using, to rate day 30

inputs and outputs (I/Os) 304

reference link 25

instance methods 181

__str__ method 186, 187

adding, to Pet class 183

arguments, adding 184

examples 181, 182

keyword argument, using 185

refactoring, with static methods 189, 190

integer 8-10

summing 120-122

integer object

creating 172, 173

Integrated Development and Learning Environment (IDLE) 216

integrated development environment (IDE) 305

integration tests 317

International Earth Rotation and Reference Systems Service

reference link 230

item

accessing, from lists 62

accessing, from shopping list data 62, 63

adding, to list 63

adding, to shopping list 64, 65

iterative functions 113

itertools

finite sequence, turning into infinite sequence and back again 295

infinite sequences, using 292-294

leveraging 292

takewhile(), using 292-294

J

JavaScript Object Notation (JSON) 138

Jupyter Notebook 485

starting with 3

Jupyter Notebook issues, troubleshooting guide

reference link 3

just-in-time (JIT) compilation 367

K

Keras models

hidden layers 499

tuning 499

kernel density estimation (KDE) 160

keys 72, 73

keyword arguments 110, 179

Country class, creating with 180, 181

function, defining with 110, 111

k-nearest neighbors (KNN) 454

used, for finding median value of dataset 455, 456

k-nearest neighbors (KNN), with GridSearchCV

used, for finding optimal number of neighbors 456, 457

KNeighborsClassifier

using, to predict accuracy in dataset 468-470

L

lambda functions 131, 132

filtering with 134

mapping with 132

used, for sorting 135

writing, for first item in list 132

lasso 452

least common multiple (LCM)

finding 46

len() function 25, 61

libraries

importing 95

Light Gradient Boosting Machine (LightGBM) 476

linear regression 441-445

function 448, 449

issues, simplifying 442, 443

N-dimensions 443

used, for predicting accuracy of median value of dataset 445-448

linear search 104, 105

line chart

drawing 149-151

list comprehensions 279, 280

chess tournament, building 282

multiple input lists, using 280, 281

using 278

list methods 61

lists 59

basic operations 61, 62

converting, into NumPy arrays 383

item, accessing from 62

item, adding to 63

looping through 65

properties 72

unzipping, with zip() 79

used, for storing company employee table data 75

working with 60, 61

zipping, with zip() 79

LiteralString type 544, 545

logger object 248, 249

using 249, 250

logging 247

in debug category 248

in error category 248-253

in fatal category 248-253

in info category 248

in warning category 248-253

logging cookbook

reference link 253

logging module

using 247, 248

logging stack

configuring 253-257

logical operators 35, 36

logistic regression 466

used, for predicting data accuracy 467, 468

logistic transform

mapping with 133

log records 253

look before you leap (LBYL) 260

loops 43

break keyword 45, 46

components 43

continue keyword 53-55

for loops 50

programs, writing 46

running, by time elapsed calculation 233

while loops 43-45

lower-level modules 219

examples 220

lru_cache

using, to speed up code 267-270

M

machine learning (ML)

MNIST data, preparing 517-519

using, to predict customer return rate accuracy 479, 480

matrices 65, 388

as nested lists 65, 66

computation time, for large matrices 390

nested list, using to store data from 66, 67

working with 388-390

matrix operations 68

implementing 69, 70

multiplication 70

multiplication, implementing 71, 72

max

finding 387

mean

calculating, of test score 384

mean, with null values

concatenating, of test score data 406, 407

finding, of test score data 406, 407

median 384

finding, from collection of income data 384, 385

median house values, in Boston

AdaBoost, using to predict 478, 479

XGBoost, using to predict 478, 479

median house values, of dataset

Sequential deep learning, using to predict 494-498

median values, of dataset

accuracy, predicting with linear regression 445-448

finding, with k-nearest neighbors 455, 456

members 80

methods 181

class methods 191, 192

instance methods 181, 182

overriding 204, 205

overriding, with super() 207, 208

static methods 188, 189

min

finding 387

MNIST 516

data, preparing for machine learning 517-519

MNIST Fashion images

classifying, with CNNs 524

mode 414

modular arithmetic 4

modules 90

movie record

storing, with dictionary 73-75

multiline strings 21

multiple inheritances 209

multiple input lists

using 280, 281

multiple lists

used, for building scorecard 284

multiple variables 15

assigning 15, 16

multiprocessing

used, for running code in parallel 355, 356

with execnet 356

with multiprocessing package 358

with threading package 360

multiprocessing package

using, to execute Python program 358-360

mutable list 77

N

Naive Bayes 468

nbviewer

URL 256, 257

nested lists 61, 66

matrices as 65, 66

using, to store data from matrix 66, 67

using, to store employee data 67, 68

Network Time Protocol (NTP) 232

neural network

building, for classification 512-515

building, to predict whether patient has heart disease 515

densely connected layers, modifying to improve score 499-505

Dropout, using to improve score 510-512

number of epochs, modifying to improve score 506, 507

nonlocal keyword 130, 131

Not a Number (NaN) 405

not operator 35

null values 414

checking 464-466

replacing 417, 418

viewing 414-417

number of epochs 505

modifying, in neural network to improve score 506, 507

optimizing, with Early Stopping 507-509

numpy

conda virtual environment, creating, to install 347-350

conda virtual environment, setting up to install 347-350

NumPy 382

components 382

NumPy arrays 382

lists, converting into 383

NumPy computations

implementing, by creating array 391-397

NumPy documentation

reference link 72

O

objects 172

order of operations 7

working with 7, 8

ordinary least squares (OLS) 431

origin repository 341

or operator 35

OS

information 234

interacting with 234

outliers 385

P

pandas

conda virtual environment, creating to install 347-350

conda virtual environment, setting up to install 347-350

pandas library 398

parent class

classes, inheriting from 213

parent method

calling, with super() 206, 207

partial

used, for adapting functions 271, 272

using, on class methods 273, 274

pathlib

using 236, 237

pattern matching 538, 539

reference link 539

PEG parser 535

reference link 535

PEP 1 529

PEP 8 529

PEP 11 529

PEP 602 529

PEP 634 538, 539

PEP 678

exceptions notes 545, 546

perfect squares

calculating 47, 48

Person class

inheriting from 201, 202

Pet class

creating 176, 177

extending, with class methods 192, 193

instance method, adding 183

Pi

random numbers, using to find value of 297-299

pie chart

creating 154, 155

Titanic dataset, visualizing with 168-170

pip package

creating 321-323

distribution with multiple files, creating 323-325

information, adding 325, 326

plotting techniques 146

Portable Document Format (PDF) 327

positional arguments 109, 179, 364

function, defining with 110, 111

using, to accept destination inputs from user 365

using, to accept source inputs from user 365, 366

positional-only parameters 534

POSIX time 230

predictor column 441, 443

prime numbers list

Cython, adopting to find time taken to obtain 369-371

print function 21, 22

creating, that writes to stderr 272, 273

process information

inspecting 234-236

production

code, deploying 351, 352

programs

writing 46

writing, for real estate offer 48-50

writing, to identify perfect squares 47, 48

properties 193

full name property 195, 196

property decorator 194, 195

setter method 196, 197

validation, via setter method 198, 199

pseudocode 99

pull request workflow 341

pulsar dataset

classification report 473-475

confusion matrix 473-475

preparing 464-466

pulsar percentage

finding, from dataset 470-473

pulsars

AdaBoost, using to predict 477, 478

XGBoost, using to predict 477, 478

PyPy 367

used, for finding time to get list of prime numbers 367-369

pytest

reference link 320

test, writing with 320, 321

Python

as calculator 4

bubble sort, using in 103

collections, using 257

errors 10

logging in 247

performance 366

profiling 366

script and modules 90

sets, using 81, 82

tests, writing with unit testing 318

text file, reading 138-140

used, for building conversational bots 55, 56

writing, on GitHub as team 341-346

Python 3.7 529

built-in breakpoint 529

dataclasses 531

dict insertion order 531

importlib.resources 531

module dynamic attributes 529, 530

nanosecond support, in time module 530

Python 3.8 531

assignment expression 532

f-string, supporting debug with = 534

functools.cached_property 532, 533

importlib.metadata 533

positional-only parameters 534

typing.Final 534

typing.Literal 534

typing.TypedDict 534

Python 3.9 535

dicts, supporting for | union operator 536

IANA database 535, 536

PEG parser 535

str.removeprefix 537

str.removesuffix 537

type hints, with standard collections 537

Python 3.10 537

correlation, computing 541

covariance, computing 541

error messages 539, 540

linear_regression, computing 541

parenthesized context managers 539

pattern matching 538, 539

type union operator (|) 540

Python 3.11 541

enhanced errors, in tracebacks 541-543

exceptions notes 545, 546

LiteralString type 544, 545

required keys in dicts 544

runtime 541

tomllib package 543, 544

Python algorithms 98, 99

maximum number, finding with 99, 100

Python code

testing 246, 247

Python code application

debugging 314, 315

Python developer’s guide

URL 528

Python Enhancement Proposals (PEPs) 528, 529

reference link 528

sections 528

Python environment

modifying 366

Python function

example 92

Pythonic code 263

Python module

importing 92, 93

writing 92, 93

Python Packaging Authority (PyPA) 321

Python program

executing, with multiprocessing package 358-360

Python script

building, to calculate time 98

executing 91

writing 91

Python Software Foundation (PSF) 321

Python squaring program

executing, with execnet 356-358

Python virtual environment

random numbers list, generating 378, 379

Q

quality assurance (QA) 316

quotes

escape sequence with 20

R

RandomForestClassifier

using, to predict accuracy in dataset 468-470

random forests 457, 458

building 459

hyperparameters 459, 460

tuning, with RandomizedSearchCV 460-462

RandomizedSearchCV

used, for tuning random forests 460-462

random numbers list

generating, in Python virtual environment 378, 379

recursion

Fibonacci function, using with 119, 120

recursive countdown

creating 118

recursive functions 116, 117

terminating case 117

regression 430

regression line

plotting 430, 431

regression test 316

regular expressions

features 299

text, matching with 300

using 299, 300

using, to replace text 301

winner, finding for X-Files 301, 302

regularization 451-454

technique 509

reStructuredText PEP Template

reference link 528

reStructuredText (RST) 327

ridge 452

runtime documentation 247

S

salary calculator

debugging 307-314

scatter plots 424

creating, for Boston Housing dataset 425, 426

drawing 147-149

scorecard

building, with dictionary comprehensions 284

building, with multiple lists 284

scripts 90

command-line arguments, parsing 362, 363

searching algorithms 104

Sequential deep learning

using, to predict accuracy of median house values of dataset 494-498

series 399

set comprehensions 282, 283

using 283, 284

sets 80

operations 82, 83

operations, implementing 83-85

using, in Python 81, 82

setter method 196, 197

used, for validation 198, 199

writing 197, 198

shebangs

in Ubuntu 93

shopping list

item, adding to 64, 65

shopping list data

item, accessing from 62, 63

shutil 240

Sieve

generating 296

Signal to Noise Ratio (SNR) 463

single inheritance 200, 201

skewed data 385

slicing 30-33, 63

sorting algorithm 101-103

source code management 332

commit history 334

commit object 332

files, ignoring 334

local changes, undoing 334

repository 332

staging area 333

source code tree 321

source distributions (sdists) 321

source inputs

accepting, from user with positional arguments 365, 366

spaces 8, 23

Sphinx

files, generating 327

using, to create documentation 327, 328

standard collections

used, for type-hinting 537

standard deviation 386

finding, from income data 386, 387

Standard Library 216

high-level modules 217-219

lower-level modules 219, 220

navigating 220

need for 216

reference link 220

standard math operations 4, 5

static methods 188, 189

instance methods, refactoring with 189, 190

statistical graphs

creating 418

StatsModel

regression output 431, 432

stderr 241

print function, creating that writes to 272, 273

stdout 241

string concatenation 23

string interpolation 24

casting 27

comma separators 24

f-strings 24

input() function 28

len() function 25

string methods 25, 33, 34

implementing 26, 27

strings 18

comparing 39

comparing, with comparison operators 39

displaying 21, 22

error syntax 19, 20

escape sequence 20

exploring 173-175

indexing 30

multiline strings 21

operations 23

reference link 20

slicing 30

syntax 18

str.removeprefix 537

str.removesuffix 537

subclassing 200

subprocess module

reference link 240

using 240-244

sum

finding 387

super() method

methods, overriding with 207, 208

parent method, calling with 206, 207

syntax error 11

system date

finding 96

T

tab completion 25

takewhile()

using 292-294

target column 441

test coverage 318

test score

mean, calculating of 384

text

matching, with regular expressions 300

replacing, with regular expressions 301

text document

words, counting 258, 259

text file

content, writing 142, 143

data and time, recording with content creation 142, 143

partial content, reading from 140, 141

reading, with Python 138-140

threading package

multiprocessing with 360

using 360-362

time complexities 100

constant time 101

for the maximum number algorithm 101

logarithmic time 101

quadratic time 101

time delta

calculating, between two datetime objects 228-230

time elapsed

calculating, to run loop 233

time_ns 233

times

working with 225, 226

timestamps 226

time.time function 233

Time Zone Database

reference link 535

time zones

datetime, comparing 227, 228

timsort 222

tomllib package 543, 544

traces 304

transpose 399

tuple properties

dance genre list, exploring 78

exploring, in dance genre list 78, 79

tuples 77

two-dimensional arrays 65

type casting 18

types

working, with casting 27, 28

typing.Final 534

typing.Literal 534

typing.TypedDict 534

U

Ubuntu

shebangs 93

unit testing 317

sample code, checking with 318-320

tests, writing in Python with 318

Unix epoch time

calculating 230-232

Unix time 230

upstream repository 341

UTC time zone 231

V

values 72, 73

variable assignment 11

variables 127, 128

inside, versus outside 128-130

naming 13-15

scope 127

shortcut, for incrementing by 1 12

values, assigning to 11-13

violin plots 434

creating 434, 435

virtual environments 347

saving 350

sharing 350

W

wall time 226

walrus operator 532

while loop 43

incrementor 44

instructions 44

setting up 44

variable, initializing 44

working 44, 45

words

counting, in text document 258, 259

X

X-Files

winner, searching 301, 302

XGBoost (Extreme Gradient Boosting) 476

using, to predict median house values in Boston 478, 479

using, to predict pulsars 477, 478

Z

zip()

used, for unzipping dictionaries 79

used, for unzipping lists 79

used, for zipping dictionaries 79

used, for zipping lists 79

using, to manipulate dictionaries 79, 80

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset