Understand lists, tables and weighted sums before seeing formal linear algebra in Professional. Optional support only—not a prerequisite for exams or certificates.
Treat a vector as an ordered list of measurements with a consistent meaning for each position.
Multiply matching entries and add them to form a weighted sum.
Count rows and columns and check compatible dimensions.
A vector such as [2, 3] can represent two features: hours studied and exercises completed. Position matters: [3, 2] describes a different observation. Choose consistent units and feature order across all examples.
features = [2, 3]
print(len(features)) # 2 featuresA dot product is a weighted sum. For features [2, 3] and weights [4, 1], multiply 2 × 4 and 3 × 1, then add 8 + 3 = 11. Both vectors must have the same length.
features = [2, 3]
weights = [4, 1]
if len(features) != len(weights):
raise ValueError("Lengths must match")
score = sum(x * w for x, w in zip(features, weights))
print(score) # 11A matrix with 3 rows and 2 columns has shape 3 × 2. Rows can be examples and columns can be features. Multiplying a 3 × 2 matrix by a 2-entry weight vector produces 3 scores, one per row. The inner dimensions must match.
examples = [[2, 3], [1, 4], [0, 5]]
weights = [4, 1]
for row in examples:
print(sum(x * w for x, w in zip(row, weights)))
# 11
# 8
# 5If one feature uses thousands and another uses fractions, the large feature can dominate a distance calculation. Scaling makes comparisons more meaningful; it does not automatically remove bias. Embeddings are longer numerical vectors that represent content, not a list of readable words.
When this helps: This is a gentle bridge to Professional linear algebra, embeddings and clustering. It is not required before starting Foundations.
rows = [[3, 4], [1, 5]] weights = [2, 1] # Check lengths and print each weighted sum
Test your understanding with this quiz. Select the best answer for each question.
Help optimize our AI programming lessons to ensure student success!
Sign in to send a comment to Customer Support.