Book Image

Machine Learning Quick Reference

By : Rahul Kumar
Book Image

Machine Learning Quick Reference

By: Rahul Kumar

Overview of this book

Machine learning makes it possible to learn about the unknowns and gain hidden insights into your datasets by mastering many tools and techniques. This book guides you to do just that in a very compact manner. After giving a quick overview of what machine learning is all about, Machine Learning Quick Reference jumps right into its core algorithms and demonstrates how they can be applied to real-world scenarios. From model evaluation to optimizing their performance, this book will introduce you to the best practices in machine learning. Furthermore, you will also look at the more advanced aspects such as training neural networks and work with different kinds of data, such as text, time-series, and sequential data. Advanced methods and techniques such as causal inference, deep Gaussian processes, and more are also covered. By the end of this book, you will be able to train fast, accurate machine learning models at your fingertips, which you can easily use as a point of reference.
Table of Contents (18 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Kernel types


We're going to explain the types of in this section.

Linear kernel

Let's say there are two vectors, x1 and x2, so the linear kernel can be defined by the following:

K(x1, x2)= x1 . x2

Polynomial kernel

If there are two vectors, x1 and x2, the linear kernel can be defined by the following:

K(x1, x2)= (x1 . x+ c)d

Where:

  • c: Constant
  • d: Degree of polynomial:
def polynomial_kernel(x1, x2, degree, constant=0): 
    result = sum([x1[i] * x2[i] for i in range(len(x1))]) + constant 
    return pow(result, degree)

If we use the same x1 and x2 as used previously, we get the following:

x1= [4,8]
x2=[20,30] 
polynomial_kernel(x1,x2,2,0)
# result would be 102400

If we increase the degree of polynomial, we will try to get influenced by other vectors as the decision boundary becomes too complex and it will result in overfitting:

Polynomial kernel using degree as 6.

 

Gaussian kernel

The polynomial kernel has given us a good boundary line. But can we work with polynomial kernels all the time? Not in the following...