AttributeError: 'DataFrame' object has no attribute 'as_matrix' is the error
It could be that your code used to work and now it doesn't because you updated your pandas package.

If you check pandas.DataFrame.as_matrix's documentation you will see that this method has been deprecated.

Instead, you should use:

X_mat = X[['height', 'width']].values()