Understanding AI · lesson 11 of 60 · about 5 minutes
Predicting from a Pattern
Use a pattern to guess something new, and see why predictions far from the data are risky.
What you'll learn
- Use a model to predict a new value
- Explain why predictions inside the data's range are safer
- Spot a prediction that goes too far
The point of a pattern
The reason to find a pattern is to predict things you haven't seen yet. If the line fits days from 15 to 30 degrees, it can make a good guess for 22 degrees.
Don't stretch it too far
Predictions far outside the examples get risky. The ice cream line says 0 degrees means -30 sales, which is impossible. At 60 degrees it predicts 210, but nobody's buying ice cream in a heatwave like that.
AI is most reliable on examples similar to the ones it learned from.
Predictions inside and outside the data, which went from 15 to 30 degrees.
def predict_sales(temperature):
return 4 * temperature - 30
print(predict_sales(22))
print(predict_sales(0))Output
58
-30Tip
A prediction of -30 ice creams is a sign you've gone beyond what the model knows.
Now try it yourself
This lesson is free in Codiqo, with 6 questions on what you just read. You can only learn to code by writing code, so it ends with a short program you write yourself, which we run and check straight away.