Nice answear, an Ovo approach is an One-Vs-One approach so it kinda sees all differences between classes one by one. I actually forgot that I need this approach for a multi calss too so for instance :
- Tumor Classes : GBM , BrCa, PAAD,Lung,HBC,CRC
- Healthy Class : HC.
Given this 7 classes I have to predict to which the sample belongs. I have 285 samples and 2519 genes. So In that case would an approach like the one mentioned below do the work?
Training :
def loocv(train_X,train_y):
# define X and y
X = train_X
y = train_y
# define LOOCV
loo = LeaveOneOut()
loo.get_n_splits(X)
# define true and predict list
y_true,y_pred = [],[]
# run
for train_index, test_index in loo.split(X):
X_train, X_test = X[train_index], X[test_index]
y_train, y_test = y[train_index], y[test_index]
model = SVC(kernel='linear',random_state=0)
ovo_classifier = OneVsOneClassifier(model)
ovo_classifier.fit(X_train,y_train)
yhat = ovo_classifier.predict(X_test)
y_true.append(y_test[0])
y_pred.append(yhat[0])
return y_true,y_pred,ovo_classifier
Validation :
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)
pred_y = model.predict(X_test)
training_accuracy = accuracy_score(y_true,y_pred)
accuracy = accuracy_score(y_test,pred_y)
return(accuracy,training_accuracy)
Result :
0.6767441860465118
0.6713567839195979