Analysis

Problem 1: Every month, we have to pay for the data we have stored in the cloud thus far, plus the new data that is added in that month. We will use linear regression to predict the cost for a general month, and then we will calculate the sum of the first 12 months to calculate the cost for the whole year.

Input:

source_code/6/cloud_storage.pyimport numpy as npfrom scipy.linalg import lstsqmonth = np.array([1,2,3,4,5])bill = np.array([120.0,131.2,142.1,152.9,164.3])M = month[:, np.newaxis]**[0, 1]model, _, _, _ = lstsq(M,bill)print "Intercept =", model[0]print "month_data =", model[1]

Output:

$ python cloud_storage.pyIntercept = 109.00999999999992month_data = 11.030000000000008

This means that the base cost is base_cost=109.01 euros, ...

Get Data Science Algorithms in a Week - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.