0

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!

Ch3steR
  • 20,090
  • 4
  • 28
  • 58
larn
  • 398
  • 2
  • 16

1 Answers1

2

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)
stellasia
  • 5,372
  • 4
  • 23
  • 43