What is Linear Algebra? #
Linear Algebra is a branch of mathematics that deals with vectors, matrices, and their operations. It is widely used in Data Science and Machine Learning.
Vectors #
A vector is a list of numbers representing magnitude and direction.
Example: #
v = [2, 4, 6]
Vector Operations #
Addition:
[1, 2] + [3, 4] = [4, 6]
Scalar Multiplication:
2 × [1, 2] = [2, 4]
Matrices #
A matrix is a 2D array of numbers (rows & columns).
Example: #
A = [[1, 2],
[3, 4]]Matrix Operations #
Addition #
(Add corresponding elements)
A + B = [[1+5, 2+6],
[3+7, 4+8]]Multiplication
A × B = [[(1×5 + 2×7), (1×6 + 2×8)],
[(3×5 + 4×7), (3×6 + 4×8)]]Transpose #
(Convert rows into columns)
Aᵀ = [[1, 3],
[2, 4]]Basic Python Example
import numpy as np
# Vectors
v1 = np.array([1, 2])
v2 = np.array([3, 4])
print("Addition:", v1 + v2)
print("Scalar:", 2 * v1)
# Matrices
A = np.array([[1, 2], [3, 4]])
B = np.array([[5, 6], [7, 8]])
print("Matrix Add:\n", A + B)
print("Matrix Multiply:\n", A.dot(B))
print("Transpose:\n", A.T)Importance in Data Science #
- Used in machine learning algorithms
- Helps in handling large datasets
- Important for deep learning and AI
| Category | Type | Description | Example |
|---|---|---|---|
| Data Collection | Databases | Structured data stored in systems | MySQL, PostgreSQL |
| Data Collection | APIs | Data fetched from web services | Weather API |
| Data Collection | Files | Local stored data | CSV, Excel |
| Data Collection | Web Scraping | Extract data from websites | E-commerce sites |
| Data Collection | Sensors/IoT | Real-time data collection | Smart devices |
| Data Format | CSV | Rows & columns text format | name, age |
| Data Format | JSON | Key-value format | {"name": "Alex"} |
| Data Format | Excel | Spreadsheet format | .xlsx file |
| Data Storage | Databases | Store structured data | SQL |
| Data Storage | Data Warehouse | Large-scale analytics storage | Snowflake |
| Data Storage | Data Lake | Raw data storage | Hadoop |
| Data Storage | Cloud Storage | Online scalable storage | AWS, Azure |
