Getting Started with Machine Learning

From the archive: a general guide from March 2024, tidied and kept for reference.

Getting Started with Machine Learning

Machine learning is less about the algorithms for their own sake than about using them to solve a real problem. This guide sets out a learning path in three phases, a first working example, some practice projects and a short comparison of the two main frameworks.

A First Example


# Basic ML Example: Linear Regression
import numpy as np
from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split

# Generate sample data
X = np.random.rand(100, 1) * 10
y = 2 * X + 1 + np.random.randn(100, 1)

# Split data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)

# Train model
model = LinearRegression()
model.fit(X_train, y_train)

# Make predictions
predictions = model.predict(X_test)
                                

A linear regression with scikit-learn: generate noisy points along the line y = 2x + 1, hold back 20% of them for testing, fit the model on the rest and predict the held-back points.

Learning Path and Practice

A Learning Roadmap

Foundation Phase

Learn Python, the core data libraries, and the basic mathematics ML relies on (linear algebra and probability).

Python Basics NumPy Pandas Linear Algebra
ML Fundamentals

Learn the core ML algorithms and the statistics behind them.

Scikit-learn Statistics Data Visualization
Advanced ML

Move on to deep learning and to running models in production.

PyTorch or TensorFlow Deep Learning Model Deployment

Projects to Build

Beginner
Image Classification

Train a small convolutional network to classify the handwritten digits in the MNIST dataset.

TensorFlow CNN Computer Vision
Intermediate
Time Series Forecasting

Train an LSTM on a historical price series, such as daily stock closes. It is good practice in sequence modeling, not a reliable way to predict markets.

Keras LSTM Time Series
Advanced
Chatbot Development

Build a chatbot on top of a pretrained transformer language model, using the Hugging Face Transformers library.

Transformers NLP LLMs

TensorFlow and PyTorch

TensorFlow
Keras API Mobile Deployment TensorFlow Serving

Best for: production deployment, mobile and edge devices

PyTorch
Research Friendly Dynamic Graphs Python First

Best for: research, prototyping and production; most newly published model code targets PyTorch