Datasets & Data Types

Rows become examples; columns become features, labels, identifiers, and context.

A Table Is Not Yet A Learning Problem

A Titanic table contains age, passenger class, ticket, fare, cabin, port, and survival. A beginner may treat every column as “just data.” But averaging ticket numbers is meaningless, class is ordered but not a physical measurement, and survival can be either a descriptive column or the target of a prediction task.

A data type describes what operations and assumptions are valid—not merely how a value is stored.

Retrieval Warm-Up

  1. What is fixed during inference but adjusted during training?
  2. What is the difference between a prediction and a label?
  3. Why can training accuracy fail to measure generalisation?

One concrete dataset

PassengerIdPclassSexAgeFareEmbarkedSurvived
13male227.25S0
21female3871.28C1
63malemissing8.46Q0

Each row is an observation/sample/instance. For survival prediction, Pclass through Embarked may be features, Survived is the label, and PassengerId is an identifier.

Column-Type Explorer

Click a column

Numerical

A measured quantity; differences and averages are meaningful.

Types Determine Valid Transformations

TypeExampleMeaning for modelling
NumericalAge: 38, fare: 71.28Arithmetic, order, distances; check units and skew.
CategoricalEmbarked: C, Q, SNames/groups without order; encode deliberately.
OrdinalCabin class: 1st, 2nd, 3rdOrdered categories, but gaps are not equal.
TextPassenger name or reviewVariable length; tokens and meaning require representation.
Time seriesTimestamped daily demandOrder, lags, trend, seasonality; random shuffle may leak future.
ImagePassenger photographPixel grid with spatial channels and resolution.
BooleanSurvived: yes/noTwo-state category, often a label.
IdentifierPassengerId, ticket numberLocates records; usually not a meaningful numeric quantity.

Features, Labels, Metadata, And Leakage

Feature

Available input used to predict, such as age at boarding.

Label/target

Observed answer, such as survived.

Identifier

Joins records but should not imply magnitude.

Metadata

Context for slicing or auditing; may or may not be used by the model.

Leakage

Information unavailable at prediction time, such as a rescue record.

Missing value

Unknown/unrecorded—not automatically zero.

Train, Validation, And Test

Training set: adjusts parameters. Validation set: compares modelling decisions. Test set: estimates final performance after choices are frozen.

891 rows → train 623 · validation 134 · test 134

Split before learning imputations, vocabularies, or scaling constants. For time series, train on the past and test on the future. For related passengers or repeated entities, grouped splitting may prevent near-duplicates crossing boundaries.

Inspect Before Transforming

import pandas as pd

df = pd.read_csv("notebook/data/titanic.csv")
print(df.shape)             # (891, 12)
print(df.dtypes)            # storage types, not full semantic types
print(df.isna().sum())      # Age 177, Cabin 687, Embarked 2
print(df.nunique())

roles = {
    "PassengerId": "identifier",
    "Pclass": "ordinal feature",
    "Sex": "categorical feature",
    "Age": "numerical feature",
    "Survived": "binary label",
}

Worked Classification

A column stores values 1, 2, 3 for cabin class.

It is physically stored as an integer, semantically ordinal, and should not automatically be treated as a continuous measurement. A ticket number contains digits but is an identifier/categorical token, not a quantity.

Mastery Check

1. Classify age, port, class, review, timestamp, image, ticket, and survival.

2. Why is missing age not age zero?

3. Give a leakage feature for survival prediction.

4. Explain the three data splits and when each may influence decisions.

5. Tomorrow retrieve all data types; in three days classify a new schema cold.

Next: What Kind Of Feedback Exists?

Now that examples, features, and labels are concrete, we can classify learning problems by what signal the learner receives.