Cross Validation, Data Science

I have written this code and getting error:
from sklearn.model_selection import train_test_split
X0 = pd.read_csv('C:/Users/Desktop/Dataset for Experiment - 2019/ANFIS modeling data/china_data.csv')
train_test_split. X0 = X0.drop(columns = ['EFFORT'], axis = 1)
X_train, X_test, y_train, y_test = train_test_split(X0, test_size=0.8)
**the error which is showing for this code "X_train, X_test, y_train, y_test = train_test_split(X0, test_size=0.8)
ValueError: not enough values to unpack (expected 4, got 2)"**
I tried many times to remove this error but it is still persistent. Can anybody explain to me why I am getting this error & how can I remove this error?

 采纳的回答

In MATLAB, you can use cvpartition
Train vs Test
pt = cvpartition(Y, 'HoldOut', 0.2);
trainIndex = training(pt);
testIndex = test(pt);
X_train = X(:,trainIndex);
Y_train = Y(trainIndex);
X_test = X(:,testIndex);
Y_test = Y(testIndex);
Cross validation
pt = cvpartition(Y, 'KFold', 5);
...
...
It is easier to control the data index for validation.

更多回答(0 个)

类别

帮助中心File Exchange 中查找有关 Response Computation and Visualization 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by