Data Representation in Machine Learning
Data representation is the step of deciding how data processed by machine learning is represented.
Why Opening Pages Matter
Before you open the first chapter of a technical book, its opening pages can tell you what you are signing up for. In the machine learning with Python material this article draws on, the front matter contains a short statement of what the reader will learn, followed by identifying details about the publisher and the authors. Reading these two parts carefully helps you decide whether the book fits your goals and gives you a mental map before you start.
This article follows one thread through that front matter and then uses it to introduce a core idea of machine learning: data representation. You will trace how the goals are listed, separate learning content from identifying details, and then practice deciding how a real-world record should be represented before a learning system sees it.
Two Kinds of Front-Matter Information
A book's front matter contains two different kinds of information. Learning goals describe what the book teaches. Publisher details identify who produced the book and which edition you hold. Keeping these two categories separate is the central skill, because they answer different questions. A learning goal answers the question what will I be able to do or understand? A publisher detail answers the question who made this, and which copy is this?
Because the two categories answer different questions, mixing them up leads to wrong conclusions. A publisher's social media handle tells you where the publisher can be followed. It says nothing about what the book covers. The ISBN identifies the title, but it does not describe any skill you will gain.
Reading the Seven Goals in Order
The section headed with the phrase that introduces the book's goals is a collection of seven separate statements. Each one names an area of study, and together they form the book's stated scope. The goals are meant to be read in the order the book gives them, because that order shows how the scope develops.
The source material summarizes the range of the goals. They run from fundamental concepts and algorithms, through data representation, evaluation, pipelines, and text data, and end with suggestions for improving your skills. Reading in that order traces a path from foundations toward practice and then toward your own growth.
- 1Start with the foundational goal about fundamental concepts and algorithms. It tells you the book builds its understanding from the ground up.
- 2Read the data representation goal next. It introduces the step where data is prepared for learning, which the later material depends on.
- 3Move to the evaluation goal. Its wording suggests attention to measuring how well a method works, including advanced methods for model evaluation and parameter tuning.
- 4Follow with the pipelines goal, which moves from individual methods toward chaining steps together.
- 5Read the text data goal, which points to methods for working with a particular kind of data.
- 6Finish with the suggestions goal, which promises guidance for improving your skills rather than a certification.
Identifying Details on the Same Pages
The same pages that hold the learning goals also carry publisher details. In the source material, these include the category line PYTHON/MACHINE LEARNING, the ISBN 978-1-449-36941-5, the publisher's Twitter handle @oreillymedia, and its facebook.com/oreilly page. The ISBN is the number that identifies this particular title, so it is the detail you would use to confirm you hold this specific book.
The pages also contain endorsement and author information. A reader quoted as a Senior Researcher at Microsoft Research calls the book a practical resource for anyone starting to use machine learning in Python. The author biographies describe Andreas Müller, a maintainer and core contributor to scikit-learn who earlier worked as a machine learning researcher on computer vision applications at Amazon, and Sarah Guido, a data scientist who most recently served as Lead Data Scientist at Bitly. These biographies tell you who wrote the material. They do not list the topics it teaches.
Data Representation Defined
Data representation is the step of deciding how data processed by machine learning is represented. It is the step that turns information about the world into a form that a learning system can work with.
Before a machine learning system can learn anything, the data it receives has to be in a form it can process. The same real-world information can be written down in many different ways, and each way changes what the system can make of it. Data representation is the topic that covers this step: deciding how the data is represented for machine learning.
Data representation sits at the very start of the learning process. Choices made here shape everything that follows, and they are made before learning begins. That timing is why the question is worth understanding before you look at any particular method.
The Two Questions of Representation
Data representation asks two linked questions. The first is how the data should be represented: in what form it is expressed so that machine learning can work with it. The second is which data aspects to focus on: which parts of the information deserve attention at all. Both concerns are needed. A representation that captures the wrong aspects will not help the learner, and a well-chosen set of aspects still needs a usable form.
The source describes two checks that connect the questions. Each aspect kept should be checked against the goal you are trying to reach. Each form chosen should preserve what that aspect means. So the selection question constrains the form question, and the form question determines whether a selected aspect survives the trip into the learning system intact.
Tracing a Sales Record
The source offers a small, invented case to see the two questions at work. A shop keeps a record for each sale. Every record includes a date, a product name, a price, and the name of the store branch. A team wants a machine learning system to help predict how much a customer will spend.
Applying the two questions to a sales record
Each sale record holds a date, a product name, a price, and a store branch name. The goal is to predict how much a customer will spend. Decide which aspects to keep and how to represent each one.
- 1Select the aspects against the goal
The goal is predicting spending. The price is directly tied to spending, so it is the clearest aspect to keep. The product name and the store branch may explain differences in spending, so they are plausible to keep. Each kept aspect must be justified by the goal, not included merely because it is present.
- 2Choose a form for the product name
A product name is text, and a learning system needs a usable form. One reasonable choice is to express each product as a category, so that the form preserves the idea that two sales involved the same kind of product.
- 3Choose a form for the store branch
A branch name is also a label rather than a quantity. Representing it as a category keeps the meaning that two sales happened at the same branch, without treating the branch name as a number with an order.
- 4Check the price form
A price is already a number, so its form is simple. The check is whether the number keeps its meaning. A value recorded in one currency should not be mixed with values in another without a deliberate decision.
- 5Decide on the date
The date may matter because spending can vary over time. Whether to keep the full date or only parts of it is a choice to justify against the goal. The source does not settle this, so the decision belongs to the team and should be stated.
The team keeps price, product category, and branch category as the core aspects, with the date as a justified candidate. Each form preserves what its aspect means, and each aspect is tied to the goal of predicting spending.
From Fruit to Numeric Features
Here is a different, original illustration. Suppose a raw item is a single apple. Its appearance and taste are not numbers, so before any learning can happen, the team must choose which aspects of the apple to keep and express each one as a value. Each value stands for one chosen aspect, and together they form the representation of that apple.
Notice what the two questions do here. The selection question decided that weight, colour, and sweetness matter for the goal, while the apple's exact shape, smell, and brand were set aside. The form question decided that colour is expressed as a yes or no value, because that form preserves the distinction the team cares about. If the team had chosen to keep colour but expressed it as an arbitrary number with no meaning, the representation would have lost what colour means.
Mistakes When Choosing Representations
Common mistake Treating representation as a step to finish after learning starts
What it looks likeAdjusting the data form only once a model has already been trained and disappointing results appear.
Why it failsChoices about representation are made before learning begins and shape what the system can learn.
Do this insteadMake representation decisions deliberately at the start, and revisit them as explicit, justified choices rather than afterthoughts.
Common mistake Keeping every available field because it exists
What it looks likeIncluding a branch name, a date, and an internal record number in the sales data without asking whether each one bears on spending.
Why it failsEach aspect kept should be checked against the goal. An aspect with no link to the goal adds noise rather than meaning.
Do this insteadWrite down the goal first, then keep only the aspects that bear on it, stating why each one was kept.
Common mistake Choosing a form that changes what an aspect means
What it looks likeEncoding a product category as ordinary numbers such as 1, 2, 3, which can suggest an order that does not exist.
Why it failsEach form chosen should preserve what the aspect means. A form that implies a false order distorts the aspect.
Do this insteadPick a form whose structure matches the meaning of the aspect, such as a category when the values are labels.
Common mistake Confusing publisher details with learning goals when reading front matter
What it looks likeReading the ISBN or a social handle and concluding that the book teaches a particular skill.
Why it failsPublisher details identify the book and its creators; they are not learning content.
Do this insteadRead the goals for coverage and the publisher details for identification, keeping the two questions separate.
Practice Applying the Two Questions
A library records each loan with the borrower's membership type, the subject of the book, the loan length in days, and the date it was returned. The team wants to predict whether a book will be returned late. Decide which aspects to keep and how to represent each one. For each choice, state the goal link that justifies it, and say which form you chose and why that form keeps the meaning of the aspect.
Hints
- Start from the goal: what is the late return a function of? Only keep aspects that bear on it.
- Ask whether each aspect is a number, a label, or a date, and whether its form implies an order that the real aspect does not have.
- Consider whether the return date itself is an aspect to keep as input, or whether it reveals the answer you are trying to predict.
Checking Your Representation Choices
A good check after you have chosen a representation is to read your decisions back against the two questions. Did you explain why each kept aspect serves the goal? Did you pick a form for each aspect that keeps what the aspect means? If either answer is no, the representation needs revision before any learning begins.
Key Takeaways
- Front matter holds two kinds of information: learning goals describe what a book teaches, while publisher details such as the ISBN identify the publication and its creators.
- Data representation is the step of deciding how data processed by machine learning is represented, and it happens before learning begins.
- Data representation asks two linked questions: how the data should be represented, and which data aspects to focus on.
- Each aspect kept should be checked against the goal, and each form chosen should preserve what that aspect means.
- Choices about representation shape what the learning system can make of the data, so they deserve deliberate justification.