print('Accuracy of S_TWSVM %.3f' % (100 * np.mean(y_S_TWSVM == y_test))) ###Cross validation score of S_TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf3, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of S_TWSVM: %s' %scores) print('CV accuracy of S_TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # TWSVM: best params of TWSVM {'c': 1.0, 'c_': 1.0} from TWSVM_class import TWSVM start_time = time.time() clf4 = TWSVM(c=1, c_=1) clf4.fit(AB_train_mms, y_train) end_time = time.time() print('total run time of TWSVM: %f ' % ((end_time - start_time))) y_TWSVM = clf4.predict(AB_test_mms) print('Accuracy of TWSVM %.3f ' % (100 * np.mean(y_TWSVM == y_test))) ###Cross validation score of TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf4, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of TWSVM: %s' %scores) print('CV accuracy of TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores)))
clf3 = S_TWSVM(c1 = 1, c2 = 0.0001, c3 = 100) clf3.fit(AB_train_mms, y_train) end_time = time.time() print('Total runtime of S_TWSVM: %s' %((end_time - start_time))) y_S_TWSVM = clf3.predict(AB_test_mms) print('Accuracy of S_TWSVM %.3f' %(100*np.mean(y_S_TWSVM == y_test))) ###Cross validation score of S_TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator = clf3, X = AB_train_mms, y = y_train, cv = 10, n_jobs =1) #print('CV accuracy scores of S_TWSVM: %s' %scores) print('CV accuracy of S_TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # TWSVM best params of TWSVM {'c': 100.0, 'c_': 10.0} from TWSVM_class import TWSVM start_time = time.time() clf4 = TWSVM(c = 100, c_ = 10) clf4.fit(AB_train_mms, y_train) end_time = time.time() print('total run time of TWSVM: %f ' %((end_time - start_time))) y_TWSVM = clf4.predict(AB_test_mms) print('Accuracy of TWSVM %.3f ' %(100*np.mean(y_TWSVM == y_test))) ###Cross validation score of TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator = clf4, X = AB_train_mms, y = y_train, cv = 10, n_jobs =1) #print('CV accuracy scores of TWSVM: %s' %scores) print('CV accuracy of TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # SVM best params of SVM #from SVM_class import SVM #start_time = time.time() #clf5 = SVM(c = 1)
print('Accuracy of S_TWSVM %.3f' % (100 * np.mean(y_S_TWSVM == y_test))) ###Cross validation score of S_TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf3, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of S_TWSVM: %s' %scores) print('CV accuracy of S_TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # TWSVM best params of TWSVM {'c': 0.1, 'c_': 0.1} from TWSVM_class import TWSVM start_time = time.time() clf4 = TWSVM(c=0.1, c_=0.1) clf4.fit(AB_train_mms, y_train) end_time = time.time() print('total run time of TWSVM: %f ' % ((end_time - start_time))) y_TWSVM = clf4.predict(AB_test_mms) print('Accuracy of TWSVM %.3f ' % (100 * np.mean(y_TWSVM == y_test))) ###Cross validation score of TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf4, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of TWSVM: %s' %scores) print('CV accuracy of TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores)))
clf3 = S_TWSVM(c1 = 10, c2 = 100, c3 = 1000) clf3.fit(AB_train_mms, y_train) end_time = time.time() print('Total runtime of S_TWSVM: %s' %((end_time - start_time))) y_S_TWSVM = clf3.predict(AB_test_mms) print('Accuracy of S_TWSVM %.3f' %(100*np.mean(y_S_TWSVM == y_test))) ###Cross validation score of S_TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator = clf3, X = AB_train_mms, y = y_train, cv = 10, n_jobs =1) #print('CV accuracy scores of S_TWSVM: %s' %scores) print('CV accuracy of S_TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # TWSVM best params of TWSVM {'c': 0.0001, 'c_': 0.0001} from TWSVM_class import TWSVM start_time = time.time() clf4 = TWSVM(c = 0.0001, c_ = 0.0001) clf4.fit(AB_train_mms, y_train) end_time = time.time() print('total run time of TWSVM: %f ' %((end_time - start_time))) y_TWSVM = clf4.predict(AB_test_mms) print('Accuracy of TWSVM %.3f ' %(100*np.mean(y_TWSVM == y_test))) ###Cross validation score of TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator = clf4, X = AB_train_mms, y = y_train, cv = 10, n_jobs =1) #print('CV accuracy scores of TWSVM: %s' %scores) print('CV accuracy of TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # SVM best params of SVM #from SVM_class import SVM #start_time = time.time() #clf5 = SVM(c = 1)
###Cross validation score of S_TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf3, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of S_TWSVM: %s' %scores) print('CV accuracy of S_TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores))) # TWSVM best params of TWSVM {'c': 10, 'c_': 0.1} from TWSVM_class import TWSVM start_time = time.time() clf4 = TWSVM(c=10, c_=0.1) clf4.fit(AB_train_mms, y_train) end_time = time.time() print('total run time of TWSVM: %f ' % ((end_time - start_time))) y_TWSVM = clf4.predict(AB_test_mms) print('Accuracy of TWSVM %.3f ' % (100 * np.mean(y_TWSVM == y_test))) ###Cross validation score of TWSVM #from sklearn.model_selection import cross_val_score scores = cross_val_score(estimator=clf4, X=AB_train_mms, y=y_train, cv=10, n_jobs=1) #print('CV accuracy scores of TWSVM: %s' %scores) print('CV accuracy of TWSVM: %.3f +/- %.3f' % (np.mean(scores), np.std(scores)))