Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning NumPy Array

You're reading from  Learning NumPy Array

Product type Book
Published in Jun 2014
Publisher
ISBN-13 9781783983902
Pages 164 pages
Edition 1st Edition
Languages
Author (1):
Ivan Idris Ivan Idris
Profile icon Ivan Idris

Table of Contents (14) Chapters

Learning NumPy Array
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with NumPy NumPy Basics Basic Data Analysis with NumPy Simple Predictive Analytics with NumPy Signal Processing Techniques Profiling, Debugging, and Testing The Scientific Python Ecosystem Index

Introducing the day-of-the-year temperature model


Continuing with the work we did in the previous example, I would like to propose a new model, where temperature is a function of the day of the year (between 1 and 366). Of course, this model is not complete, but can be used as a component in a more advanced model, which should take into account the previous autoregressive model that we did with lag 2. The procedure for this model is illustrated as follows:

  1. Fit the temperature data before the cutoff point to a quadratic polynomial just as in the previous section but without averaging:

    poly = np.polyfit(days[:cutoff], temp[:cutoff], 2)
    print poly

    Believe it or not, we get the same polynomial coefficients we got earlier:

    [ -4.91072584e-04   1.92682505e-01  -3.97182941e+00]
    
  2. Calculate the absolute difference between the predicted and actual values:

    delta = np.abs(np.polyval(poly, days[cutoff:]) - temp[cutoff:])
  3. Plot a histogram of the absolute error:

    plt.hist(delta, bins = 10, normed = True)
    plt.show...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}