Skip to Main Content
Hands-On Predictive Analytics with Python
book

Hands-On Predictive Analytics with Python

by Alvaro Fuentes
December 2018
Beginner to intermediate content levelBeginner to intermediate
330 pages
8h 32m
English
Packt Publishing
Content preview from Hands-On Predictive Analytics with Python

A mini NumPy tutorial

Here are a couple of little motivating examples about why we need vectorization when doing any kind of scientific computing. You will see what we mean by vectorization in the following example.

Let's perform a couple of simple calculations with Python. We have two examples:

  • First, let's say we have some distances and times and we would like to calculate the speeds:
distances = [10, 15, 17, 26]times = [0.3, 0.47, 0.55, 1.20]# Calculate speeds with Pythonspeeds = []for i in range(4):    speeds.append(distances[i]/times[i])speeds

Here we have the speeds:

[33.333333333333336,
 31.914893617021278,
 30.909090909090907,
 21.666666666666668]

An alternative to accomplish the same in Python methodology would be the following:

# An ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python: Advanced Predictive Analytics

Python: Advanced Predictive Analytics

Ashish Kumar, Joseph Babcock
Python: Data Analytics and Visualization

Python: Data Analytics and Visualization

Phuong Vo.T.H, Martin Czygan, Ashish Kumar, Kirthi Raman
Python: End-to-end Data Analysis

Python: End-to-end Data Analysis

Phuong Vothihong, Martin Czygan, Ivan Idris, Magnus Vilhelm Persson, Luiz Felipe Martins

Publisher Resources

ISBN: 9781789138719Supplemental Content