Musubi Learning
Log InSign Up
Back to Lessons
🌳 Builder15 min

Build Your First Model

Write real Python code to build a simple AI model that classifies data — your first hands-on machine learning project.

Published: March 10, 2026

Watch the lesson video

Build Your First Model

Ready to write real AI code? In this lesson you'll build a classifier — an AI that can sort things into categories.

What you need

The project: Fruit classifier

We'll teach an AI to tell apart apples and oranges based on two features:

Step 1: Install scikit-learn

pip install scikit-learn

Step 2: Write the training data

from sklearn.tree import DecisionTreeClassifier

X_train = [
    [150, 0],   # apple
    [170, 0],   # apple
    [130, 0],   # apple
    [200, 1],   # orange
    [220, 1],   # orange
    [180, 1],   # orange
]

y_train = [0, 0, 0, 1, 1, 1]

Step 3: Train the model

model = DecisionTreeClassifier()
model.fit(X_train, y_train)
print("Model trained!")

Step 4: Make predictions

new_fruit = [[160, 0]]
prediction = model.predict(new_fruit)

if prediction[0] == 0:
    print("That's an apple!")
else:
    print("That's an orange!")

What just happened?

  1. You gave the model labeled examples (training data)
  2. The model found patterns (heavy + bumpy = orange)
  3. The model generalized to new data it never saw

This is machine learning in its simplest form!

Musubi's Challenge

Add a third fruit (bananas!) to your training data. What features would you use?


You built your first AI model. Welcome to the Builder tier!