Title Page Copyright Numerical Computing with Python Contributors About the authors About the reviewers Packt is searching for authors like you About Packt Why subscribe? Packt.com Preface Who this book is for What this book covers To get the most out of this book Download the example code files Conventions used Get in touch Reviews Journey from Statistics to Machine Learning Statistical terminology for model building and validation Machine learning Statistical fundamentals and terminology for model building and validation Bias versus variance trade-off Train and test data Summary Tree-Based Machine Learning Models Introducing decision tree classifiers Terminology used in decision trees Decision tree working methodology from first principles Comparison between logistic regression and decision trees Comparison of error components across various styles of models Remedial actions to push the model towards the ideal region HR attrition data example Decision tree classifier Tuning class weights in decision tree classifier Bagging classifier Random forest classifier Random forest classifier - grid search AdaBoost classifier Gradient boosting classifier Comparison between AdaBoosting versus gradient boosting Extreme gradient boosting - XGBoost classifier Ensemble of ensembles - model stacking Ensemble of ensembles with different types of classifiers Ensemble of ensembles with bootstrap samples using a single type of classifier Summary K-Nearest Neighbors and Naive Bayes K-nearest neighbors KNN voter example Curse of dimensionality Curse of dimensionality with 1D, 2D, and 3D example KNN classifier with breast cancer Wisconsin data example Tuning of k-value in KNN classifier Naive Bayes Probability fundamentals Joint probability Understanding Bayes theorem with conditional probability Naive Bayes classification Laplace estimator Naive Bayes SMS spam classification example Summary Unsupervised Learning K-means clustering K-means working methodology from first principles Optimal number of clusters and cluster evaluation The elbow method K-means clustering with the iris data example Principal Component Analysis - PCA PCA working methodology from first principles PCA applied on handwritten digits using scikit-learn Singular value decomposition - SVD SVD applied on handwritten digits using scikit-learn Deep auto encoders Model building technique using encoder-decoder architecture Deep auto encoders applied on handwritten digits using Keras Summary Reinforcement Learning Reinforcement learning basics Category 1 - value based  Category 2 - policy based  Category 3 - actor-critic Category 4 - model-free Category 5 - model-based Fundamental categories in sequential decision making Markov decision processes and Bellman equations Dynamic programming Algorithms to compute optimal policy using dynamic programming Grid world example using value and policy iteration algorithms with basic Python Monte Carlo methods Monte Carlo prediction The suitability of Monte Carlo prediction on grid-world problems Modeling Blackjack example of Monte Carlo methods using Python Temporal difference learning TD prediction Driving office example for TD learning SARSA on-policy TD control Q-learning - off-policy TD control Cliff walking example of on-policy and off-policy of TD control Further reading Summary Hello Plotting World! Hello Matplotlib! What is Matplotlib? What's new in Matplotlib 2.0? Changes to the default style Color cycle Colormap Scatter plot Legend  Line style Patch edges and color Fonts Improved functionality or performance Improved color conversion API and RGBA support Improved image support Faster text rendering Change in the default animation codec Changes in settings New configuration parameters (rcParams) Style parameter blacklist Change in Axes property keywords Plotting our first graph Loading data for plotting Data structures List Numpy array pandas dataframe Loading data from files The basic Python way The Numpy way The pandas way Importing the Matplotlib pyplot module Plotting a curve Viewing the figure Saving the figure Setting the output format PNG (Portable Network Graphics) PDF (Portable Document Format) SVG (Scalable Vector Graphics) Post (Postscript) Adjusting the resolution Summary Visualizing Online Data Typical API data formats CSV JSON XML Introducing pandas Importing online population data in the CSV format Importing online financial data in the JSON format Visualizing the trend of data Area chart and stacked area chart Introducing Seaborn Visualizing univariate distribution Bar chart in Seaborn Histogram and distribution fitting in Seaborn Visualizing a bivariate distribution Scatter plot in Seaborn Visualizing categorical data Categorical scatter plot Strip plot and swarm plot Box plot and violin plot Controlling Seaborn figure aesthetics Preset themes Removing spines from the figure Changing the size of the figure Fine-tuning the style of the figure More about colors Color scheme and color palettes Summary Visualizing Multivariate Data Getting End-of-Day (EOD) stock data from Quandl Grouping the companies by industry Converting the date to a supported format Getting the percentage change of the closing price Two-dimensional faceted plots Factor plot in Seaborn Faceted grid in Seaborn Pair plot in Seaborn Other two-dimensional multivariate plots Heatmap in Seaborn Candlestick plot in matplotlib.finance Visualizing various stock market indicators Building a comprehensive stock chart Three-dimensional (3D) plots 3D scatter plot 3D bar chart Caveats of Matplotlib 3D Summary Adding Interactivity and Animating Plots Scraping information from websites Non-interactive backends Interactive backends Tkinter-based backend  Interactive backend for Jupyter Notebook  Plot.ly-based backend Creating animated plots Installation of FFmpeg Creating animations Summary Selecting Subsets of Data Selecting Series data Getting ready How to do it... How it works... There's more... See also Selecting DataFrame rows Getting ready How to do it... How it works... There's more... See also Selecting DataFrame rows and columns simultaneously Getting ready How to do it... How it works... There's more... Selecting data with both integers and labels Getting ready How to do it... How it works... There's more... Speeding up scalar selection Getting ready How to do it... How it works... There's more... Slicing rows lazily Getting ready How to do it... How it works... There's more... Slicing lexicographically Getting ready How to do it... How it works... There's more... Boolean Indexing Calculating boolean statistics Getting ready How to do it... How it works... There's more... Constructing multiple boolean conditions Getting ready How to do it... How it works... There's more... See also Filtering with boolean indexing Getting ready How to do it... How it works... There's more... See also Replicating boolean indexing with index selection Getting ready How to do it... How it works... There's more... Selecting with unique and sorted indexes Getting ready How to do it... How it works... There's more... See also Gaining perspective on stock prices Getting ready How to do it... How it works... There's more... Translating SQL WHERE clauses Getting ready How to do it... How it works... There's more... See also Determining the normality of stock market returns Getting ready How to do it... How it works... There's more... See also Improving readability of boolean indexing with the query method Getting ready How to do it... How it works... There's more... See also Preserving Series with the where method Getting ready How to do it... How it works... There's more... See also Masking DataFrame rows Getting ready How to do it... How it works... There's more... See also Selecting with booleans, integer location, and labels Getting ready How to do it... How it works... There's more... See also Index Alignment Examining the Index object Getting ready How to do it... How it works... There's more... See also Producing Cartesian products Getting ready How to do it... How it works... There's more... Exploding indexes Getting ready How to do it... How it works... There's more... Filling values with unequal indexes Getting ready How to do it... How it works... There's more... Appending columns from different DataFrames Getting ready How to do it... How it works... There's more... Highlighting the maximum value from each column Getting ready How to do it... How it works... There's more... See also Replicating idxmax with method chaining Getting ready How to do it... How it works... There's more... Finding the most common maximum Getting ready How to do it... How it works... There's more... Grouping for Aggregation, Filtration, and Transformation Defining an aggregation Getting ready How to do it... How it works... There's more... See also Grouping and aggregating with multiple columns and functions Getting ready How to do it... How it works... There's more... Removing the MultiIndex after grouping Getting ready How to do it... How it works... There's more... Customizing an aggregation function Getting ready How to do it... How it works... There's more... Customizing aggregating functions with *args and **kwargs Getting ready How to do it... How it works... There's more... See also Examining the groupby object Getting ready How to do it... How it works... There's more... See also Filtering for states with a minority majority Getting ready How to do it... How it works... There's more... See also Transforming through a weight loss bet Getting ready How to do it... How it works... There's more... See also Calculating weighted mean SAT scores per state with apply Getting ready How to do it... How it works... There's more... See also Grouping by continuous variables Getting ready How to do it... How it works... There's more... See also Counting the total number of flights between cities Getting ready How to do it... How it works... There's more... See also Finding the longest streak of on-time flights Getting ready How to do it... How it works... There's more... See also Restructuring Data into a Tidy Form Tidying variable values as column names with stack Getting ready How to do it... How it works... There's more... See also Tidying variable values as column names with melt Getting ready How to do it... How it works... There's more... See also Stacking multiple groups of variables simultaneously Getting ready How to do it... How it works... There's more... See also Inverting stacked data Getting ready How to do it... How it works... There's more... See also Unstacking after a groupby aggregation Getting ready How to do it... How it works... There's more... See also Replicating pivot_table with a groupby aggregation Getting ready How to do it... How it works... There's more... Renaming axis levels for easy reshaping Getting ready How to do it... How it works... There's more... Tidying when multiple variables are stored as column names Getting ready... How to do it... How it works... There's more... See also Tidying when multiple variables are stored as column values Getting ready How to do it... How it works... There's more... See also Tidying when two or more values are stored in the same cell Getting ready... How to do it... How it works... There's more... Tidying when variables are stored in column names and values Getting ready How to do it... How it works... There's more... Tidying when multiple observational units are stored in the same table Getting ready How to do it... How it works... There's more... See also Combining Pandas Objects Appending new rows to DataFrames Getting ready How to do it... How it works... There's more... Concatenating multiple DataFrames together Getting ready How to do it... How it works... There's more... Comparing President Trump's and Obama's approval ratings Getting ready How to do it... How it works... There's more... See also Understanding the differences between concat, join, and merge Getting ready How to do it... How it works... There's more... See also Connecting to SQL databases Getting ready How to do it... How it works... There's more... See also Other Books You May Enjoy Leave a review - let other readers know what you think