Skip to course content
Free course

Machine Learning Foundations / Module 2

Module 2 lesson

Data Types and Column Roles

Unit ID: ML-M02-U02 Estimated active time: 25-30 minutes

Type is not the same as role

A column has a data type, such as text, number, date, or category.

A column also has a role, such as target, feature, metadata, or excluded.

These are different questions.

For example, final_quiz_score is numeric. But it is not a valid feature for a day-3 prediction because it is recorded later.

Common ML column types

TypeExampleNote
Numericday3_minutes_activeMay need missing-value handling
Categoricalpython_preparationMay need encoding later
Date/timestarted_module1_dateUseful for timing checks
Binarycompleted_module1_by_day10Often a target
Identifierrecord_idUsually metadata, not a feature

Inspect with pandas

Use:

df.info()
df.head()
df.dtypes

These commands do not tell you everything, but they help you start.

object columns in pandas often contain text or categories. You must inspect the values before deciding how to use them.

Practice

For each column in the Module 2 dataset, fill:

ColumnTypeRole
record_idtextmetadata
completed_module1_by_day10binarytarget
final_quiz_scorenumericexclude future information

Then complete the remaining columns.

Takeaway

Column type tells you what kind of value is stored. Column role tells you how the value may be used. A numeric column can still be unsafe for modelling.