From 18b0277e6246b00a45db2b34e61c53b322428772 Mon Sep 17 00:00:00 2001 From: QuantumNovice <43876848+QuantumNovice@users.noreply.github.com> Date: Sat, 2 May 2020 19:57:24 +0500 Subject: [PATCH 1/2] Update support_vector_machines.py --- machine_learning/support_vector_machines.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/machine_learning/support_vector_machines.py b/machine_learning/support_vector_machines.py index 53b446ef975d..4b389fb7cb53 100644 --- a/machine_learning/support_vector_machines.py +++ b/machine_learning/support_vector_machines.py @@ -12,7 +12,7 @@ def NuSVC(train_x, train_y): def Linearsvc(train_x, train_y): - svc_linear = svm.LinearSVC() + svc_linear = svm.LinearSVC(tol=10e-2) svc_linear.fit(train_x, train_y) return svc_linear @@ -20,7 +20,7 @@ def Linearsvc(train_x, train_y): def SVC(train_x, train_y): # svm.SVC(C=1.0, kernel='rbf', degree=3, gamma=0.0, coef0=0.0, shrinking=True, # probability=False,tol=0.001, cache_size=200, class_weight=None, verbose=False, - # max_iter=-1, random_state=None) + # max_iter=1000, random_state=None) # various parameters like "kernel","gamma","C" can effectively tuned for a given # machine learning model. SVC = svm.SVC(gamma="auto") @@ -39,7 +39,6 @@ def test(X_new): 'versicolor' >>> test([6,3,4,1]) 'versicolor' - """ iris = load_iris() # splitting the dataset to test and train @@ -51,6 +50,7 @@ def test(X_new): # current_model=NuSVC(train_x, train_y) current_model = Linearsvc(train_x, train_y) prediction = current_model.predict([X_new]) + return iris["target_names"][prediction][0] From f27710fb031c779fd577266e3e07945c40927230 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sat, 2 May 2020 21:18:57 +0200 Subject: [PATCH 2/2] Update support_vector_machines.py --- machine_learning/support_vector_machines.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine_learning/support_vector_machines.py b/machine_learning/support_vector_machines.py index 4b389fb7cb53..3bf54a69128d 100644 --- a/machine_learning/support_vector_machines.py +++ b/machine_learning/support_vector_machines.py @@ -1,7 +1,6 @@ from sklearn.datasets import load_iris from sklearn import svm from sklearn.model_selection import train_test_split -import doctest # different functions implementing different types of SVM's @@ -50,9 +49,10 @@ def test(X_new): # current_model=NuSVC(train_x, train_y) current_model = Linearsvc(train_x, train_y) prediction = current_model.predict([X_new]) - return iris["target_names"][prediction][0] if __name__ == "__main__": + import doctest + doctest.testmod()