Machine Learning Starter · free course

Free course · Lesson 2 of 5

The Machine Learning Workflow

In this lesson you will

  • Describe the steps of an ML project
  • Explain why test data must stay unseen

Building an ML model follows a standard workflow. Understanding this process is more important than memorizing algorithms — because real-world ML is mostly about data preparation and evaluation, not just writing code.

  1. Define the Problem: What are you trying to predict? Is it a category (classification) or a number (regression)?
  2. Collect & Prepare Data: Gather data, handle missing values, remove errors, and split into training (80%) and testing (20%) sets.
  3. Choose & Train a Model: Pick an algorithm (e.g., Linear Regression, Decision Tree), feed it the training data.
  4. Evaluate the Model: Test on the unseen testing data. Measure accuracy (classification) or error (regression).
  5. Deploy & Monitor: Use the model on new data. Monitor its performance over time — models can "drift" as data changes.

💡 Practical Skill: The training/testing split is critical. If you test on the same data you trained on, you'll get misleadingly high accuracy (this is called overfitting). Always hold out a test set!

Worked exampleTrain/Test Split & Simple Model (scikit-learn)
Python
# Complete ML workflow using scikit-learn# Install: pip install scikit-learn matplotlib import numpy as npfrom sklearn.model_selection import train_test_splitfrom sklearn.tree import DecisionTreeRegressorfrom sklearn.metrics import mean_absolute_error # Step 1: Create a synthetic dataset# Feature: hours_studied => Target: exam_scorenp.random.seed(42)hours = np.random.uniform(1, 20, 100).reshape(-1, 1)scores = hours.flatten() * 4.5 + np.random.normal(0, 8, 100) # Step 2: Split into training (80%) and testing (20%)X_train, X_test, y_train, y_test = train_test_split(    hours, scores, test_size=0.2, random_state=42) print(f"Training samples: {len(X_train)}, Testing samples: {len(X_test)}") # Step 3: Train a Decision Tree modelmodel = DecisionTreeRegressor(max_depth=4)model.fit(X_train, y_train) # Step 4: Evaluate on test datapredictions = model.predict(X_test)error = mean_absolute_error(y_test, predictions)print(f"Mean Absolute Error on test set: {error:.1f} points") # Step 5: Make a prediction for a new studentnew_student = np.array([[12]])  # studied 12 hourspredicted_score = model.predict(new_student)[0]print(f"Predicted score for 12 hours of study: {predicted_score:.1f}%") # Compare: a rule-based estimate (simple linear)simple_pred = 12 * 4.5 + 40  # baselineprint(f"Simple baseline estimate: {simple_pred:.1f}%")

Practice exercise

Write the workflow for predicting which clinics will run out of a medicine: the decision, the data and how you would check the model.

Key takeaways

  • Framing and data take most of the effort
  • Keep a test set aside and use it only at the end
  • Deployed models need monitoring
In the full program Module 2: Preparing Data for Machine Learning See how this topic is taught in depth, with practical activities and an assessment.

Free self-study lesson — no certificate. For the full instructor-led program, see registration options.