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
3D plots
__init__ method 177
**kwargs
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
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
assignment expression 532
automated testing 316
test coverage 318
average 384
B
bar plots
Titanic dataset, visualizing with 168-170
big data
working with 408
Booleans 34
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
scatter plot, creating for 425, 426
used, for creating histogram 419-421
box plots 433
branching 34
bubble sort 102
using, in Python 103
C
calculator
Python as 4
chess tournament
building 282
child processes
customizing, with env vars 244-246
class attributes 176
classes 172
Circle class, creating 178
creating 213
inheriting, from parent class 213
keyword arguments 179
subclassing, from Python packages 202
templates 177
classification
neural networks, building 512-515
classification models 462, 463
classification report
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 with super() 207, 208
multiple inheritances 209
parent method, calling with super() 206, 207
Pet class, extending with 192, 193
clock arithmetic 4
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
collections
counter class 258
using, in Python 257
column types
casting 408
command-line arguments
command-line interface (CLI) tool 304
comma-separated values (CSV) 138, 409
comma separators 24
comments 16
company employee table data
storing, with dictionary 75
storing, with list 75
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
pulsar percentage, finding from dataset 470-473
consultation appointment system
contour plot
conversational bots
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 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
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
creating 287
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
storing, from matrix with nested lists 66, 67
testing, with cross-validation 449
data analysis
performing, to find outliers 436
dataclasses 531
dataclass module
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
lists 59
data types
dates
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
DecisionTreeClassifier
using, to predict accuracy in dataset 468-470
building 459
deep learning algorithms 486-490
deep learning model 490
Boston Housing dataset, preparing 491-493
Early Stopping 507
Keras models, tuning 499
number of epochs 505
Sequential deep learning, using to predict accuracy of house values of our dataset 494-498
default dict
defaultdict
using, to obtain default values 285
used, for code refactoring 261- 263
defensive programming 144
density plot
dependency management 346, 347
destination inputs
accepting, from user with positional arguments 365, 366
dictionary (dicts) 398
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
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
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
electronic publication (EPUB) 327
elements 80
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
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
filter lambda
using 134
filters 253
finite sequence
turning, into infinite sequence and back again 295
Fizzbuzz tool
for loops 50
formatters 253
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
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
H
handlers 253
handwritten digits
CNN, building to predict 521-523
hashable objects 258
heatmap
using, for currency conversion 126, 127
hidden files
listing, in home directory 240
hidden layers 499
examples 218
histogram 419
creating, with Boston Housing dataset 419-421
histogram functions
home directory
hidden files, listing 240
hyperparameter 454
Hypertext Markup Language (HTML) 306
I
if else 41
if __name__ == '__main__' statement 97
if syntax 39
importlib.metadata 533
importlib.resources 531
indentation 40
index 59
infinite loops 45
infinite sequences
inheritance. See class inheritance
input
accepting, from user with argparse 363, 364
using, to rate day 30
inputs and outputs (I/Os) 304
reference link 25
instance methods 181
adding, to Pet class 183
arguments, adding 184
keyword argument, using 185
refactoring, with static methods 189, 190
integer object
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
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
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
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
libraries
importing 95
Light Gradient Boosting Machine (LightGBM) 476
N-dimensions 443
used, for predicting accuracy of median value of dataset 445-448
line chart
chess tournament, building 282
multiple input lists, using 280, 281
using 278
list methods 61
lists 59
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
zipping, with zip() 79
logging 247
in debug category 248
in info category 248
logging cookbook
reference link 253
logging module
logging stack
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
components 43
for loops 50
programs, writing 46
running, by time elapsed calculation 233
lower-level modules 219
examples 220
lru_cache
using, to speed up code 267-270
M
machine learning (ML)
using, to predict customer return rate accuracy 479, 480
computation time, for large matrices 390
nested list, using to store data from 66, 67
matrix operations 68
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
overriding, with super() 207, 208
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
multiple lists
used, for building scorecard 284
multiple variables 15
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
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
Not a Number (NaN) 405
not operator 35
null values 414
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
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
reference link 539
PEG parser 535
reference link 535
PEP 1 529
PEP 8 529
PEP 11 529
PEP 602 529
PEP 678
perfect squares
Person class
Pet class
extending, with class methods 192, 193
instance method, adding 183
Pi
random numbers, using to find value of 297-299
pie chart
Titanic dataset, visualizing with 168-170
pip package
distribution with multiple files, creating 323-325
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
prime numbers list
Cython, adopting to find time taken to obtain 369-371
creating, that writes to stderr 272, 273
process information
production
programs
writing 46
writing, for real estate offer 48-50
writing, to identify perfect squares 47, 48
properties 193
validation, via setter method 198, 199
pseudocode 99
pull request workflow 341
pulsar dataset
pulsar percentage
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
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
tests, writing with unit testing 318
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
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
linear_regression, computing 541
parenthesized context managers 539
type union operator (|) 540
Python 3.11 541
enhanced errors, in tracebacks 541-543
required keys in dicts 544
runtime 541
maximum number, finding with 99, 100
Python code
Python code application
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
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
building 459
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
terminating case 117
regression 430
regression line
regression test 316
regular expressions
features 299
text, matching with 300
using, to replace text 301
winner, finding for X-Files 301, 302
technique 509
reStructuredText PEP Template
reference link 528
reStructuredText (RST) 327
ridge 452
runtime documentation 247
S
salary calculator
scatter plots 424
creating, for Boston Housing dataset 425, 426
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
sets 80
operations, implementing 83-85
shebangs
in Ubuntu 93
shopping list
shopping list data
shutil 240
Sieve
generating 296
Signal to Noise Ratio (SNR) 463
skewed data 385
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
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
navigating 220
need for 216
reference link 220
instance methods, refactoring with 189, 190
statistical graphs
creating 418
StatsModel
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
strings 18
comparing 39
comparing, with comparison operators 39
escape sequence 20
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
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()
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
text file
data and time, recording with content creation 142, 143
partial content, reading from 140, 141
threading package
multiprocessing with 360
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
timestamps 226
time.time function 233
Time Zone Database
reference link 535
time zones
timsort 222
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
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
Unix time 230
upstream repository 341
UTC time zone 231
V
variable assignment 11
inside, versus outside 128-130
scope 127
shortcut, for incrementing by 1 12
violin plots 434
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
words
counting, in text document 258, 259
X
X-Files
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