---
title: "Data as a Matrix: Rows, Features and the Target"
description: "Almost every method takes the same shape of input: one row per example, one column per feature, and a separate target column. Getting real data into that shape means encoding categories, scaling colum"
canonical: https://lightmysky.com/learn/computing/data-as-a-matrix-rows-features-and-the-target-mt_KEN-TU1Gpn
source: https://lightmysky.com/learn/computing/data-as-a-matrix-rows-features-and-the-target-mt_KEN-TU1Gpn.md
retrieved: 2026-09-12
---

> **Agent view.** This is the Markdown twin of the page, for tools and assistants.
> When to use this site, and the call that answers each job: https://lightmysky.com/agent-instructions.md
> API description (OpenAPI 3.1): https://lightmysky.com/openapi.json · Authentication: https://lightmysky.com/auth.md
> Pricing: https://lightmysky.com/pricing.md · Catalog: https://lightmysky.com/llms.txt · Full catalog: https://lightmysky.com/llms-full.txt
> Every machine-readable file on this domain: https://lightmysky.com/.well-known/ai-catalog.json
> Ask for Markdown with `Accept: text/markdown`, a `.md` address, or `?mode=agent`.

# Data as a Matrix: Rows, Features and the Target

Almost every method takes the same shape of input: one row per example, one column per feature, and a separate target column. Getting real data into that shape means encoding categories, scaling columns onto comparable ranges, and deciding what one row is.

Subject: Computing · Area: Machine Learning · Ages 18 to 20
Page: https://lightmysky.com/learn/computing/data-as-a-matrix-rows-features-and-the-target-mt_KEN-TU1Gpn

## Ready when they can

- Turn a table with text categories into a numeric feature matrix
- Say why scaling matters when features are measured in different units
- Decide what one row should represent for a stated prediction question

## Lesson: Shaping data into rows and columns

Almost every method expects one grid: one row per example, one column per feature, plus a separate target column. The box where a row meets a column is a cell with a single value. For house sales you might use rooms, area, and neighborhood as features with price as the target.

**Example.** Models only multiply and add numbers, so words must become numbers first. Turn each neighborhood into its own 0 or 1 flag, with 1 marking a match. A table with 4 text columns and 3 numeric ones needs 4 columns encoded, while the numbers stay as they are.

Features must live on comparable ranges, or the biggest numbers decide everything. Income spans thousands while schooling spans single digits, so raw gaps in income drown schooling out of every distance. Rescale each column before you train.

**Tip.** Let the question pick the row: to predict popcorn buys, make one row one person visit with a yes or no attached. Keep labels like seat numbers and IDs out of the features. In a diagnosis table you would also drop a treatment given after diagnosis, keeping the illness status apart as the target.

**Recap.** One row per example, numbers only, comparable ranges, and the target kept apart is the shape every model wants.

## Practice

15 questions on this page, each with its working shown.

## Needs first

- [Matrix Multiplication and What It Represents](https://lightmysky.com/learn/mathematics/matrix-multiplication-and-what-it-represents-mt_0fJOMPlCxr)
- [Lists: Many Values Under One Name](https://lightmysky.com/learn/computing/lists-many-values-under-one-name-mt_ipB6kmyK85)
- [Vectors: Notation, Addition and Scalar Multiples](https://lightmysky.com/learn/mathematics/vectors-notation-addition-and-scalar-multiples-mt_NkqmrL7pLe)

## Opens up

- [Clustering: Structure Without Labels](https://lightmysky.com/learn/computing/clustering-structure-without-labels-mt_BAMGOlWgRY)
- [Linear Regression by Least Squares](https://lightmysky.com/learn/computing/linear-regression-by-least-squares-mt_QRRkpIrwWs)
- [Regularisation: Charging for Complexity](https://lightmysky.com/learn/computing/regularisation-charging-for-complexity-mt_RVgsDP0XzP)
