def test_rectangular_tsvm_hepatitis(self): """ It tests TSVM with rectangular on hepatitis dataset """ clf = TSVM('RBF', 0.75, 0.5, 2, 0.1) clf.fit(X, y) pred = clf.predict(X) assert_greater(np.mean(y == pred), 0.95)
def test_linear_tsvm_hepatitis(self): """ It tests linear TSVM estimator on hepatits dataset """ clf = TSVM('linear', 1, 0.5, 0.5) clf.fit(X, y) pred = clf.predict(X) assert_greater(np.mean(y == pred), 0.78)
def test_rbf_tsvm_hepatitis(self): """ It tests non-linear TSVM estimator on hepatitis dataset """ clf = TSVM('RBF', 1, 0.5, 0.5, 0.1) clf.fit(X, y) pred = clf.predict(X) assert_greater(np.mean(y == pred), 0.95)
data_path = '/home/mir/mir-projects/NDC' # Specify the dataset's filename dataset = DataReader(join(data_path, 'NDC-train-1l.csv'), ',', False) dataset.load_data(False, False) X, y, _ = dataset.get_data() print("Loaded the dataset...") X_train, X_test, y_train, y_test = train_test_split(X,y, test_size=0.3) print(X_train.shape) print("Split train/test sets...") # A TSVM-based estimator tsvm_model = TSVM() train_t = time.time() tsvm_model.fit(X_train, y_train) print("Train time: %.5f" % (time.time() - train_t)) test_t = time.time() pred = tsvm_model.predict(X_test) print("Test time: %.5f" % (time.time() - test_t)) acc = accuracy_score(y_test, pred) print("Acc: %.2f" % (acc * 100))