Convolutions:
Convolve the two 3x3 matrices that were assigned to you with your 9x9 matrix and calculate the resulting two matrices
filter1 = np.array([[1,0,0],[0,0,1],[1,1,0]])
filter2 = np.array([[1,1,1],[0,1,1],[1,1,0]])
matrix = np.array([
[1,-1,0,2,0,0,1,1,1],
[1,1,-1,2,0,-2,-1,0,0],
[1,-1,-1,-2,0,2,0,0,-1],
[1,0,0,-1,-1,2,-1,-1,-1],
[-1,-1,1,-1,2,1,-1,-1,1],
[-1,-1,-1,1,-2,-1,0,1,1],
[-1,0,0,-1,1,-2,-1,1,-1],
[0,1,0,-1,-1,-2,-1,0,-1],
[1,1,-1,-1,1,1,0,-1,1]
])
output of filter 1:
[[0,-1,-3,-2,1,2,1],
[1,-1,-2,2,1,-2,-4],
[1,-1,-2,1,2,1,-3],
[0,-3,2,-1,-5,0,1],
[-3,0,-2,-2,1,-1,0],
[0,-1,-1,-3,-6,-3,-2],
[1,-1,-3,-3,2,-1,-3]]
output of filter 2:
[[0,0,1,-2,0,3,2],
[0,-1,-2,1,0,0,-4],
[-3,-5,-4,2,6,0,-5],
[-1,-3,-1,2,-3,-3,-2],
[-4,-1,0,-1,0,-3,1],
[-2,-1,-3,-5,-9,-3,1],
[2,-2,-4,-5,-3,-2,-3]]
scipy.signal.convolve2d(A, b)
taken from this stack overflow post instead of the manual convolution code, but the scipy convolve function still gives a 9x9 output.Scipy convolve2 output from filter 1:
>>> [[ 1 -1 0 2 0 0 1 1 1]
[ 1 0 2 0 0 2 1 2 0]
[ 1 0 1 0 1 1 0 0 -1]
[ 1 0 0 0 4 0 0 0 -1]
[-1 1 0 2 0 0 0 0 1]
[-1 0 0 0 0 0 0 2 1]
[-1 0 0 0 0 0 0 0 -1]
[ 0 0 0 0 0 0 0 0 -1]
[ 1 1 -1 -1 1 1 0 -1 1]]
Scipy convolve2 output from filter 2:
>>> [[ 1 -1 0 2 0 0 1 1 1]
[ 1 2 1 0 0 0 0 1 0]
[ 1 0 0 0 0 2 1 0 -1]
[ 1 0 0 0 1 3 2 0 -1]
[-1 0 0 1 2 0 0 0 1]
[-1 0 0 0 0 0 0 2 1]
[-1 0 0 0 0 0 0 0 -1]
[ 0 2 0 0 0 0 0 0 -1]
[ 1 1 -1 -1 1 1 0 -1 1]]
What is the purpose of using a 3x3 filter to convolve across a 2D image matrix?
Why would we include more than one filter?
How many filters did you assign as part of your architecture when training a model to learn images of numbers from the mnist dataset?
MSE: From your 400+ observations of homes for sale, calculate the MSE for the following:
In which percentile do the 10 most accurate predictions reside?
prices = np.array(df['prices'])
print(np.percentile(prices, 65))
>>> 285000.0
print(np.percentile(prices, 72))
>>> 300000.0
Did your model trend towards over or under predicting home values?
Which feature appears to be the most significant predictor in the above cases?
Stretch goal: calculate the MAE and compare with your MSE results