liveBook · Manning

Array

As explained in Grokking Machine Learning, Second Edition

An array is an indexed collection of values, typically arranged for efficient numerical computation.

An array is an indexed collection of values arranged for efficient numerical work. In Python machine learning, NumPy arrays hold datasets and support mathematical operations. section 3.16

Arrays can represent data in several useful shapes:

  • A one-dimensional array can hold feature values and matching labels, such as measurements paired with outcomes. section 3.16
  • A two-dimensional array can store several features for each data point, such as counts of two words in sentences. section 5.18
  • A matrix can store an image as rows and columns of pixel intensities, then be reshaped into a vector for a neural network. section 10.19

A small feature-and-label array

features = np.array([1, 2, 3, 5, 6, 7]) and labels = np.array([155, 197, 244, 356, 407, 448]) keep the inputs and their corresponding outputs in separate, aligned arrays. section 3.16

import numpy as np
features = np.array([1,2,3,5,6,7]) 
labels = np.array([155, 197, 244, 356, 407, 448])

Inspect a short NumPy example that creates aligned feature and label arrays. section 3.16

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Shows one- and two-dimensional examples plus reshaping, but stops short of deeper array implementation details.
Examples
Uses feature-label datasets, alien word counts, MNIST image matrices, reshaped vectors, and encoded labels.
What it assumes
Builds from tabular features and labels while introducing NumPy arrays through small Python datasets.
What you can do after
Apply via NumPy by creating aligned data arrays, reshaping image matrices, and supplying vector inputs to neural networks.
How it connects
Connects arrays with NumPy, Matplotlib, neural networks, dimensionality reduction, matrix factorization, and image compression.

Also explained in

Compare how 48 books explain array →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.