Artificial Intelligence Starter · free course

Free course · Lesson 2 of 5

How AI Learns from Data

In this lesson you will

  • Explain how AI learns from examples
  • Explain why AI systems make mistakes

AI learns by finding patterns in data. Instead of being explicitly programmed with rules, an AI model is trained on examples. For instance, show an AI thousands of labeled pictures of cats and dogs, and it learns to distinguish them on its own. This process is called Machine Learning (ML).

  • Training data: examples the model learns from (e.g., 10,000 labeled emails as "spam" or "not spam").
  • Features: the pieces of information the model uses (e.g., words in an email, pixel values in an image).
  • Labels: the correct answer the model is trying to predict (e.g., "spam" or "not spam").
  • After training, the model can make predictions on new, unseen data — this is called inference.

💡 Practical Skill: Use Google Colab (free, browser-based) to run simple ML experiments. No installation needed — just a Google account. Start with pre-built datasets from scikit-learn.

Worked exampleSimple Machine Learning Classifier (Python)
Python
# A simple ML classifier using scikit-learn# Run this in Google Colab or locally with: pip install scikit-learn from sklearn import tree # Features: [weight_grams, texture_smooth(0=rough,1=smooth)]# 0 = orange, 1 = applefeatures = [    [150, 0],  # orange    [170, 0],  # orange    [180, 1],  # apple    [200, 1],  # apple    [140, 0],  # orange    [190, 1],  # apple] # Labels: 0 = orange, 1 = applelabels = [0, 0, 1, 1, 0, 1] # Train the decision tree classifierclassifier = tree.DecisionTreeClassifier()classifier = classifier.fit(features, labels) # Predict a new fruit: 160g, smooth texture (should be apple)result = classifier.predict([[160, 1]])fruit = "Apple" if result[0] == 1 else "Orange"print(f"The AI predicts: {fruit}")# Output: The AI predicts: Apple

Practice exercise

Describe the training examples you would need to teach an AI to tell ripe from unripe mangoes, and one situation where it might fail.

Key takeaways

  • AI learns patterns from labelled examples
  • Poor or narrow data produces poor AI
  • Test AI on new examples to know how good it is
In the full program Module 2: How AI Learns from Data 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.