AI Hints
Statistics & Math for ML · Lesson 2 of 138

Data and Variables

Rows and columns.

⏱ 2 min read▶ Video at 1:09🎓 Free
Watch this lesson in the Statistics & Math for ML courseWatch on YouTube ↗Full Statistics & Math for ML course

Most data comes as a table. Each row is one thing you measured, like one person, one sale, or one day. Each column is one thing you measured about it, like age, price, or temperature. Statisticians call the columns variables.

Data and Variables
From the video: Data and Variables
  • Data is usually a table
  • Rows are things
  • Columns are variables

A tiny dataset

Here are five students. Each row is a student. The columns are their name, hours studied, exam score, and whether they passed. In machine learning, the columns we use to predict are called features. The one we want to predict, like passed, is called the target, or the label.

namehoursscorepassed
Ana255no
Ben572yes
Cara890yes
Dev140no
Eli681yes

A table in Python

In Python, a simple way to hold a column is a list. Here, hours and scores are two lists, where the same position is the same student. Len counts the rows. And zip walks through two columns together, row by row. Run it.

students.pypython
hours = [2, 5, 8, 1, 6]
scores = [55, 72, 90, 40, 81]

print("students:", len(scores))
for h, s in zip(hours, scores):
    print(h, "hours ->", s, "points")
Output
students: 5
2 hours -> 55 points
5 hours -> 72 points
8 hours -> 90 points
1 hours -> 40 points
6 hours -> 81 points

Summary

Rows are the things we measure, and columns are variables. Features predict, and the target is what we want to predict. Next, the different types of data.

Key takeaways
  • Rows and columns
  • Features and target
  • Lists hold columns
Next up: Types of Data — numbers and categories