Indexing selects elements, rows, columns, or slices from tensors. It follows familiar zero-based Python list syntax, then extends it across multiple tensor dimensions so data can be manipulated expressively and efficiently. section 3.2.1 section 3.3
Common forms include:
- Use a single position such as a[0], or assign through an index to change an element. section 3.2.1
- Use ranges such as points[1:], points[1:, :], or points[:, 0] to select portions of one or more dimensions. section 3.3
- Use a Boolean tensor as advanced indexing to filter rows whose corresponding mask entries are True. section 4.3.6
Filtering wines by quality
A comparison creates a Boolean index: bad_indexes = target <= 3. Applying data[bad_indexes] keeps the 20 matching wine rows and all 11 columns. Combining masks, as in (target > 3) & (target < 7), groups wines into quality ranges; another mask can compare predicted and actual categories. section 4.3.6
# In[54]: points[1:] #1 points[1:, :] #2 points[1:, 0] #3 points[None] #4
This listing makes multidimensional range indexing concrete by contrasting row slices, column selection, and adding a dimension with None. section 3.3














