Multi-Output Linear Prediction
- 27Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
- spaceFlip card
- KI knew it
- DI didn't know it
- ←Previous card
- →Next card
What are the two cases of extending linear prediction beyond one input and one output?
Case 1: One input, multiple outputs (solved by multiple formulas). Case 2: Multiple inputs, one or more outputs (the focus of this module).
Or swipe the card
27 cards
What are the two cases of extending linear prediction beyond one input and one output?
Case 1: One input, multiple outputs (solved by multiple formulas). Case 2: Multiple inputs, one or more outputs (the focus of this module).
How is a single input x represented when there are multiple outputs?
You can have three separate formulas inside the system: g1(x) = y1, g2(x) = y2, g3(x) = y3.
How are inputs and outputs represented in the matrix framework for multiple inputs and outputs?
The input x is a row in a matrix X (each row is an observation, each column a feature). The output y is a row in a matrix Y (each column an output). For one output, Y is a vector.
What is the basic machine learning framework described in this module?
We have a table of data: some rows have known outputs (training data) and others do not (test data). We use the training rows to learn a predictor, then use it to predict outputs for the test rows.
How are non-numerical features (e.g., text like 'married') handled?
They are either converted to numbers (e.g., categories) or the column is discarded.
What are the dimensions of the input matrix X?
X has n rows (number of observations) and d columns (number of features or dimensions).
Why is an extra column of ones added to the input matrix X?
To incorporate a bias term (y-intercept) in the linear model. The column of ones multiplied by w0 gives the bias.
What do w0 and w1...wd represent in the linear predictor?
w0 is the bias (y-intercept); w1 through wd are coefficients (slopes) for each feature.
How is a prediction made for a new input row after training?
Compute the dot product of the row (including the 1 for bias) with the weight vector w to get the predicted output.
What is the goal of training in linear regression?
To calculate the optimal weight vector w from the known input matrix X and output vector y.
Why is it better to use squared error rather than raw error?
Raw errors can cancel out (positive and negative). Squaring makes all errors positive and penalizes larger errors more.
What is the mean squared error (MSE) formula in scalar form?
MSE = rac{1}{n} sum_{i=1}^{n} (y_{ ext{pred},i} - y_i)^2
What is the matrix form of the mean squared error?
MSE = rac{1}{n} (Xw - y)^T (Xw - y)
How do we find the w that minimizes the MSE?
Take the gradient of MSE with respect to w, set it to zero, and solve for w.
What is the gradient of the MSE with respect to w?
abla_w MSE = rac{2}{n} X^T (Xw - y)$$What equation do we get by setting the gradient to zero?
XTXw=XTy
What is the normal equation for linear regression?
w=(XTX)−1XTy
What is the shape of X^T X and why is it manageable?
X^T X is d x d (d is number of features). Though X is large (n x d), the product shrinks to a small d x d matrix.
What is the shape of X^T y?
X^T y is d x m, where d is number of features and m is number of outputs.
What is the shape of the optimal weight matrix w?
w is d x m, where d is number of features and m is number of outputs.
In the example with 5 features and 3 outputs, what is the size of w?
5 rows and 3 columns (5 x 3).
How is w computed using numpy in the example?
Using the formula: w = np.linalg.inv(X.T @ X) @ X.T @ y
Interpret the calculated w from the example: w0=426, w1=-60, w2=149, w3=3.7.
Bias (base credit score) = 426; each additional year of age decreases score by 60; each year with current employer increases score by 149; each extra $1000 income increases score by 3.7.
What is the general machine learning framework for prediction?
We have an input x, we put it into a function g(x) (the predictor) to get predicted output y. We train g(x) using data, then use it on new x.
What are the two approaches to finding the best g(x)?
Analytical (e.g., solving the normal equation for linear regression) and iterative (e.g., gradient descent, where we guess g, check error, and refine).
How does the learned g(x) relate to the ideal function f(x)?
g(x) is an approximation of the unknown true function f(x) that maps inputs to outputs. Training aims to make g close to f.
What is the role of the library function (e.g., sklearn.linear_model.LinearRegression) in this context?
It encapsulates the matrix operations and optimization, allowing the same code to handle single or multiple inputs/outputs.

Ask anything
We've read this whole study set, so questions about it get the best answers.