I am trying to do a cross validation, however, I am only allowed to use those libraries below (as the professor demanded):
import numpy as np
from sklearn import svm
from sklearn.datasets import load_iris
Therefore, I am not able to use KFold for example to split the data. How should I go about it? Any suggestions?
k = 10
kf = KFold(n_splits=k, random_state=None)
acc_score = []
for train_index , test_index in kf.split(X):
X_train , X_test = X[train_index,:],X[test_index,:]
y_train , y_test = y[train_index] , y[test_index]
SVC = train_model(X_train, y_train)
y_pred = make_predictions(SVC, X_test)
acc = accuracy_score(y_pred , y_test)
acc_score.append(acc)
mean = sum(acc_score)/k
I was thinking on hard coding the split, but there could be a better solution.