100% found this document useful (1 vote)
34 views106 pages

Python Data Analytics: With Pandas, NumPy, and Matplotlib, 3rd Edition Fabio Nelli No Waiting Time

Learning content: Python Data Analytics: With Pandas, NumPy, and Matplotlib, 3rd Edition Fabio NelliImmediate access available. Includes detailed coverage of core topics with educational depth and clarity.

Uploaded by

zofiajus4942
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
34 views106 pages

Python Data Analytics: With Pandas, NumPy, and Matplotlib, 3rd Edition Fabio Nelli No Waiting Time

Learning content: Python Data Analytics: With Pandas, NumPy, and Matplotlib, 3rd Edition Fabio NelliImmediate access available. Includes detailed coverage of core topics with educational depth and clarity.

Uploaded by

zofiajus4942
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 106

Python Data Analytics: With Pandas, NumPy, and

Matplotlib, 3rd Edition Fabio Nelli digital download

Now on sale at ebookmass.com


https://ebookmass.com/product/python-data-analytics-with-pandas-
numpy-and-matplotlib-3rd-edition-fabio-nelli/

★★★★★
4.7 out of 5.0 (16 reviews )

Download PDF Now


Python Data Analytics: With Pandas, NumPy, and Matplotlib,
3rd Edition Fabio Nelli

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


Here are some recommended products for you. Click the link to
download, or explore more at ebookmass.com

Python Data Analytics: With Pandas, NumPy, and Matplotlib,


3rd Edition Fabio Nelli

https://ebookmass.com/product/python-data-analytics-with-pandas-numpy-
and-matplotlib-3rd-edition-fabio-nelli/

Machine Learning with Python for Everyone (Addison Wesley


Data & Analytics Series) 1st Edition, (Ebook PDF)

https://ebookmass.com/product/machine-learning-with-python-for-
everyone-addison-wesley-data-analytics-series-1st-edition-ebook-pdf/

Advanced Data Analytics Using Python : With Architectural


Patterns, Text and Image Classification, and Optimization
Techniques 2nd Edition Sayan Mukhopadhyay
https://ebookmass.com/product/advanced-data-analytics-using-python-
with-architectural-patterns-text-and-image-classification-and-
optimization-techniques-2nd-edition-sayan-mukhopadhyay/

Data-Driven SEO with Python: Solve SEO Challenges with


Data Science Using Python 1st Edition Andreas Voniatis

https://ebookmass.com/product/data-driven-seo-with-python-solve-seo-
challenges-with-data-science-using-python-1st-edition-andreas-
voniatis/
Data Mining for Business Analytics: Concepts, Techniques
and Applications in Python eBook

https://ebookmass.com/product/data-mining-for-business-analytics-
concepts-techniques-and-applications-in-python-ebook/

Data Quality: Empowering Businesses with Analytics and AI


Prashanth Southekal

https://ebookmass.com/product/data-quality-empowering-businesses-with-
analytics-and-ai-prashanth-southekal/

ISE Data Analytics for Accounting 3rd Edition Vernon


Richardson Professor

https://ebookmass.com/product/ise-data-analytics-for-accounting-3rd-
edition-vernon-richardson-professor/

Data Science from Scratch: First Principles with Python


2nd Edition

https://ebookmass.com/product/data-science-from-scratch-first-
principles-with-python-2nd-edition/

Health Analytics with Python: A Comprehensive Guide for


2024 Van Der Post

https://ebookmass.com/product/health-analytics-with-python-a-
comprehensive-guide-for-2024-van-der-post/
Python Data Analytics
With Pandas, NumPy, and Matplotlib

Third Edition

Fabio Nelli
Python Data Analytics: With Pandas, NumPy, and Matplotlib
Fabio Nelli
Rome, Italy

ISBN-13 (pbk): 978-1-4842-9531-1 ISBN-13 (electronic): 978-1-4842-9532-8


https://doi.org/10.1007/978-1-4842-9532-8

