How is a dataset represented as a matrix in machine learning?

Quick Overview

Asks how a tabular dataset maps onto a feature matrix and a label vector for machine learning models. Tests the samples-by-features convention, how shapes line up in operations such as a linear model's prediction, and how categorical, text and image data become numeric columns.

How is a dataset represented as a matrix in machine learning?

Role: Data Scientist

Category: Statistics & Math

Difficulty: easy

Interview Round: Other

How is a dataset represented as a matrix in machine learning? ```hint Check the shapes Write down the shapes of the data, the labels and the weights of a linear model, and check that a prediction for every example comes out of one matrix operation. ``` ### What a Strong Answer Covers - What a row and a column of the matrix stand for, and the usual notation for its shape. - Where the labels live and what shape they have. - Why the orientation matters for matrix operations such as computing predictions. - How non-numeric data such as categories, text or images becomes numeric columns. - At least one practical pitfall with shapes or preprocessing. ### Follow-up Questions - What changes in the matrix when a linear model has an intercept, and why? - What are the shapes of $X^\top X$ and $X X^\top$, and what does each one measure? - When would you store the feature matrix as a sparse matrix? - How would you lay out a dataset of time series or images for a model that does not take flat feature vectors?

Overview: Asks how a tabular dataset maps onto a feature matrix and a label vector for machine learning models. Tests the samples-by-features convention, how shapes line up in operations such as a linear model's prediction, and how categorical, text and image data become numeric columns.

PracHub logo
General
Nov 24, 2026
easyData ScientistOtherStatistics & Math
0
0

How is a dataset represented as a matrix in machine learning?

What a Strong Answer Covers Guidance

  • What a row and a column of the matrix stand for, and the usual notation for its shape.
  • Where the labels live and what shape they have.
  • Why the orientation matters for matrix operations such as computing predictions.
  • How non-numeric data such as categories, text or images becomes numeric columns.
  • At least one practical pitfall with shapes or preprocessing.

Follow-up Questions Guidance

  • What changes in the matrix when a linear model has an intercept, and why?
  • What are the shapes of X⊤XX^\top X and XX⊤X X^\top , and what does each one measure?
  • When would you store the feature matrix as a sparse matrix?
  • How would you lay out a dataset of time series or images for a model that does not take flat feature vectors?