Error in train_test_split on scikit-learn: ValueError: not enough values to unpack (expected 5, got 4)

Asked 1 years ago, Updated 1 years ago, 453 views

I'm a beginner at Python and I'm doing epidemiological research using machine learning, but I don't know if it's the right way to proceed.Currently, I am having trouble adjusting hyperparameters.If you don't mind, please give me some advice and point it out.

import numpy as np
import pandas aspd
import matplotlib.pyplot asplt
import seaborn as sns
import csv
csvfile=open('BioAsseT practice data5.csv')
df = pd.read_csv("BioAsseT practice data5.csv")
X = df.external
y = df.total
X.shape, y.shape
((103,), (103,))
from sklearn.model_selection import train_test_split

X_train_val, X_test, y_train_val, y_test=train_test_split(X,y,test_size=0.2, random_state=1)

X_train, X_val, y_train, y_val, y_test=train_test_split(X_train_val, y_train_val, test_size=0.3, random_state=1)
ValueError Traceback (most recent call last)
<ipython-input-39-3f9989894ee6>in<module>
---->1 X_train, X_val, y_train, y_val, y_test=train_test_split(X_train_val, y_train_val, test_size=0.3, random_state=1)

ValueError: not enough values to unpack (expected 5, got 4)

python machine-learning google-columnatory scikit-learn

2023-01-18 17:44

1 Answers

X_train, X_val, y_train, y_val, y_test=train_test_split(X_train_val, y_train_val, test_size=0.3, random_state=1)

There is one extra variable on the left above.Let's make it four.


2023-01-18 18:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.