NumPy for ML: Tutorial 1

NumPy Tutorial 1

Concept: Speed & Efficiency

In Python, Lists are flexible but slow. In Machine Learning, we use NumPy Arrays because they are specifically built for math.

# Standard Python List
data = [1, 2, 3]

# Slow for math
# Uses more memory
import numpy as np

# NumPy Array
data = np.array([1, 2, 3])

# 50x Faster
# Optimized for Machine Learning
Activity: Construct the Code

Drag the correct syntax parts to create a NumPy array.

np.array
([10, 20])
Result:
Drop 'Method' Here
Drop 'List' Here
Knowledge Check

Which bracket style is used inside the parentheses when creating an array?

A. Curly Braces { }
B. Square Brackets [ ]
C. No Brackets needed

Post a Comment

0 Comments