Skip to main content
NumPy beginner Lesson 12 of 12

NumPy Projects

Hands-on projects to solidify your NumPy skills — from basic array manipulation to building ML algorithms from scratch.

Beginner Projects

1. Statistics Calculator

Build a statistics module that computes mean, median, mode, variance, standard deviation, percentiles, and IQR for any array — without using scipy.stats. Verify your results match scipy.

What you’ll practice: Array creation, axis arguments, reduction operations, np.sort, np.unique


2. Image Brightness and Contrast Filter

Load a grayscale image as a NumPy array (via PIL) and implement: brightness adjustment (add scalar), contrast stretch (linear normalization to [0,255]), and histogram equalization.

What you’ll practice: Array arithmetic, clip(), broadcasting, histograms with np.histogram


3. Grade Book Analyzer

Given a 2D array of student scores (rows=students, cols=subjects), compute: class averages per subject, top student per subject, overall letter grades, pass/fail flags (threshold configurable).

What you’ll practice: axis operations, boolean masking, np.argmax, np.where


4. Temperature Anomaly Detector

Given 365 days of temperature readings, compute the 30-day rolling mean and flag any day where the actual temperature deviates more than 2 standard deviations from the rolling mean.

What you’ll practice: Stride tricks or loop-based rolling, np.std, boolean indexing


5. Matrix Calculator

Implement a CLI matrix calculator: add, subtract, multiply, transpose, determinant, inverse. Accept matrices as user input and display results formatted nicely.

What you’ll practice: np.linalg, matrix operations, input parsing


6. Dice Roll Simulator

Simulate rolling N dice M times. Compute the probability distribution of the sum, compare to the theoretical distribution, and visualize with a text-based histogram.

What you’ll practice: np.random, np.bincount, vectorized operations, fractions


7. Stock Returns Analyzer

Given daily closing prices for 5 stocks, compute: daily returns (pct_change), cumulative returns, rolling 20-day volatility, correlation matrix, and the minimum-variance portfolio weights.

What you’ll practice: Arithmetic on arrays, rolling operations, np.cov, np.linalg.eig


8. Polynomial Interpolation

Given N (x, y) data points, fit a polynomial using np.polyfit and evaluate it at 1000 points. Compare different polynomial degrees and identify the best fit by MSE.

What you’ll practice: np.polyfit, np.polyval, np.linspace, MSE computation


9. Run-Length Encoder/Decoder

Implement run-length encoding (compress consecutive repeated values) and decoding using only NumPy. Example: [1,1,1,2,2,3] → [(3,1),(2,2),(1,3)].

What you’ll practice: np.diff, np.where, np.repeat, fancy indexing


10. Distance Matrix Calculator

Given N 2D points, compute the full N×N pairwise Euclidean distance matrix using broadcasting (no loops). Then find the K nearest neighbors for each point.

What you’ll practice: Broadcasting, np.argsort, Euclidean distance formula


Intermediate Projects

1. K-Means Clustering from Scratch

Implement K-Means using only NumPy: random centroid initialization, assignment step (vectorized distances), update step, convergence check. Test on the Iris dataset.

What you’ll practice: Broadcasting for pairwise distances, argmin, vectorized assignments


2. Neural Network Forward Pass

Implement a 3-layer neural network forward pass using only NumPy: random weight initialization, matrix multiplication, ReLU activation, softmax output. No backprop required.

What you’ll practice: Matrix operations, broadcasting, exponential/log operations


3. Gradient Descent Optimizer

Implement gradient descent, momentum, and Adam optimizers from scratch. Apply them to minimize a 2D function (Rosenbrock, Ackley) and plot the optimization trajectory.

What you’ll practice: NumPy math operations, running statistics, vectorization


4. Signal Processing Pipeline

Implement: zero-mean normalization, FIR filter (moving average and Hamming window), peak detection (find local maxima), and FFT-based frequency analysis on synthetic ECG data.

What you’ll practice: np.fft, convolution via np.convolve, np.argrelmax


5. Game of Life

Implement Conway’s Game of Life using NumPy: represent the grid as a 2D boolean array, count neighbors using convolution (np.lib.stride_tricks or scipy.signal), apply rules vectorized.

What you’ll practice: 2D array operations, convolution-based neighbor counting, boolean logic


6. Monte Carlo Options Pricing

Implement Black-Scholes Monte Carlo pricing for European call/put options. Simulate 100,000 stock price paths, compute payoffs, discount to present value.

What you’ll practice: np.random, cumulative products, vectorized option payoff calculation


7. Image Compression via SVD

