iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 11
0
自我挑戰組

機器學習與數學天天玩系列 第 11

Day 11-機器學習與數學天天玩-PCA-Transformation of Vectors in Spaces: Dot Product Part 1

/images/emoticon/emoticon28.gif We are now in the PCA journey, station 2.

  1. Statistical Introduction
    2. Transformation of Vectors in Spaces
  2. Orthogonal Projection

https://ithelp.ithome.com.tw/upload/images/20181014/20111554uG7RdahJzn.png

Like the picture above, we want to know the difference between x and y. There are two ways for us to inspect, distance between x and y, and the angle between x and y. When it comes to the distance, the formula is as below:

https://ithelp.ithome.com.tw/upload/images/20181014/20111554sMgbP9bQ0e.png

We firstly make x - y, and then have the transpose of (x-y) time (x-y), and then have it be a root square value.

import numpy as np

x = np.array([1, 2])
y = np.array([2, 1])

def distance(x, y):
    
    distance = ((x-y)@(x-y))**0.5
    
    return distance

distance(x, y)

上一篇
Day 10-機器學習與數學天天玩-PCA-Transformation of Vectors in Spaces
下一篇
Day 12-機器學習與數學天天玩-PCA-Transformation of Vectors in Spaces: Dot Product Part 2
系列文
機器學習與數學天天玩13

尚未有邦友留言

立即登入留言