← All drillsBuild a Metrics API with NumPy and FastAPI
What you'll be able to do- ✓Explain what a NumPy array is, and read its shape, dtype and memory use
- ✓Replace a loop with a vectorised NumPy line, and measure the speed-up
- ✓Avoid the silent NumPy bugs: integer wrap-around, float precision, and views that change the original
- ✓Use axis and broadcasting, and fix a shape error by reading it
- ✓Find blanks, junk codes and wrong units in real data, and clean them without touching the original
- ✓Build a rolling-window anomaly detector, and judge it with precision and recall instead of accuracy
- ✓Serve results through a FastAPI service with path and query parameters, a request body and validated Pydantic models
- ✓Handle missing values honestly in JSON, return consistent errors, and paginate long lists
- ✓Test an API with pytest, including a parity test against NumPy and a test against a known truth
- ✓Measure an API with p50 and p95, and use the numbers to make a design decision
Build a small data service that cleans messy readings, finds the ones that look wrong, and answers questions about them over a REST API, and show with tests and measurements that it can be trusted.
⌁ Metrics backends, smart meters, factory dashboards and the service layer that puts a model behind an endpoint all follow this shape: clean the readings, look for trouble, and answer questions over HTTP.
Start this internshipCreate an account to unlock the 6 sections, the workbench, and askThili.
BeginSections
1. Build a Metrics API with NumPy and FastAPI
🔒 locked2. Lesson 1 - Arrays, Not Lists
🔒 locked3. Lesson 2 - Axes, Broadcasting and Dirty Data
🔒 locked4. Lesson 3 - Finding the Anomalies
🔒 locked5. Lesson 4 - Serving It: Your First REST API
🔒 locked6. Lesson 5 - Making It Trustworthy
🔒 lockedDig deeper
🔗NumPy: the absolute basics for beginners
docs🔗NumPy: broadcasting
docs🔗NumPy: copies and views
docs🔗NumPy: sliding_window_view
docs📄Array programming with NumPy (Harris et al., Nature, 2020)
paper🔗pandas: windowing operations (rolling)
docs🔗FastAPI tutorial
docs🔗Pydantic documentation
docs🔗RFC 9110: HTTP semantics (methods and status codes)
docs🔗pytest documentation
docs