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).
ML Fundamentals
Learn the core ML algorithms and the statistics behind them.
Advanced ML
Move on to deep learning and to running models in production.
Projects to Build
Image Classification
Train a small convolutional network to classify the handwritten digits in the MNIST dataset.
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.
Chatbot Development
Build a chatbot on top of a pretrained transformer language model, using the Hugging Face Transformers library.
TensorFlow and PyTorch
TensorFlow
Best for: production deployment, mobile and edge devices
PyTorch
Best for: research, prototyping and production; most newly published model code targets PyTorch