# Vector in ML

**Vector** is an ordered array of numbers (or data point) representing features of object like text, image, or audio.  
  
These high dimensional numerical representations, or embeddings, captures semantic meaning, allowing algos to measure similarities, and identifying relationships.  
It helps basically to process unstructured data for examples like recommendation systems and LLMs

 Now let’s understand what above definition means.  
  
**How vector is represented?  
**  
example like tables length and breadth (in inch) might be:  
V = (48,16)  
in higher dimensions vector will have large components such as:

V = (x<sub>1</sub>,x<sub>2</sub>,x<sub>3</sub>,x<sub>4</sub>,…….x<sub>N</sub>)

Now you can simply create a vector in python using NumPy

`Import numpy as np`

`V = np.array([48,16])`

`Print(“Vectors:”,v)`  
  
\# Similarly, a matrix is also an example of a vector.  
  
**Types of Vectors in Machine Learning.  
**  
**Row and Column Vectors  
**row vector is v = (x<sub>1</sub>, x<sub>2</sub>,x<sub>3 </sub> ) it is one-dimensional array

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1770207695765/18582ad9-68a2-4f0a-b5cd-d2f8f82ef8c4.png align="left")

**Zero Vector**

A vector with all elements is 0. It is useful in optimization and denote origin in vector space.

v = (0,0,0)

**Unit Vector**

A vector of magnitude 1. It is majorly used for direction

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1770207741379/57cc0177-5950-4b9c-a49b-b452a95a7e9b.png align="left")

**Sparse Vector**

 In this vector it majorly consists of zeros and used in text analysis and recommendation system

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1770207781622/5e5d47ee-3298-47ae-a3d4-e5a60fb7deaa.png align="left")

**Dense Vector  
**  
In this vector it consists of non-zero elements and used in image processing and deep learning  

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1770207803192/ef6b80d1-504e-47b2-a31d-495f1340cbce.png align="left")

**Key operations** are performed using [NumPy](https://pypi.org/project/numpy/) or [PyTorch](https://pytorch.org/) to perform core mathematical operations in python  
these operations are dot product, scalar multiplication, vector addition/subtraction, Normalization. we will deep dive in coming blogs.

**Why vectors are used in Ml.**

Because of its properties which can be utilised to create

**Feature Representation**  
As we learned vectors represents data point in numerical forms.  Like in Natural language processing words are translated into word vectors using library in python you can also achieve using [word2vec](https://www.geeksforgeeks.org/python/python-word-embedding-using-word2vec/)

**Similarity Measurement  
**Now feature representation of word vectors enables us to measure distance of vectors using [Euclidean Distance](https://www.geeksforgeeks.org/maths/euclidean-distance/) or [Cosine Similarity](https://www.geeksforgeeks.org/dbms/cosine-similarity/) Algorithms in Ml.  

**Transformations and Projections.**  
Vectors enable mathematical operations such as rotation, scaling and translation.  
example used in [principal component](https://www.ibm.com/think/topics/principal-component-analysis) analysis.  

### Application of vectors

[Linear Regression](https://www.ibm.com/think/topics/linear-regression)

[Neural Networks](https://www.ibm.com/think/topics/neural-networks)

[Embeddings](https://www.pinecone.io/learn/vector-embeddings/)

*Ask questions and what do you think about Vectors in comment X*  
  
**What’s Next** .... we will deep dive into **how word2Vec library works** and helps in finding feature representation Stay Tuned and Subscribe
