\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage{algorithm,algpseudocode}
\usepackage{bm}
\usepackage{hyperref}
\usepackage{float}
\usepackage{subcaption}
\usepackage{enumitem}
\usepackage{xcolor}
\definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0}
\definecolor{aaltoBlue}{RGB}{0, 51, 102}
\definecolor{pinegreen}{cmyk}{0.92,0,0.59,0.25}
\definecolor{royalblue}{cmyk}{1,0.50,0,0}
\definecolor{lavander}{cmyk}{0,0.48,0,0}
\definecolor{violet}{cmyk}{0.79,0.88,0,0}
\definecolor{lightblue}{RGB}{173, 216, 230}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{calc,arrows.meta,positioning,fit,shapes.geometric,shapes.misc,intersections,patterns,decorations.pathreplacing,backgrounds,matrix}
\usepgfplotslibrary{fillbetween,groupplots}
\setcounter{secnumdepth}{-\maxdimen}
% Long unbreakable tokens (the ISO/IEC author names in citations, term names
% in the title) otherwise overflow the margin by a few points; a modest
% emergency stretch lets TeX loosen the paragraph instead.
\emergencystretch=2em
\usepackage{mleftright}
% Project macros used by this entry (auto-extracted).
\newcommand{\LapMat}[1]{\mL^{(#1)}}
\newcommand{\datapoint}{\vz}
\newcommand{\datapointspace}{\mathcal{Z}}
\newcommand{\dataset}{\mathcal{D}}
\newcommand{\defeq}{:=}
\newcommand{\edge}[2]{\{#1,#2\}}
\newcommand{\edges}{\mathcal{E}}
\newcommand{\edgeweight}{A}
\newcommand{\eigval}[1]{\lambda_{#1}}
\newcommand{\feature}{x}
\newcommand{\featuredim}{d}
\newcommand{\featureidx}{j}
\newcommand{\featuremtx}{\mX}
\newcommand{\featurespace}{\mathcal{X}}
\newcommand{\featuretrafovec}{{\bf \Phi}}
\newcommand{\featurevec}{\vx}
\newcommand{\graph}{\mathcal{G}}
\newcommand{\hilbertspace}{\mathcal{H}}
\newcommand{\hypothesis}{h}
\newcommand{\innerprodgeneric}[3]{\langle #1, #2 \rangle_{#3}}
\newcommand{\kernel}{k}
\newcommand{\kernelmap}[2]{k\big(#1,#2\big)}
\newcommand{\labelspace}{\mathcal{Y}}
\newcommand{\mL}[0]{{\bf L}}
\newcommand{\mX}[0]{{\bf X}}
\newcommand{\nodes}{\mathcal{V}}
\newcommand{\nrcategories}{K}
\newcommand{\nrfeatures}{\featuredim}
\newcommand{\pair}[2]{\left( #1,#2 \right)}
\newcommand{\predictedlabel}{\widehat{\truelabel}}
\newcommand{\reals}{\mathbb{R}}
\newcommand{\sampleidx}{r}
\newcommand{\samplesize}{m}
\newcommand{\truelabel}{y}
\newcommand{\vu}[0]{{\bf u}}
\newcommand{\vx}[0]{{\bf x}}
\newcommand{\vz}[0]{{\bf z}}

\begin{document}

\section{feature vector}

\subsection*{Author and editors}
Alexander Jung\textsuperscript{*}, Department of Computer Science, Aalto University, Espoo, Finland (ORCID \mbox{\href{https://orcid.org/0000-0001-7538-0990}{0000-0001-7538-0990}}) \\
Editors: Konstantina Olioumtsevits (ORCID \mbox{\href{https://orcid.org/0000-0003-2697-8659}{0000-0003-2697-8659}}), Ekkehard Schnoor (ORCID \mbox{\href{https://orcid.org/0000-0001-8252-1499}{0000-0001-8252-1499}}), Aalto University, Espoo, Finland \\
\textsuperscript{*}Corresponding author: \href{mailto:alex.jung@aalto.fi}{alex.jung@aalto.fi}

\subsection{Synonyms}
covariate vector, input vector, predictor vector

\subsection{Abstract}
A feature vector is a list of numbers describing a data point, with one entry for each 
            of its features. A feature is an attribute of the data point that is 
            measured or computed without substantial human supervision. The precise specification of 
            these measurements defines a feature transformation, the function that maps the 
            data point to its feature vector that belongs to an underlying feature space. 
            The feature space is usually a Euclidean space whose dimension is the number of
	    features. Nonnumeric features are encoded as numbers, a binary attribute as $0$ 
            or $1$ and a categorical one by one-hot encoding. The domain of the feature transformation 
            varies between applications: a data point can be a record of attributes, a text, 
            a digital image, an audio recording, or a node of a graph, whose feature vector collects entries
            of the eigenvectors of the Laplacian matrix. More generally, the feature space can be any
	    Hilbert space, and a kernel method uses such feature vectors without ever forming them, 
            through their inner products alone.

\subsection{Definition}
A machine learning (ML) method can represent a day at Krems an der Donau (Austria) by 
  four numbers. They are the air temperature at $06{:}00$ and at $15{:}00$ (UTC) of that day, and 
  the same two readings of the previous day. For 16 July 2024, these are $24.6$ and $30.8\,^{\circ}\mathrm{C}$, 
  and $22.2$ and $31.5\,^{\circ}\mathrm{C}$ the day before. Stacking these measurements into 
  a vector $\big(24.6, 30.8, 22.2, 31.5\big)^{\top} \in \reals^{4}$ gives a feature vector 
  that characterizes this day.
\par
  In general, the entries of a feature vector $\featurevec = \big(\feature_{1}, \ldots, \feature_{\nrfeatures}\big)^{\top}$ 
  are the features $\feature_{1}, \ldots, \feature_{\nrfeatures}$ of a data point: 
  attributes measured or computed without substantial human supervision (Duda et al., 2001). 
  A precise specification of how these attributes are measured defines a feature transformation
  \[
   \featuretrafovec : \datapointspace \rightarrow \featurespace, \quad \featurevec = \featuretrafovec(\datapoint) \text{.}
   \]
  The function $\featuretrafovec$ maps a data point $\datapoint \in
  \datapointspace$ to its feature vector $\featurevec$ in the feature space $\featurespace$ (Fig.~\ref{fig_featurevec_dict}). 
  Feature extraction, a preprocessing step, computes $\featuretrafovec(\datapoint)$ for a given
  data point (Bishop, 2006, p.~2). In supervised learning, the extracted feature vector is
  fed into a hypothesis $\hypothesis: \featurespace \rightarrow \labelspace$ that delivers a
  prediction $\predictedlabel = \hypothesis(\featurevec)$ of the label $\truelabel \in \labelspace$
  of the data point. The feature vectors $\featurevec^{(1)}, \ldots, \featurevec^{(\samplesize)}$ of the
  data points in a dataset $\dataset$ of dataset size $\samplesize$ are the rows of its
  feature matrix $\featuremtx \in \reals^{\samplesize \times \nrfeatures}$.
  \begin{figure}[H]
   \centering
   \begin{tikzpicture}[>=Stealth, every node/.style={font=\small}]
			\node[draw, rounded corners, minimum width=1.5cm, minimum height=1.2cm] (z) at (0,0) {$\datapoint$};
			\node[font=\footnotesize, below=1pt] at (z.south) {data point};
			\draw[->, thick] (z.east) -- (3.25,0) node[midway, above] {$\featuretrafovec$};
			\node[draw, minimum width=1.1cm, minimum height=0.6cm] (a1) at (3.9,0.9) {$\feature_{1}$};
			\node[draw, minimum width=1.1cm, minimum height=0.6cm] (a2) at (3.9,0.3) {$\feature_{2}$};
			\node[draw, minimum width=1.1cm, minimum height=0.6cm] (a3) at (3.9,-0.3) {$\vdots$};
			\node[draw, minimum width=1.1cm, minimum height=0.6cm] (a4) at (3.9,-0.9) {$\feature_{\nrfeatures}$};
			\node[font=\footnotesize, below=1pt] at (a4.south) {$\featurevec \in \featurespace$};
   \end{tikzpicture}
   \caption{A feature vector $\featurevec$ stacks the individual features
			$\feature_{1}, \,\ldots, \,\feature_{\nrfeatures}$ of a data point
			$\datapoint$, computed by the feature transformation $\featuretrafovec$. It
			is a point in the feature space $\featurespace$
			\label{fig_featurevec_dict}}
   \end{figure}
   One widely used choice for the feature space is a Euclidean space $\reals^{\nrfeatures}$ of 
   fixed dimension $\nrfeatures$ (Axler, 2024, Sect.~1A). For the weather example above, the
   feature space is $\featurespace=\reals^{4}$. The feature space $\reals^{\nrfeatures}$ serves
   ML applications whose features are numeric quantities, such as the four
   temperatures. Features measured on different scales are often brought to a common scale by
   feature standardization before training. The dimension $\nrfeatures$ ranges from a
   handful of measurements to millions of pixel intensities; a large $\nrfeatures$ invites the
   curse of dimensionality and motivates dimensionality reduction.
\par
  Nonnumeric features can also be entries of a feature vector, once their values are encoded as 
  real numbers (Goodfellow et al., 2016; Hastie et al., 2009). A binary 
  feature, such as whether there was rainfall during the day, is encoded as $0$ or $1$. A 
  categorical feature with $\nrcategories$ possible values, such as the season (winter,
  spring, summer, or autumn), is one-hot encoded. It occupies $\nrcategories$ entries of the 
  feature vector, all equal to $0$ except for a single entry equal to $1$, whose position names 
  the value. On 16 July 2024, $18.7$ millimeters of rain fell, and the season is summer, so the 
  two features are encoded as the entries $1$ and $\big(0, 0, 1, 0\big)$, respectively. 
  Stacked under the four temperatures, they give the feature vector $\featurevec = \big(24.6, 30.8, 22.2,
  31.5, 1, 0, 0, 1, 0\big)^{\top} \in \reals^{9}$ of the day. Records that mix numeric and nonnumeric
  attributes in this way, one row per data point, are tabular data.
\par
  While the range of the feature transformation $\featuretrafovec$ can often be chosen as 
  $\reals^{\nrfeatures}$, its domain $\datapointspace$ varies widely among ML applications. 
  For example, each element of $\datapointspace$ can be a text document, with its feature vector
  consisting of word occurrence counts or of an average of the word embeddings of its
  words. In computer vision, the elements of $\datapointspace$ are digital images, each an array of pixels. The feature vector then lists the red-green-blue (RGB) 
  intensities of those pixels, one entry per intensity (Fig.~\ref{fig_featurevec_patch_dict}). The 
  feature vector of an audio recording typically consists of signal values at a sequence 
  of time instants, one entry $\feature_{\featureidx}$ for each instant
  $\featureidx=1,\ldots,\nrfeatures$ (Fig.~\ref{fig_featurevec_audio_dict}), or of the entries of its
  spectrogram. Instead of fixing $\featuretrafovec$ by hand, deep learning methods learn it from
  data: the layers of a deep net up to the last one compute a feature vector, and the
  last layer is the hypothesis applied to it (feature learning; Goodfellow et al., 2016, Ch.~15).
  \begin{figure}[H]
  \centering
  % the four pixel colors of the patch, as RGB triples of its three planes
   \definecolor{pxone}{RGB}{78,85,67}
   \definecolor{pxtwo}{RGB}{80,87,69}
   \definecolor{pxthree}{RGB}{124,131,113}
   \definecolor{pxfour}{RGB}{125,132,114}
   \begin{tikzpicture}[scale=0.78, font=\scriptsize,
			every node/.style={inner sep=0pt},
			cell/.style={draw=black, fill=white}]
			% one grid per color channel, stepped so that every cell stays visible
			\foreach \dx/\dy/\chan/\a/\b/\c/\d in {%
				0/0/R/78/80/124/125,
				2.3/0.6/G/85/87/131/132,
				4.6/1.2/B/67/69/113/114} {
				\draw[cell] (\dx,\dy) rectangle ++(1,-1);
				\node at (\dx+0.5,\dy-0.5) {$\a$};
				\draw[cell] (\dx+1,\dy) rectangle ++(1,-1);
				\node at (\dx+1.5,\dy-0.5) {$\b$};
				\draw[cell] (\dx,\dy-1) rectangle ++(1,-1);
				\node at (\dx+0.5,\dy-1.5) {$\c$};
				\draw[cell] (\dx+1,\dy-1) rectangle ++(1,-1);
				\node at (\dx+1.5,\dy-1.5) {$\d$};
				\node[font=\small] at (\dx+1.0,\dy+0.34) {\chan};
			}
			% the patch itself, each pixel filled with its own three intensities
			\foreach \dx/\dy/\col/\idx/\ink in {%
				0/0/pxone/1/white, 1/0/pxtwo/2/white,
				0/-1/pxthree/3/black, 1/-1/pxfour/4/black} {
				\draw[draw=black, fill=\col] (7.9+\dx,1.2+\dy) rectangle ++(1,-1);
				\node[font=\tiny, \ink, anchor=north west]
					at (7.96+\dx,1.16+\dy) {\idx};
			}
			\node[font=\small, align=center] at (8.9,1.54) {the patch in color};
     \end{tikzpicture}
     \\[0.7em]
		$\featurevec = \big(
			\underbrace{78, 85, 67}_{\text{pixel } 1},\;
			\underbrace{80, 87, 69}_{\text{pixel } 2},\;
			\underbrace{124, 131, 113}_{\text{pixel } 3},\;
			\underbrace{125, 132, 114}_{\text{pixel } 4}
			\big)^{\top} \in \reals^{12}$
		\caption{A $2 \times 2$ patch of a digital image and its feature vector. The
			patch has one array (or grid) of intensities per color channel, labeled R,
			G, and B, and each array holds the same four pixels in the same positions.
			On the right, the patch is shown in color, its pixels numbered $1$ to $4$: pixel
			$1$ has the color with the three intensities $78$, $85$, and $67$. Stacking
			those three values for pixel $1$, then those for pixel $2$, and so on gives a
			feature vector with $\nrfeatures = 12$ entries
			\label{fig_featurevec_patch_dict}}
     \end{figure}
     \begin{figure}[H]
     \begin{center}
     \begin{tikzpicture}
	\begin{axis}[
			width=0.86\columnwidth, height=0.36\columnwidth,
			axis lines=left,
			xlabel={instant $\featureidx$},
			ylabel={entry $\feature_{\featureidx}$},
			xmin=0, xmax=256, ymin=-1, ymax=1,
			label style={font=\small},
			tick label style={font=\footnotesize},
		]
			\addplot[black, line width=0.5pt, mark=none]
				table[col sep=comma, x=j, y=x]{featurevec_audio.csv};
      \end{axis}
      \end{tikzpicture}
      \end{center}
      \caption{The feature vector of an audio recording read at $256$ time instants.
			Entry $\feature_{\featureidx}$ is the value its signal takes at instant
			$\featureidx$, so this data point is a point of $\reals^{256}$
			\label{fig_featurevec_audio_dict}}
      \end{figure}
  The domain $\datapointspace$ can also be the node set $\nodes$ of a weighted graph
  $\graph = \pair{\nodes}{\edges}$, a similarity graph whose node $\sampleidx \in \nodes \defeq \{1, \ldots,
  \samplesize\}$ is the $\sampleidx$th data point. An edge $\edge{\sampleidx}{\sampleidx'} \in \edges$
  with edge weight $\edgeweight_{\sampleidx,\sampleidx'} > 0$ records that the two data points
  are similar in a domain-specific sense, such as two web pages linked to each other or two weather
  stations a few kilometers apart. Unlike a $k$-nearest-neighbor graph ($k$-NN graph), which is built from features already at hand, such a
  graph presupposes no features; it delivers them. Let $\vu^{(1)}, \ldots,
  \vu^{(\nrfeatures)}$ be eigenvectors of the Laplacian matrix $\LapMat{\graph}$, each a
  vector in $\reals^{\samplesize}$, for its $\nrfeatures$ smallest eigenvalues $\eigval{1} \leq \ldots \leq \eigval{\nrfeatures}$. The
  feature vector of node $\sampleidx$ collects the $\sampleidx$th entries of these eigenvectors,
  \[
  \featurevec^{(\sampleidx)} = \big(u^{(1)}_{\sampleidx}, \ldots, u^{(\nrfeatures)}_{\sampleidx}\big)^{\top} \in \reals^{\nrfeatures}
  \]
  (von Luxburg, 2007, Sect.~4; Hastie et al., 2009, Sect.~14.5.3). An
  eigenvector with a small eigenvalue varies little across edges with large edge weight
  (see Laplacian matrix), so nodes joined by such edges receive nearby feature vectors: the map
  $\sampleidx \mapsto \featurevec^{(\sampleidx)}$ is an embedding of the nodes into $\reals^{\nrfeatures}$.
  The eigenvector $\vu^{(2)}$, for the algebraic connectivity $\eigval{2}$, is the Fiedler vector of $\graph$.
  Spectral clustering applies this construction before clustering the resulting feature vectors
  (von Luxburg, 2007, Sect.~4), and a graph neural network (GNN) learns node feature vectors from the same graph by
  message passing along its edges.
\par
  The notion of a Euclidean feature vector can be generalized by replacing the feature space 
  $\reals^{\nrfeatures}$ with an arbitrary Hilbert space $\hilbertspace$. Here, a feature vector 
  is the image of a feature transformation
  \[ 
    \featuretrafovec : \datapointspace \rightarrow \hilbertspace \text{,}
  \]
  and any Hilbert space can serve as the feature space (Shalev-Shwartz and Ben-David, 2014, Sect.~16.1). 
  One construction of such a feature vector uses a kernel $\kernel: \reals^{\nrfeatures} \times \reals^{\nrfeatures}
  \rightarrow \reals$. The kernel assigns to each $\vz \in \reals^{\nrfeatures}$ the function $\kernelmap{\vz}{\cdot}:
  \reals^{\nrfeatures} \rightarrow \reals$, whose value at $\vz' \in \reals^{\nrfeatures}$ is $\kernelmap{\vz}{\vz'}$. 
  That function is itself a vector in a reproducing kernel Hilbert space (RKHS) $\hilbertspace$, a Hilbert space whose
  elements are functions on $\reals^{\nrfeatures}$ (Aronszajn, 1950, Part~I, Sect.~2; 
  Schölkopf and Smola, 2002, Sect.~2.2.2). A kernel method, such as the support vector machine (SVM),
  kernel ridge regression, or a Gaussian process (GP), uses elements of $\hilbertspace$ as feature
  vectors without ever forming them explicitly. Many ML methods use feature vectors only
  through their inner products, which the reproducing property reduces to kernel evaluations,
  $\innerprodgeneric{\kernelmap{\vz}{\cdot}}{\kernelmap{\vz'}{\cdot}}{\hilbertspace}
	= \kernelmap{\vz}{\vz'}$ (Schölkopf and Smola, 2002, Eq.~(2.30)).

\subsection{Cross References}
feature, feature space, feature transformation, data point, vector, Euclidean space, feature matrix, input vector, preprocessing, feature learning, dimensionality reduction, tabular data, graph, weighted graph, similarity graph, Laplacian matrix, eigenvector, embedding, spectral clustering, kernel, RKHS, kernel method, Hilbert space

\subsection{References}
\begin{enumerate}
  \item Axler (2024). Linear Algebra Done Right. 4th ed., Springer, Cham, Switzerland.
  \item Bishop (2006). Pattern Recognition and Machine Learning. Springer Science+Business Media, New York, NY, USA.
  \item Duda et al. (2001). Pattern Classification. 2nd ed., Wiley, New York, NY, USA.
  \item Goodfellow et al. (2016). Deep Learning. MIT Press, Cambridge, MA, USA.
  \item Schölkopf and Smola (2002). Learning with Kernels: Support Vector Machines, Regularization, Optimization, and Beyond. MIT Press, Cambridge, MA, USA.
  \item von Luxburg (2007). A tutorial on spectral clustering. Statist. Comput., 17(4), pp.~395--416.
  \item Shalev-Shwartz and Ben-David (2014). Understanding Machine Learning: From Theory to Algorithms. Cambridge Univ. Press, New York, NY, USA.
  \item Aronszajn (1950). Theory of Reproducing Kernels. Trans. Am. Math. Soc., 68(3), pp.~337--404.
  \item Hastie et al. (2009). The Elements of Statistical Learning: Data Mining, Inference, and Prediction. 2nd ed., Springer Science+Business Media, New York, NY, USA.
\end{enumerate}

\end{document}
