Reputation: 398
I'm currently trying to calculate the Mean Squared Error of a particular polynomial regression model. However, when I run train_test_split
I get an error message:
ValueError: too many values to unpack (expected 2)
Here's the code I have written:
def mse(X, y, degree, model):
X_train, y_train = train_test_split(X, y, test_size=0.6, random_state=10)
train_errors = []
for m in range(1, len(X_train)):
model.fit(X_train[:m], y_train[:m])
y_train_predict = model.predict(X_train[:m])
mse = train_errors.append(mean_squared_error(y_train[:m], y_train_predict))
return mse
I'm unsure why I'm getting this error or what I can change up to make the code work! Any advice would be appreciated!
Upvotes: 0
Views: 329
Reputation: 5622
train_test_split
also returns the test sample:
X_train, X_test, y_train, y_test = train_test_split(
X, y, test_size=0.6, random_state=10)
Upvotes: 2