---
description: projection in math
---

# projection

![orthogonal projection](https://2417198446-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F04q6gn1bES1RZU067ZeW%2Fuploads%2Fq1cQl4I70IxM0n8khbT3%2Fimage.png?alt=media\&token=b13506e2-1771-416b-97a7-d0ec2845cc76)

```python
import numpy as np
import matplotlib.pyplot as plt

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

a = x * np.dot(x, y) / np.linalg.norm(x)**2
b = y - a

plt.plot( [0, x[0]],
          [0, x[1]], lw = 5 )
plt.plot( [0, y[0]],
          [0, y[1]], lw = 5 )

plt.plot( [0, a[0]],
          [0, a[1]] )
plt.plot( [0, b[0]],
          [0, b[1]] )

plt.axis('square')
plt.xlim(-3, 5)
plt.ylim(-3, 5)
plt.show()
```

As shown in the figure, this program draws the projection and parallel lines of the orange vector on the blue vector.

Projection is a very important content in machine learning and data mining.

## Statistics

Start time of this page: December 29, 2021

Completion time of this page: December 31, 2021
