isds2020
isds2020 copied to clipboard
got an error for 11.1.6
my code for the update weights:
def update_weights(X_, y_, w_, eta): error = compute_error(y_, X_, w_) fod = X_.T.dot(error) w_[1:] += eta * np.dot(x_.T,error) w_[0] += eta * error.sum(
#answer for 11.1.6 w = np.zeros(1+X.shape[1]) for i in range(50): print(update_weights(y_train, X_train,w,0.001))
the error I got:

It seems the error is about the training data, but my code for handling the data is the same as the solution provided.
Thank you in advance!
hi @fxj483 ,
the problem is this line update_weights(y_train, X_train,w,0.001).
Your update_weights function expects the input (X_, y_, w_, eta) but you insert (y_train, X_train,w,0.001). You will have to switch y_train and X_train :)
The ValueError gets raised in the net_input function where you are trying to multiply a vector of dim (122, ) with a vector of dim (8, ). This is not well defined as to why the value error gets raised.
Whenever you get a ValueError due to something with the dimensionality of your data, check the dimension of your feature matrix and target vector by, e.g. for the feature matrix, writing X.shape.