Book Image

Data Science Projects with Python

By : Stephen Klosterman
Book Image

Data Science Projects with Python

By: Stephen Klosterman

Overview of this book

Data Science Projects with Python is designed to give you practical guidance on industry-standard data analysis and machine learning tools, by applying them to realistic data problems. You will learn how to use pandas and Matplotlib to critically examine datasets with summary statistics and graphs, and extract the insights you seek to derive. You will build your knowledge as you prepare data using the scikit-learn package and feed it to machine learning algorithms such as regularized logistic regression and random forest. You’ll discover how to tune algorithms to provide the most accurate predictions on new and unseen data. As you progress, you’ll gain insights into the working and output of these algorithms, building your understanding of both the predictive capabilities of the models and why they make these predictions. By then end of this book, you will have the necessary skills to confidently use machine learning algorithms to perform detailed data analysis and extract meaningful insights from unstructured data.
Table of Contents (9 chapters)
Data Science Projects with Python
Preface

Preface

Note

About

This section briefly introduces the author, the coverage of this book, the technical skills you'll need to get started, and the hardware and software required to complete all of the included activities and exercises.

About the Book

Data Science Projects with Python is designed to give you practical guidance on industry-standard data analysis and machine learning tools in Python, with the help of realistic data. The book will help you understand how you can use pandas and Matplotlib to critically examine a dataset with summary statistics and graphs, and extract meaningful insights. You will continue to build on your knowledge as you learn how to prepare data and feed it to machine learning algorithms, such as regularized logistic regression and random forest, using the scikit-learn package. You'll discover how to tune algorithms to provide the best predictions on new, unseen data. As you delve into later chapters, you'll gain an understanding of the workings and output of these algorithms, and gain insight into not only the predictive capabilities of the models but also they way they make predictions.

About the Author

Stephen Klosterman is a machine learning data scientist at CVS Health. He enjoys helping to frame problems in a data science context and delivering machine learning solutions that business stakeholders understand and value. His education includes a Ph.D. in biology from Harvard University, where he was an assistant teacher of the data science course.

Objectives

  • Install the required packages to set up a data science coding environment

  • Load data into a Jupyter Notebook running Python

  • Use Matplotlib to create data visualizations

  • Fit a model using scikit-learn

  • Use lasso and ridge regression to reduce overfitting

  • Fit and tune a random forest model and compare performance with logistic regression

  • Create visuals using the output of the Jupyter Notebook

Audience

If you are a data analyst, data scientist, or a business analyst who wants to get started with using Python and machine learning techniques to analyze data and predict outcomes, this book is for you. Basic knowledge of computer programming and data analytics is a must. Familiarity with mathematical concepts such as algebra and basic statistics will be useful.

Approach

Data Science Projects with Python takes a case study approach to simulate the working conditions you will experience when applying data science and machine learning concepts. You will be presented with a problem and a dataset, and walked through the steps of defining an answerable question, deciding what analysis methods to use, and implementing all of this in Python to create a deliverable.

Hardware Requirements

For the optimal student experience, we recommend the following hardware configuration:

  • Processor: Intel Core i5 or equivalent

  • Memory: 4 GB RAM

  • Storage: 35 GB available space

Software Requirements

You'll also need the following software installed in advance:

  • OS: Windows 7 SP1 64-bit, Windows 8.1 64-bit or Windows 10 64-bit, Ubuntu Linux, or the latest version of OS X

  • Browser: Google Chrome/Mozilla Firefox Latest Version

  • Notepad++/Sublime Text as IDE (this is optional, as you can practice everything using the Jupyter Notebook on your browser)

  • Python 3.4+ (latest is Python 3.7) installed (from https://python.org)

  • Python libraries as needed (Jupyter, NumPy, Pandas, Matplotlib, and so on)

Installation and Setup

Before you start this book, make sure you have installed the Anaconda environment as we will be using the Anaconda distribution of Python.

Installing Anaconda

Install Anaconda by following the instructions at this link: https://www.anaconda.com/distribution/

Additional Resources

The code bundle for this book is hosted on GitHub at https://github.com/TrainingByPackt/Data-Science-Projects-with-Python.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Conventions

Code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "By typing conda list at the command line, you can see all the packages installed in your environment."

A block of code is set as follows:

import numpy as np #numerical computation
import pandas as pd #data wrangling
import matplotlib.pyplot as plt #plotting package
#Next line helps with rendering plots
%matplotlib inline
import matplotlib as mpl #add'l p‑lotting functionality
mpl.rcParams['figure.dpi'] = 400 #high res figures
import graphviz #to visualize decision trees

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Create a new Python 3 notebook from the New menu as shown."