def train_test_error(clf, train_x, train_y, test_x, test_y):
"""
Return training and testing errors according to input classifier
Arguments:
:param clf: classifier sklearn object
:param train_x: gene expression matrix
:param train_y: list of labels
:param test_x: gene expression matrix
:param test_y: list of labels
Output:
Returns training and testing auroc
"""
model = clf.fit(train_x, train_y)
pred_y = model.predict(train_x)
train_err = roc_auc_score(train_y, pred_y, average='weighted')
pred_y = model.predict(test_x)
test_err = roc_auc_score(test_y, pred_y, average='weighted')
return train_err, test_err
评论列表
文章目录