# Challenge: Sum of Squared Error Calculator

Implement a Python program to calculate the sum of squared error.

We'll cover the following

## Statement

Complete the calculateSSE function that accepts arrays, $A,\ \bold{b},\ \text{and}\ \bold{w}$ representing a linear system and computes the Sum of Squared Error for the respective system in given $\bold{w}$.

## Example

$A = \begin{bmatrix} 1 & -2 \\ 3 & 1 \\ 1 & 1 \end{bmatrix} \bold w = \begin{bmatrix} 1\\1 \end{bmatrix} \bold b = \begin{bmatrix} 9\\5\\8 \end{bmatrix}$

\begin{align*} \bold d = A\bold{\hat{w}} - \bold b&=\begin{bmatrix} 1 & -2 \\ 3 & 1 \\ 1 & 1 \end{bmatrix} \begin{bmatrix} 1\\1 \end{bmatrix} - \begin{bmatrix} 9\\5\\8 \end{bmatrix} =\begin{bmatrix} -10\\-1\\-6 \end{bmatrix} \\ \bold d^T\bold d&=\begin{bmatrix} -10 & -1 & -6 \end{bmatrix} \begin{bmatrix} -10\\-1\\-6 \end{bmatrix} \\ SSE(1,1) &= 137 \end{align*}

## Sample inputs and outputs

The following table provides example inputs and corresponding outputs:

Input Output
$A = [[1 , -2],[3 , 1],[1 , 1]]$ $\bold{w}=[[1],[1]]$ $\bold{b}=[[9],[5],[8]]$ 137
$A = [[7 , 2 , 5],[9,7,3],[6,9,1]]$ $\bold{w}=[[2],[-2],[0]]$ $\bold{b}=[[3],[3],[2]]$ 114

## Try it yourself

The signature of the function is given below:

Get hands-on with 1200+ tech skills courses.