Copyright © 2023 by Fabio Nelli


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Celestin Suresh John
Development Editor: James Markham
Coordinating Editor: Mark Powers
Copy Editor: Kezia Endsley
Cover image by Tyler B on Unsplash (www.unsplash.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail [email protected]; for reprint,
paperback, or audio rights, please e-mail [email protected].
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to readers
on GitHub (github.com/apress). For more detailed information, please visit https://www.apress.com/
gp/services/source-code.
Paper in this product is recyclable
“Science leads us forward in knowledge, but only analysis makes us more aware”

This book is dedicated to all those who are constantly looking for awareness
Table of Contents

About the Author���������������������������������������������������������������������������������������������������xvii


About the Technical Reviewer��������������������������������������������������������������������������������xix
Preface�������������������������������������������������������������������������������������������������������������������xxi


■Chapter 1: An Introduction to Data Analysis��������������������������������������������������������� 1
Data Analysis�������������������������������������������������������������������������������������������������������������������� 1
Knowledge Domains of the Data Analyst������������������������������������������������������������������������� 2
Computer Science���������������������������������������������������������������������������������������������������������������������������������� 2
Mathematics and Statistics�������������������������������������������������������������������������������������������������������������������� 3
Machine Learning and Artificial Intelligence������������������������������������������������������������������������������������������ 3
Professional Fields of Application����������������������������������������������������������������������������������������������������������� 3

Understanding the Nature of the Data������������������������������������������������������������������������������ 4


When the Data Become Information������������������������������������������������������������������������������������������������������� 4
When the Information Becomes Knowledge������������������������������������������������������������������������������������������� 4
Types of Data������������������������������������������������������������������������������������������������������������������������������������������ 4

The Data Analysis Process����������������������������������������������������������������������������������������������� 4


Problem Definition���������������������������������������������������������������������������������������������������������������������������������� 5
Data Extraction��������������������������������������������������������������������������������������������������������������������������������������� 6
Data Preparation������������������������������������������������������������������������������������������������������������������������������������� 6
Data Exploration/Visualization���������������������������������������������������������������������������������������������������������������� 7
Predictive Modeling�������������������������������������������������������������������������������������������������������������������������������� 7
Model Validation������������������������������������������������������������������������������������������������������������������������������������� 8
Deployment�������������������������������������������������������������������������������������������������������������������������������������������� 8

v
■ Table of Contents

Quantitative and Qualitative Data Analysis����������������������������������������������������������������������� 9


Open Data������������������������������������������������������������������������������������������������������������������������� 9
Python and Data Analysis����������������������������������������������������������������������������������������������� 12
Conclusions�������������������������������������������������������������������������������������������������������������������� 13

■Chapter 2: Introduction to the Python World������������������������������������������������������ 15
Python—The Programming Language��������������������������������������������������������������������������� 15
The Interpreter and the Execution Phases of the Code������������������������������������������������������������������������ 16
Installing Python������������������������������������������������������������������������������������������������������������� 18
Python Distributions����������������������������������������������������������������������������������������������������������������������������� 19
Using Python����������������������������������������������������������������������������������������������������������������������������������������� 23
Writing Python Code����������������������������������������������������������������������������������������������������������������������������� 26
IPython�������������������������������������������������������������������������������������������������������������������������������������������������� 30

PyPI—The Python Package Index���������������������������������������������������������������������������������� 36


The IDEs for Python������������������������������������������������������������������������������������������������������������������������������ 37

SciPy������������������������������������������������������������������������������������������������������������������������������ 42
NumPy�������������������������������������������������������������������������������������������������������������������������������������������������� 42
Pandas�������������������������������������������������������������������������������������������������������������������������������������������������� 43
matplotlib��������������������������������������������������������������������������������������������������������������������������������������������� 43

Conclusions�������������������������������������������������������������������������������������������������������������������� 43

■Chapter 3: The NumPy Library����������������������������������������������������������������������������� 45
NumPy: A Little History��������������������������������������������������������������������������������������������������� 45
The NumPy Installation�������������������������������������������������������������������������������������������������� 46
ndarray: The Heart of the Library����������������������������������������������������������������������������������� 47
Create an Array������������������������������������������������������������������������������������������������������������������������������������� 48
Types of Data���������������������������������������������������������������������������������������������������������������������������������������� 49
The dtype Option���������������������������������������������������������������������������������������������������������������������������������� 50
Intrinsic Creation of an Array���������������������������������������������������������������������������������������������������������������� 50

Basic Operations������������������������������������������������������������������������������������������������������������ 51
Arithmetic Operators���������������������������������������������������������������������������������������������������������������������������� 52
The Matrix Product������������������������������������������������������������������������������������������������������������������������������� 53

vi
■ Table of Contents

Increment and Decrement Operators��������������������������������������������������������������������������������������������������� 54


Universal Functions (ufunc)������������������������������������������������������������������������������������������������������������������ 54
Aggregate Functions���������������������������������������������������������������������������������������������������������������������������� 55

Indexing, Slicing, and Iterating��������������������������������������������������������������������������������������� 55


Indexing������������������������������������������������������������������������������������������������������������������������������������������������ 55
Slicing��������������������������������������������������������������������������������������������������������������������������������������������������� 57
Iterating an Array���������������������������������������������������������������������������������������������������������������������������������� 59

Conditions and Boolean Arrays�������������������������������������������������������������������������������������� 60


Shape Manipulation������������������������������������������������������������������������������������������������������� 61
Array Manipulation��������������������������������������������������������������������������������������������������������� 62
Joining Arrays��������������������������������������������������������������������������������������������������������������������������������������� 62
Splitting Arrays������������������������������������������������������������������������������������������������������������������������������������� 63

General Concepts����������������������������������������������������������������������������������������������������������� 64
Copies or Views of Objects������������������������������������������������������������������������������������������������������������������� 64
Vectorization����������������������������������������������������������������������������������������������������������������������������������������� 65
Broadcasting���������������������������������������������������������������������������������������������������������������������������������������� 66

Structured Arrays����������������������������������������������������������������������������������������������������������� 68
Reading and Writing Array Data on Files������������������������������������������������������������������������ 70
Loading and Saving Data in Binary Files���������������������������������������������������������������������������������������������� 70
Reading Files with Tabular Data����������������������������������������������������������������������������������������������������������� 70

Conclusions�������������������������������������������������������������������������������������������������������������������� 72

■Chapter 4: The pandas Library—An Introduction������������������������������������������������ 73
pandas: The Python Data Analysis Library��������������������������������������������������������������������� 73
Installation of pandas����������������������������������������������������������������������������������������������������� 74
Installation from Anaconda������������������������������������������������������������������������������������������������������������������� 74
Installation from PyPI���������������������������������������������������������������������������������������������������������������������������� 78

Getting Started with pandas������������������������������������������������������������������������������������������� 78


Introduction to pandas Data Structures������������������������������������������������������������������������� 79

vii
■ Table of Contents

The Series��������������������������������������������������������������������������������������������������������������������������������������������� 80
The Dataframe�������������������������������������������������������������������������������������������������������������������������������������� 87
The Index Objects��������������������������������������������������������������������������������������������������������������������������������� 94

Other Functionalities on Indexes������������������������������������������������������������������������������������ 96


Reindexing�������������������������������������������������������������������������������������������������������������������������������������������� 96
Dropping����������������������������������������������������������������������������������������������������������������������������������������������� 98
Arithmetic and Data Alignment������������������������������������������������������������������������������������������������������������� 99

Operations Between Data Structures��������������������������������������������������������������������������� 100


Flexible Arithmetic Methods��������������������������������������������������������������������������������������������������������������� 100
Operations Between Dataframes and Series�������������������������������������������������������������������������������������� 101

Function Application and Mapping������������������������������������������������������������������������������� 102


Functions by Element������������������������������������������������������������������������������������������������������������������������� 102
Functions by Row or Column�������������������������������������������������������������������������������������������������������������� 102
Statistics Functions���������������������������������������������������������������������������������������������������������������������������� 103

Sorting and Ranking����������������������������������������������������������������������������������������������������� 104


Correlation and Covariance������������������������������������������������������������������������������������������ 107
“Not a Number” Data��������������������������������������������������������������������������������������������������� 108
Assigning a NaN Value������������������������������������������������������������������������������������������������������������������������ 108
Filtering Out NaN Values��������������������������������������������������������������������������������������������������������������������� 109
Filling in NaN Occurrences����������������������������������������������������������������������������������������������������������������� 110

Hierarchical Indexing and Leveling������������������������������������������������������������������������������ 110


Reordering and Sorting Levels����������������������������������������������������������������������������������������������������������� 112
Summary Statistics with groupby Instead of with Level�������������������������������������������������������������������� 113

Conclusions������������������������������������������������������������������������������������������������������������������ 114

■Chapter 5: pandas: Reading and Writing Data��������������������������������������������������� 115
I/O API Tools������������������������������������������������������������������������������������������������������������������ 115
CSV and Textual Files��������������������������������������������������������������������������������������������������� 116
Reading Data in CSV or Text Files��������������������������������������������������������������������������������� 116
Using Regexp to Parse TXT Files�������������������������������������������������������������������������������������������������������� 119
Reading TXT Files Into Parts��������������������������������������������������������������������������������������������������������������� 121
Writing Data in CSV���������������������������������������������������������������������������������������������������������������������������� 121
viii
■ Table of Contents

Reading and Writing HTML Files���������������������������������������������������������������������������������� 123


Writing Data in HTML�������������������������������������������������������������������������������������������������������������������������� 124
Reading Data from an HTML File�������������������������������������������������������������������������������������������������������� 126

Reading Data from XML����������������������������������������������������������������������������������������������� 127


Reading and Writing Data on Microsoft Excel Files������������������������������������������������������ 129
JSON Data�������������������������������������������������������������������������������������������������������������������� 131
The HDF5 Format��������������������������������������������������������������������������������������������������������� 135
Pickle—Python Object Serialization����������������������������������������������������������������������������� 136
Serialize a Python Object with cPickle����������������������������������������������������������������������������������������������� 136
Pickling with pandas�������������������������������������������������������������������������������������������������������������������������� 137

Interacting with Databases������������������������������������������������������������������������������������������ 137


Loading and Writing Data with SQLite3���������������������������������������������������������������������������������������������� 138
Loading and Writing Data with PostgreSQL in a Docker Container���������������������������������������������������� 140

Reading and Writing Data with a NoSQL Database: MongoDB������������������������������������� 146


Conclusions������������������������������������������������������������������������������������������������������������������ 148

■Chapter 6: pandas in Depth: Data Manipulation������������������������������������������������ 149
Data Preparation���������������������������������������������������������������������������������������������������������� 149
Merging���������������������������������������������������������������������������������������������������������������������������������������������� 150

Concatenating�������������������������������������������������������������������������������������������������������������� 154
Combining������������������������������������������������������������������������������������������������������������������������������������������ 156
Pivoting����������������������������������������������������������������������������������������������������������������������������������������������� 157
Removing�������������������������������������������������������������������������������������������������������������������������������������������� 160

Data Transformation����������������������������������������������������������������������������������������������������� 161


Removing Duplicates�������������������������������������������������������������������������������������������������������������������������� 161
Mapping���������������������������������������������������������������������������������������������������������������������������������������������� 162

Discretization and Binning������������������������������������������������������������������������������������������� 166


Detecting and Filtering Outliers���������������������������������������������������������������������������������������������������������� 168

Permutation������������������������������������������������������������������������������������������������������������������ 169
Random Sampling������������������������������������������������������������������������������������������������������������������������������ 170

ix
■ Table of Contents

String Manipulation������������������������������������������������������������������������������������������������������ 170


Built-in Methods for String Manipulation������������������������������������������������������������������������������������������� 170
Regular Expressions��������������������������������������������������������������������������������������������������������������������������� 172

Data Aggregation���������������������������������������������������������������������������������������������������������� 173


GroupBy���������������������������������������������������������������������������������������������������������������������������������������������� 174
A Practical Example���������������������������������������������������������������������������������������������������������������������������� 175
Hierarchical Grouping������������������������������������������������������������������������������������������������������������������������� 176
Group Iteration������������������������������������������������������������������������������������������������������������� 176
Chain of Transformations�������������������������������������������������������������������������������������������������������������������� 177
Functions on Groups��������������������������������������������������������������������������������������������������������������������������� 178

Advanced Data Aggregation����������������������������������������������������������������������������������������� 179


Conclusions������������������������������������������������������������������������������������������������������������������ 181

■Chapter 7: Data Visualization with matplotlib and Seaborn������������������������������ 183
The matplotlib Library�������������������������������������������������������������������������������������������������� 183
Installation�������������������������������������������������������������������������������������������������������������������� 184
The matplotlib Architecture������������������������������������������������������������������������������������������ 185
Backend Layer������������������������������������������������������������������������������������������������������������������������������������ 186
Artist Layer����������������������������������������������������������������������������������������������������������������������������������������� 186
Scripting Layer (pyplot)���������������������������������������������������������������������������������������������������������������������� 188
pylab and pyplot��������������������������������������������������������������������������������������������������������������������������������� 188

pyplot��������������������������������������������������������������������������������������������������������������������������� 189
The Plotting Window��������������������������������������������������������������������������������������������������������������������������� 189

Data Visualization with Jupyter Notebook�������������������������������������������������������������������� 191


Set the Properties of the Plot�������������������������������������������������������������������������������������������������������������� 192
matplotlib and NumPy������������������������������������������������������������������������������������������������������������������������ 194

Using kwargs���������������������������������������������������������������������������������������������������������������� 196


Working with Multiple Figures and Axes�������������������������������������������������������������������������������������������� 196

Adding Elements to the Chart��������������������������������������������������������������������������������������� 198


Adding Text����������������������������������������������������������������������������������������������������������������������������������������� 198
Adding a Grid�������������������������������������������������������������������������������������������������������������������������������������� 202
Adding a Legend��������������������������������������������������������������������������������������������������������������������������������� 203
x
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
■ Table of Contents

Saving Your Charts������������������������������������������������������������������������������������������������������� 206


Saving the Code���������������������������������������������������������������������������������������������������������������������������������� 206
Saving Your Notebook as an HTML File or as Other File Formats������������������������������������������������������� 207
Saving Your Chart Directly as an Image���������������������������������������������������������������������������������������������� 208

Handling Date Values��������������������������������������������������������������������������������������������������� 208


Chart Typology�������������������������������������������������������������������������������������������������������������� 211
Line Charts������������������������������������������������������������������������������������������������������������������� 211
Line Charts with pandas��������������������������������������������������������������������������������������������������������������������� 217

Histograms������������������������������������������������������������������������������������������������������������������� 218
Bar Charts�������������������������������������������������������������������������������������������������������������������� 219
Horizontal Bar Charts�������������������������������������������������������������������������������������������������������������������������� 222
Multiserial Bar Charts������������������������������������������������������������������������������������������������������������������������� 223
Multiseries Bar Charts with a pandas Dataframe������������������������������������������������������������������������������� 225
Multiseries Stacked Bar Charts���������������������������������������������������������������������������������������������������������� 227
Stacked Bar Charts with a pandas Dataframe������������������������������������������������������������������������������������ 229
Other Bar Chart Representations�������������������������������������������������������������������������������������������������������� 230

Pie Charts��������������������������������������������������������������������������������������������������������������������� 231


Pie Charts with a pandas Dataframe�������������������������������������������������������������������������������������������������� 234

Advanced Charts���������������������������������������������������������������������������������������������������������� 235


Contour Plots�������������������������������������������������������������������������������������������������������������������������������������� 235
Polar Charts���������������������������������������������������������������������������������������������������������������������������������������� 236

The mplot3d Toolkit������������������������������������������������������������������������������������������������������ 237


3D Surfaces���������������������������������������������������������������������������������������������������������������������������������������� 238
Scatter Plots in 3D������������������������������������������������������������������������������������������������������������������������������ 239
Bar Charts in 3D��������������������������������������������������������������������������������������������������������������������������������� 240

Multipanel Plots������������������������������������������������������������������������������������������������������������ 241


Display Subplots Within Other Subplots��������������������������������������������������������������������������������������������� 241
Grids of Subplots�������������������������������������������������������������������������������������������������������������������������������� 243

The Seaborn Library����������������������������������������������������������������������������������������������������� 245


Conclusions������������������������������������������������������������������������������������������������������������������ 257

xi
■ Table of Contents


■Chapter 8: Machine Learning with scikit-learn������������������������������������������������� 259
The scikit-learn Library������������������������������������������������������������������������������������������������ 259
Machine Learning��������������������������������������������������������������������������������������������������������� 259
Supervised and Unsupervised Learning��������������������������������������������������������������������������������������������� 259
Training Set and Testing Set��������������������������������������������������������������������������������������������������������������� 260

Supervised Learning with scikit-learn������������������������������������������������������������������������� 260


The Iris Flower Dataset������������������������������������������������������������������������������������������������ 261
The PCA Decomposition��������������������������������������������������������������������������������������������������������������������� 264

K-Nearest Neighbors Classifier������������������������������������������������������������������������������������ 267


Diabetes Dataset���������������������������������������������������������������������������������������������������������� 271
Linear Regression: The Least Square Regression�������������������������������������������������������� 272
Support Vector Machines (SVMs)��������������������������������������������������������������������������������� 276
Support Vector Classification (SVC)���������������������������������������������������������������������������������������������������� 277
Nonlinear SVC������������������������������������������������������������������������������������������������������������������������������������� 281
Plotting Different SVM Classifiers Using the Iris Dataset�������������������������������������������������������������������� 283
Support Vector Regression (SVR)�������������������������������������������������������������������������������������������������������� 285

Conclusions������������������������������������������������������������������������������������������������������������������ 287

■Chapter 9: Deep Learning with TensorFlow������������������������������������������������������� 289
Artificial Intelligence, Machine Learning, and Deep Learning�������������������������������������� 289
Artificial Intelligence��������������������������������������������������������������������������������������������������������������������������� 289
Machine Learning Is a Branch of Artificial Intelligence���������������������������������������������������������������������� 290
Deep Learning Is a Branch of Machine Learning�������������������������������������������������������������������������������� 290
The Relationship Between Artificial Intelligence, Machine Learning, and Deep Learning������������������ 290

Deep Learning�������������������������������������������������������������������������������������������������������������� 291


Neural Networks and GPUs����������������������������������������������������������������������������������������������������������������� 291
Data Availability: Open Data Source, Internet of Things, and Big Data����������������������������������������������� 292
Python������������������������������������������������������������������������������������������������������������������������������������������������� 292
Deep Learning Python Frameworks��������������������������������������������������������������������������������������������������� 292

Artificial Neural Networks�������������������������������������������������������������������������������������������� 293

xii
■ Table of Contents

How Artificial Neural Networks Are Structured���������������������������������������������������������������������������������� 293


Single Layer Perceptron (SLP)������������������������������������������������������������������������������������������������������������ 294
Multilayer Perceptron (MLP)��������������������������������������������������������������������������������������������������������������� 296
Correspondence Between Artificial and Biological Neural Networks������������������������������������������������� 297

TensorFlow������������������������������������������������������������������������������������������������������������������� 298
TensorFlow: Google’s Framework������������������������������������������������������������������������������������������������������� 298
TensorFlow: Data Flow Graph������������������������������������������������������������������������������������������������������������� 298

Start Programming with TensorFlow���������������������������������������������������������������������������� 299


TensorFlow 2.x vs TensorFlow 1.x������������������������������������������������������������������������������������������������������ 299
Installing TensorFlow�������������������������������������������������������������������������������������������������������������������������� 300
Programming with the Jupyter Notebook������������������������������������������������������������������������������������������� 300
Tensors����������������������������������������������������������������������������������������������������������������������������������������������� 300
Loading Data Into a Tensor from a pandas Dataframe����������������������������������������������������������������������� 303
Loading Data in a Tensor from a CSV File������������������������������������������������������������������������������������������� 304
Operation on Tensors�������������������������������������������������������������������������������������������������������������������������� 306

Developing a Deep Learning Model with TensorFlow��������������������������������������������������� 307


Model Building������������������������������������������������������������������������������������������������������������� 307
Model Compiling���������������������������������������������������������������������������������������������������������� 308
Model Training and Testing������������������������������������������������������������������������������������������� 309
Prediction Making�������������������������������������������������������������������������������������������������������� 309
Practical Examples with TensorFlow 2.x���������������������������������������������������������������������� 310
Single Layer Perceptron with TensorFlow������������������������������������������������������������������������������������������ 310
Multilayer Perceptron (with One Hidden Layer) with TensorFlow������������������������������������������������������� 317
Multilayer Perceptron (with Two Hidden Layers) with TensorFlow����������������������������������������������������� 319

Conclusions������������������������������������������������������������������������������������������������������������������ 321

■Chapter 10: An Example—Meteorological Data������������������������������������������������ 323
A Hypothesis to Be Tested: The Influence of the Proximity of the Sea������������������������� 323
The System in the Study: The Adriatic Sea and the Po Valley������������������������������������������������������������� 323

Finding the Data Source����������������������������������������������������������������������������������������������� 327


Data Analysis on Jupyter Notebook������������������������������������������������������������������������������ 328

xiii
■ Table of Contents

Analysis of Processed Meteorological Data����������������������������������������������������������������� 332


The RoseWind�������������������������������������������������������������������������������������������������������������� 343
Calculating the Mean Distribution of the Wind Speed������������������������������������������������������������������������ 347

Conclusions������������������������������������������������������������������������������������������������������������������ 348

■Chapter 11: Embedding the JavaScript D3 Library in the IPython Notebook���� 349
The Open Data Source for Demographics�������������������������������������������������������������������� 349
The JavaScript D3 Library�������������������������������������������������������������������������������������������� 352
Drawing a Clustered Bar Chart������������������������������������������������������������������������������������� 355
The Choropleth Maps��������������������������������������������������������������������������������������������������� 358
The Choropleth Map of the U.S. Population in 2022����������������������������������������������������� 362
Conclusions������������������������������������������������������������������������������������������������������������������ 366

■Chapter 12: Recognizing Handwritten Digits���������������������������������������������������� 367
Handwriting Recognition���������������������������������������������������������������������������������������������� 367
Recognizing Handwritten Digits with scikit-learn�������������������������������������������������������� 367
The Digits Dataset�������������������������������������������������������������������������������������������������������� 368
Learning and Predicting����������������������������������������������������������������������������������������������� 370
Recognizing Handwritten Digits with TensorFlow�������������������������������������������������������� 372
Learning and Predicting with an SLP��������������������������������������������������������������������������� 376
Learning and Predicting with an MLP�������������������������������������������������������������������������� 381
Conclusions������������������������������������������������������������������������������������������������������������������ 384

■Chapter 13: Textual Data Analysis with NLTK���������������������������������������������������� 385
Text Analysis Techniques���������������������������������������������������������������������������������������������� 385
The Natural Language Toolkit (NLTK)�������������������������������������������������������������������������������������������������� 386
Import the NLTK Library and the NLTK Downloader Tool��������������������������������������������������������������������� 386
Search for a Word with NLTK�������������������������������������������������������������������������������������������������������������� 389
Analyze the Frequency of Words�������������������������������������������������������������������������������������������������������� 390
Select Words from Text����������������������������������������������������������������������������������������������������������������������� 392
Bigrams and Collocations������������������������������������������������������������������������������������������������������������������� 393
Preprocessing Steps��������������������������������������������������������������������������������������������������������������������������� 394

xiv
■ Table of Contents

Use Text on the Network��������������������������������������������������������������������������������������������������������������������� 397


Extract the Text from the HTML Pages������������������������������������������������������������������������������������������������ 398
Sentiment Analysis����������������������������������������������������������������������������������������������������������������������������� 399

Conclusions������������������������������������������������������������������������������������������������������������������ 401

■Chapter 14: Image Analysis and Computer Vision with OpenCV����������������������� 403
Image Analysis and Computer Vision��������������������������������������������������������������������������� 403
OpenCV and Python������������������������������������������������������������������������������������������������������ 404
OpenCV and Deep Learning������������������������������������������������������������������������������������������ 404
Installing OpenCV��������������������������������������������������������������������������������������������������������� 404
First Approaches to Image Processing and Analysis���������������������������������������������������� 404
Before Starting����������������������������������������������������������������������������������������������������������������������������������� 404
Load and Display an Image���������������������������������������������������������������������������������������������������������������� 405
Work with Images������������������������������������������������������������������������������������������������������������������������������� 406
Save the New Image��������������������������������������������������������������������������������������������������������������������������� 407
Elementary Operations on Images������������������������������������������������������������������������������������������������������ 407
Image Blending����������������������������������������������������������������������������������������������������������������������������������� 411

Image Analysis������������������������������������������������������������������������������������������������������������� 412


Edge Detection and Image Gradient Analysis��������������������������������������������������������������� 413
Edge Detection����������������������������������������������������������������������������������������������������������������������������������� 413
The Image Gradient Theory���������������������������������������������������������������������������������������������������������������� 413
A Practical Example of Edge Detection with the Image Gradient Analysis����������������������������������������� 415
A Deep Learning Example: Face Detection������������������������������������������������������������������� 420
Conclusions������������������������������������������������������������������������������������������������������������������ 422

■Appendix A: Writing Mathematical Expressions with LaTeX����������������������������� 423


■Appendix B: Open Data Sources������������������������������������������������������������������������ 435

Index��������������������������������������������������������������������������������������������������������������������� 437

xv
Random documents with unrelated
content Scribd suggests to you:
Microbiology - Lecture Notes
Winter 2024 - Division

Prepared by: Dr. Johnson


Date: August 12, 2025

Part 1: Theoretical framework and methodology


Learning Objective 1: Case studies and real-world applications
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Learning Objective 2: Theoretical framework and methodology
• Theoretical framework and methodology
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 2: Diagram/Chart/Graph]
Learning Objective 3: Fundamental concepts and principles
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Learning Objective 4: Case studies and real-world applications
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Learning Objective 5: Experimental procedures and results
• Ethical considerations and implications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Key terms and definitions
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Practice Problem 6: Learning outcomes and objectives
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Important: Practical applications and examples
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Critical analysis and evaluation
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Key terms and definitions
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
[Figure 10: Diagram/Chart/Graph]
Discussion 2: Critical analysis and evaluation
Note: Fundamental concepts and principles
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 11: Diagram/Chart/Graph]
Key Concept: Experimental procedures and results
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Remember: Practical applications and examples
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Important: Statistical analysis and interpretation
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Note: Interdisciplinary approaches
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Research findings and conclusions
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 16: Research findings and conclusions
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Important: Best practices and recommendations
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Key Concept: Research findings and conclusions
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Important: Theoretical framework and methodology
• Literature review and discussion
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Unit 3: Problem-solving strategies and techniques
Example 20: Literature review and discussion
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Theoretical framework and methodology
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 22: Best practices and recommendations
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 23: Diagram/Chart/Graph]
Important: Comparative analysis and synthesis
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Experimental procedures and results
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Remember: Best practices and recommendations
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Definition: Practical applications and examples
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Literature review and discussion
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Practical applications and examples
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Key Concept: Experimental procedures and results
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 30: Diagram/Chart/Graph]
Conclusion 4: Fundamental concepts and principles
Remember: Ethical considerations and implications
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Learning outcomes and objectives
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Key Concept: Problem-solving strategies and techniques
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 33: Diagram/Chart/Graph]
Remember: Theoretical framework and methodology
• Theoretical framework and methodology
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Key Concept: Interdisciplinary approaches
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
[Figure 35: Diagram/Chart/Graph]
Example 35: Interdisciplinary approaches
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Experimental procedures and results
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Experimental procedures and results
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 38: Diagram/Chart/Graph]
Definition: Historical development and evolution
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 39: Theoretical framework and methodology
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 40: Diagram/Chart/Graph]
Conclusion 5: Research findings and conclusions
Remember: Practical applications and examples
• Interdisciplinary approaches
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Practice Problem 41: Research findings and conclusions
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Example 42: Practical applications and examples
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Note: Historical development and evolution
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Important: Study tips and learning strategies
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Practice Problem 45: Key terms and definitions
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 46: Ethical considerations and implications
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Problem-solving strategies and techniques
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Historical development and evolution
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 49: Current trends and future directions
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Module 6: Study tips and learning strategies
Definition: Current trends and future directions
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 51: Statistical analysis and interpretation
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Key Concept: Interdisciplinary approaches
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Important: Best practices and recommendations
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 54: Diagram/Chart/Graph]
Key Concept: Literature review and discussion
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Definition: Critical analysis and evaluation
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 56: Diagram/Chart/Graph]
Note: Fundamental concepts and principles
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
[Figure 57: Diagram/Chart/Graph]
Remember: Statistical analysis and interpretation
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Practice Problem 58: Case studies and real-world applications
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 59: Diagram/Chart/Graph]
Key Concept: Literature review and discussion
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Introduction 7: Comparative analysis and synthesis
Key Concept: Current trends and future directions
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
[Figure 61: Diagram/Chart/Graph]
Example 61: Theoretical framework and methodology
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 62: Case studies and real-world applications
• Comparative analysis and synthesis
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Important: Interdisciplinary approaches
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Note: Historical development and evolution
• Learning outcomes and objectives
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Example 65: Research findings and conclusions
• Critical analysis and evaluation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 66: Statistical analysis and interpretation
• Assessment criteria and rubrics
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 67: Diagram/Chart/Graph]
Note: Literature review and discussion
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Remember: Study tips and learning strategies
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
[Figure 69: Diagram/Chart/Graph]
Practice Problem 69: Case studies and real-world applications
• Case studies and real-world applications
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Test 8: Problem-solving strategies and techniques
Note: Research findings and conclusions
• Historical development and evolution
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Key Concept: Fundamental concepts and principles
• Research findings and conclusions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Example 72: Best practices and recommendations
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Definition: Key terms and definitions
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Note: Fundamental concepts and principles
• Fundamental concepts and principles
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Note: Theoretical framework and methodology
• Statistical analysis and interpretation
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Comparative analysis and synthesis
• Theoretical framework and methodology
- Sub-point: Additional details and explanations
- Example: Practical application scenario
Formula: [Mathematical expression or equation]
Example 77: Comparative analysis and synthesis
• Best practices and recommendations
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
[Figure 78: Diagram/Chart/Graph]
Note: Theoretical framework and methodology
• Key terms and definitions
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
Practice Problem 79: Learning outcomes and objectives
• Experimental procedures and results
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 80: Diagram/Chart/Graph]
Quiz 9: Research findings and conclusions
Important: Key terms and definitions
• Problem-solving strategies and techniques
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Definition: Problem-solving strategies and techniques
• Study tips and learning strategies
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Formula: [Mathematical expression or equation]
[Figure 82: Diagram/Chart/Graph]
Practice Problem 82: Statistical analysis and interpretation
• Practical applications and examples
- Sub-point: Additional details and explanations
- Example: Practical application scenario
- Note: Important consideration
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmass.com

You might also like