Posts

Showing posts with the label NumPy

Why Vector, Matrix and Tensor are called 1D, 2D and 3D

1. Vector (1D): A list of numbers in a single line. [1,2,3,4,5] Think of it as a single column or Single Row in Excel. It either goes Horizontal or Vertical or any direction, but Single Line. That is why it is called Only one dimension . Example: [5, 10, 15] → 3 numbers in one row or 3 numbers in one column. Python Code: import numpy as np vector = np.array([1,2,3,4,5]) print(vector) 2. Matrix (2D): A table of numbers with both  rows and columns . Think of it as one Excel sheet where Column A has 1,2,3,4,5 and Column B has 6,7,8,9,10 Now it has Two dimensions: rows × columns. Python Code: import numpy as np matrix = np.array([[1,2,3],[4,5,6],[7,8,9]]) print(matrix) 3. Tensor (3D or more): A collection of matrices stacked together like a . Think of it as multiple Excel sheets stacked in a workbook . One above another. Tensor Can have 3, 4, or more dimensions. Row is one dimension, Column is second dimension, second table or second sheet is third dimension, third table is fourth d...

NumPy Library in Data Science

Image
We use the NumPy library in data science with Python because it makes working with numbers and large datasets much faster and easier. Why NumPy is important in data science: NumPy stores data as arrays that uses less memory Applies Math Operations directly on all values in the array at once. We can work with 1D (vectors), 2D (matrices), and even higher-dimensional data. Libraries like Pandas , Scikit-learn , TensorFlow , and Matplotlib depend on NumPy for handling numeric data. NumPy has built-in functions for matrix multiplication, eigenvalues, random number generation, and statistical calculations.