AI Academy: Lesson 2

1. Predicting Numbers (Regression)

In Lesson 1, we learned about Classification—separating things into distinct categories (like Apple or Orange).

But what if we want to predict a continuous numerical value? For instance, predicting house prices, future stock values, or tomorrow's sales?

This is called Regression. The most common form is Linear Regression—which means finding a straight line that best fits historical data points to project where new ones will fall.

Historical Info (Past Data)
Find Trend Line
Predict Future Numbers

2. Lemonade Stand Challenge

Let's build your predictive intuition. You are running a lemonade stand! Your sales depend strongly on the daily temperature.

Look at tomorrow's weather forecast. Guess how many cups of lemonade you will sell so you can stock the right amount of lemons. Too few = lost profit; too many = wasted inventory!

Day 1 of 5
Temperature: 75°F
DayTempYour GuessActual SalesDiff (Error)

3. The Reveal: Machine Learning Line

Let's plot your Lemonade Stand sales results. The red dots are the actual daily sales coordinates plotted against temperature.

Adjust the sliders to tilt and shift the blue "Line of Best Fit". Your goal is to make the line pass as close to the center of all the dots as possible. This line represents your predictive model!

Sales (Cups)
Temperature (°F)

4. Interactive Python Notebook

Let's turn your lemonade stand intuition into a professional python machine learning model. Click "Run" (▸) on the notebook cells below, and follow prompts to modify the code!

Markdown
Goal: Train a scikit-learn Linear Regression model using daily temperature historical records.
Code [1]
import pandas as pd
data = pd.read_csv("lemonade_sales.csv")
print(data.head())
Output will display here...
Code [2] Prompt: Change the color string in the code from 'blue' to another color (e.g. 'red' or 'green') and click Run.
Output will display here...
Code [3]
from sklearn.linear_model import LinearRegression
model = LinearRegression()
model.fit(data[['temperature']], data['sales'])
print("Model training finished!")
Output will display here...
Code [4]
Output will display here...

5. Core Concept Summary

You have completed Lesson 2! Let's review the key terms in our cheat sheet companion page.

💡 The Big Idea
Linear Regression fits the **best possible straight line** through historical data coordinate points to predict a numerical future outcome.
🧬 Feature vs. Target
• **Feature (X):** The input variable used to predict the future (e.g. Temperature).
• **Target (Y):** The output number we are trying to guess (e.g. Lemonade Sales).
🌍 Real-World Use Cases
• **Business:** Forecasting next quarter's revenue.
• **Logistics:** Estimating flight or shipping delays based on wind speeds.
• **Pricing:** Dynamic pricing models for ride-sharing or airline tickets.
Narration (Professor Lyra)
Click "Start Lesson" below to begin.