Book Image

Practical Data Analysis - Second Edition

By : Hector Cuesta, Dr. Sampath Kumar
Book Image

Practical Data Analysis - Second Edition

By: Hector Cuesta, Dr. Sampath Kumar

Overview of this book

Beyond buzzwords like Big Data or Data Science, there are a great opportunities to innovate in many businesses using data analysis to get data-driven products. Data analysis involves asking many questions about data in order to discover insights and generate value for a product or a service. This book explains the basic data algorithms without the theoretical jargon, and you’ll get hands-on turning data into insights using machine learning techniques. We will perform data-driven innovation processing for several types of data such as text, Images, social network graphs, documents, and time series, showing you how to implement large data processing with MongoDB and Apache Spark.
Table of Contents (21 chapters)
Practical Data Analysis - Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface

Processing the image dataset


The image set used in this chapter is the Caltech-256 obtained from the Computational Vision Lab at CALTECH. We can download the collection of all 30607 images and 256 categories from the following link:

http://www.vision.caltech.edu/Image_Datasets/Caltech256/

In order to implement the DTW first, we need to extract a time series (pixel sequences) from each image. The time series will have a length of 768 values and will add the 256 values of each color in the RGB (Red, Green, and Blue) color model of each image. The following code implements the Image.open("Image.jpg") function and casts it into an array, and then simply adds the three vectors of color in the list:

from PIL import Image 
img = Image.open("Image.jpg") 
arr = array(img) 
list = [] 
for n in arr: list.append(n[0][0]) #R 
for n in arr: list.append(n[0][1]) #G 
for n in arr: list.append(n[0][2]) #B 

Tip

Pillow is a PIL fork by Alex Clark and is compatible with Python...