Warm-up
Imagine you’re running a Machine Learning experiment. You need a place to store the accuracy of your model, the name of your dataset, or whether training has finished. Where do you put this information? That’s where variables come in. They’re like labeled containers for your data. Today we’ll explore variables and the main types of data they hold.
Concept Explanation
A variable is like a box with a label.
You can store a value inside and use it later.
👉 Example:

Here:
-
pricestores a number, -
locationstores text, -
is_luxurystores a True/False value.
Numbers are everywhere in ML: dataset sizes, training epochs, accuracy scores, etc.
Useful for counting things like number of training iterations.
Floats are essential in ML since accuracy, loss, probabilities → all decimals.
Rare in ML, but Python supports them.
👉 Example:

Mostly used in advanced math/scientific fields, not common in ML pipelines.
Strings are sequences of characters inside 'single' or "double quotes".
👉 Example:

You can join strings:

Or use f-strings (modern and cleaner):

Strings are key in ML for storing dataset names, file paths, or labels.
Booleans are used in decision-making.

👉 Example:

In ML, you’ll often get booleans when checking conditions, like whether accuracy crossed a threshold.
Quick Review
int → whole numbers (
epochs = 50)float → decimals (
accuracy = 0.87)complex → advanced numbers (
z = 2 + 3j)string → text (
dataset_name = "Iris")boolean → true/false (
is_trained = True)
Coding Examples

Why it matters for ML
Integers → number of epochs, dataset size, batch size.
Floats → accuracy, loss, probability values.
Strings → dataset names, file paths, labels.
Booleans → check conditions like “is the model good enough?”
Homework
-
Create a variable
age = 25. Print it. -
Store your name in a string variable and print:
Hello, <your name>. -
Save accuracy as
0.87and print:Model accuracy: 0.87. -
Create a boolean variable
is_student = True. Print it. -
Bonus: Use an f-string to print your name and age in one line.
Answers to Last Session’s Exercises

Summary
- Variables are containers for data.
- Python has different data types: int, float, complex, string, boolean.
- Each type is crucial in ML: integers for counts, floats for metrics, strings for labels, booleans for decisions.
FAQ
- Q: Do I need to declare variable type in Python?
A: No, Python automatically figures it out (dynamic typing). - Q: Why are floats so important in ML?
A: Because most metrics (accuracy, probability, loss) are decimals.
Sneak Peek (Next Class Teaser)
Now that we know how to store values, what if we want to do math with them?Next session, we’ll dive into Operators, the tools that let us add, compare, and combine data. This is the math engine behind every ML algorithm!