AI Matrices
Read rows and columns before performing a batch calculation.
How it works
A matrix is a rectangular table of numbers. In this example each row is a kitchen session and each column is a feature. Multiplying the matrix by a weight vector gives one score per row. Matrix multiplication is different from element-by-element multiplication. The dimensions must align before any arithmetic is useful.
Run the code
Try in playground loads this complete standard-library Python example without executing it. Choose Run when ready. Local review uses Python 3.12.14; the existing browser editor uses Pyodide 0.27.7. These small fictional examples need no account, external data, model-provider key or database service.
Example
rows = [[2, 1], [4, 2], [6, 1]]
weights = [1.5, -0.5]
assert all(len(row) == len(weights) for row in rows)
scores = [sum(x*w for x,w in zip(row,weights,strict=True)) for row in rows]
print("shape:", (len(rows), len(weights)))
print("scores:", scores)
Expected result
shape: (3, 2) scores: [2.5, 5.0, 8.5]
There are three observations and two features, so the output has three values. Later numerical libraries perform the same operation efficiently on arrays. This nested-list example illustrates shape; it is not a replacement numerical library or a performance benchmark.