Implement low-rank approximation of an image using SVD. Show the original vs approximations at rank 5, 10, 20, 50, and compute the compression ratio and reconstruction error.

What you’ll practice: np.linalg.svd, matrix reconstruction, Frobenius norm


8. Numeric Differentiation Library

Implement finite difference methods (forward, backward, central) for first and second derivatives. Implement gradient and Jacobian computation for multi-variable functions.

What you’ll practice: Broadcasting, array slicing, function evaluation


9. Sparse Matrix Operations

Implement COO and CSR sparse matrix formats from scratch. Implement matrix-vector multiplication and compare performance to dense multiplication on various sparsity levels.

What you’ll practice: Structured arrays, vectorized indexing, performance benchmarking


10. Principal Component Analysis

Implement PCA from scratch: center the data, compute the covariance matrix, eigen-decompose, project to k components. Compare to sklearn’s PCA on the digits dataset.

What you’ll practice: np.cov, np.linalg.eigh, matrix multiplication, explained variance


Advanced Projects

1. Backpropagation Engine

Implement automatic differentiation for a small neural network: forward pass, loss computation, analytical gradient via chain rule, weight updates. Train on XOR or MNIST.

What you’ll practice: Computational graph in NumPy, matrix calculus, inplace operations


2. Numerical ODE Solver

Implement Euler, RK2, and RK4 methods for solving ODEs. Apply to: simple harmonic oscillator, Lorenz attractor (chaos), and epidemic SIR model. Compare accuracy and stability.

What you’ll practice: Numerical integration, vectorized function evaluation, time stepping


3. Fast Convolution (FFT-based)

Implement 2D image convolution using FFT (O(n log n)) vs direct convolution (O(n²)). Benchmark on various kernel sizes. Implement Gaussian blur, edge detection (Sobel), and sharpening.

What you’ll practice: np.fft.fft2, zero-padding, spectral multiplication


4. Reinforcement Learning Environment

Implement a simple grid-world environment and Q-learning from scratch using NumPy arrays for the Q-table. Train an agent to navigate from start to goal while avoiding obstacles.

What you’ll practice: Multi-dimensional arrays, epsilon-greedy sampling, Q-value updates


5. Numba JIT Acceleration

Profile a compute-intensive NumPy workload (e.g., custom distance metric, specialized convolution), implement it with Numba @jit, measure speedup, and identify when JIT helps vs hurts.

What you’ll practice: Performance profiling, understanding NumPy’s C backend, Numba integration


Portfolio Projects

1. Financial Risk Engine

Build a production-ready risk calculation library: Monte Carlo VaR and CVaR for multi-asset portfolios, historical simulation, stress testing scenarios, and a confidence interval report. Accept CSV input, produce PDF-ready output tables.

Tech stack: NumPy, SciPy, pandas, matplotlib
Demonstrates: Monte Carlo simulation, statistical computing, financial domain knowledge


2. Computer Vision Primitives Library

Build an image processing library with zero external CV dependencies: resize (bilinear interpolation), rotate (affine transform), histogram equalization, connected components labeling, and morphological operations.

Tech stack: NumPy, PIL for I/O only
Demonstrates: 2D array mastery, algorithm implementation, performance optimization


3. Scientific Computing Benchmarks

Benchmark NumPy against pure Python, Numba, and CuPy across a suite of operations (matrix multiply, convolution, sorting, FFT). Produce an interactive report showing where to use each tool.

Tech stack: NumPy, Numba, timeit, matplotlib
Demonstrates: Performance awareness, profiling expertise, comparative analysis


4. ML Algorithm Zoo

Implement 10 ML algorithms from scratch using only NumPy: linear/logistic regression, SVM, k-NN, decision tree, naive Bayes, PCA, K-Means, GMM, and a 2-layer neural network. Each with sklearn-compatible API.

Tech stack: NumPy only
Demonstrates: Deep algorithm understanding, clean API design, mathematical fluency


5. Real-Time Signal Analyzer

Build a streaming signal analysis tool: sliding window FFT, real-time anomaly detection (z-score), peak tracking, and summary statistics. Process a continuous audio or sensor data stream.

Tech stack: NumPy, sounddevice or serial (for sensor), real-time visualization
Demonstrates: Streaming data processing, DSP knowledge, production-ready design

Frequently Asked Questions

How do I know when I've mastered NumPy?
You've mastered NumPy when you instinctively reach for vectorized operations instead of Python loops, can read and write broadcasting expressions without confusion, understand when you're getting a view vs a copy, and can implement basic ML math (matrix multiply, gradient descent) using only NumPy.