Book Image

Python Machine Learning Blueprints - Second Edition

By : Alexander Combs, Michael Roman
Book Image

Python Machine Learning Blueprints - Second Edition

By: Alexander Combs, Michael Roman

Overview of this book

Machine learning is transforming the way we understand and interact with the world around us. This book is the perfect guide for you to put your knowledge and skills into practice and use the Python ecosystem to cover key domains in machine learning. This second edition covers a range of libraries from the Python ecosystem, including TensorFlow and Keras, to help you implement real-world machine learning projects. The book begins by giving you an overview of machine learning with Python. With the help of complex datasets and optimized techniques, you’ll go on to understand how to apply advanced concepts and popular machine learning algorithms to real-world projects. Next, you’ll cover projects from domains such as predictive analytics to analyze the stock market and recommendation systems for GitHub repositories. In addition to this, you’ll also work on projects from the NLP domain to create a custom news feed using frameworks such as scikit-learn, TensorFlow, and Keras. Following this, you’ll learn how to build an advanced chatbot, and scale things up using PySpark. In the concluding chapters, you can look forward to exciting insights into deep learning and you'll even create an application using computer vision and neural networks. By the end of this book, you’ll be able to analyze data seamlessly and make a powerful impact through your projects.
Table of Contents (13 chapters)

How to develop a trading strategy

We'll begin our strategy development by focusing on the technical aspects. Let's take a look at the S&P 500 over the last few years. We'll use pandas to import our data. This will give us access to several sources of stock data, including Yahoo! And Google.

  1. First, you'll need to install the data reader:
!pip install pandas_datareader 
  1. Then, go ahead and incorporate your imports:
import pandas as pd 
from pandas_datareader import data, wb 
import matplotlib.pyplot as plt 
 
%matplotlib inline 
pd.set_option('display.max_colwidth', 200) 
  1. Now, we'll get our data for the SPY ETF, which represents the stocks of the S&P 500. We'll pull data from the start of 2010 through December 2018:
import pandas_datareader as pdr 
 
start_date = pd.to_datetime('2010-01-01') 
stop_date = pd.to_datetime...