from skmultilearn.problem_transform import ClassifierChain
from sklearn.naive_bayes import GaussianNB
#scikit-learn version>=0.21
from sklearn.metrics import multilabel_confusion_matrix
from scipy.sparse import csr_matrix
def svm():
clf = ClassifierChain(GaussianNB())
S = csr_matrix(train_labels)
#S为sprase matrix
clf.fit(train_features, S)
prediction = clf.predict(csr_matrix(test_features))
cnf_matrix = multilabel_confusion_matrix(y_true, y_prediction)
# print(cnf_matrix)
TN = cnf_matrix[:, 0, 0]
TP = cnf_matrix[:, 1, 1]
FN = cnf_matrix[:, 1, 0]
FP = cnf_matrix[:, 0, 1]
ACC = accuracy_score(y_true, y_prediction)
TPR = metrics.recall_score(y_true, y_prediction, average='macro')
TNR = np.mean(TN / (TN + FP))
F1_score = metrics.f1_score(y_true, y_prediction, average='macro')