Book Image

Mastering Numerical Computing with NumPy

By : Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu
Book Image

Mastering Numerical Computing with NumPy

By: Umit Mert Cakmak, Tiago Antao, Mert Cuhadaroglu

Overview of this book

NumPy is one of the most important scientific computing libraries available for Python. Mastering Numerical Computing with NumPy teaches you how to achieve expert level competency to perform complex operations, with in-depth coverage of advanced concepts. Beginning with NumPy's arrays and functions, you will familiarize yourself with linear algebra concepts to perform vector and matrix math operations. You will thoroughly understand and practice data processing, exploratory data analysis (EDA), and predictive modeling. You will then move on to working on practical examples which will teach you how to use NumPy statistics in order to explore US housing data and develop a predictive model using simple and multiple linear regression techniques. Once you have got to grips with the basics, you will explore unsupervised learning and clustering algorithms, followed by understanding how to write better NumPy code while keeping advanced considerations in mind. The book also demonstrates the use of different high-performance numerical computing libraries and their relationship with NumPy. You will study how to benchmark the performance of different configurations and choose the best for your system. By the end of this book, you will have become an expert in handling and performing complex data manipulations.
Table of Contents (11 chapters)

Loss and error functions

In the previous subsections, we explain supervised and unsupervised learning. Regardless of which machine learning algorithm is used, our main challenge is regarding issues with optimization. In optimization functions, we are actually trying to minimize the loss function. Imagine a case where you are trying to optimize your monthly savings. In a closed state, what you will do is minimize your spending, in other words, minimize your loss function.

A very common way to build a loss function is starting with the difference between the predicted value and the actual value. In general, we try to estimate the parameters of our model, and then prediction is made. The main measurement that we can use to evaluate how good our prediction is involves calculating the difference between the actual values:

In different models, different loss functions are used. For...