From Tables to Features and Targets
Machine learning starts with a table
Scenario: A subscription team wants to predict which customers may cancel. It has one row per customer and columns for age, plan, income, tenure, and whether the customer cancelled.
Machine learning (ML) is a way to learn patterns from examples instead of writing every rule by hand. A feature is an input used to make a prediction. The target, also called the label, is the answer the model should learn to predict. In this example, tenure is a feature and cancelled is the target.
Pandas is a Python library for tables. Its DataFrame holds rows and named columns. NumPy is a numerical computing library beneath much of the Python ML ecosystem. It provides fast arrays and values such as NaN, meaning not a number, which Pandas commonly uses for missing numeric data.
Start by inspecting shape, column names, data types, missing counts, and sample values: df.shape, df.dtypes, df.isna().sum(), and df.head(). A column that looks numeric may actually have the object data type because one row contains text.
Analogy: Preparing data is like checking ingredients before cooking. A beautiful recipe cannot rescue spoiled food, missing measurements, or a label pasted onto the wrong jar.
Goal: In the data-hygiene lab, diagnose invalid numeric values and missing cells before creating a clean feature table.