From 9bb57fbbfef1ddf3420ef2da249f4e3fe63222ef Mon Sep 17 00:00:00 2001 From: QuantumNovice <43876848+QuantumNovice@users.noreply.github.com> Date: Sun, 3 May 2020 00:19:45 +0500 Subject: [PATCH] support_vector_machines.py increase error tolerance to suppress convergence warnings (#1929) * Update support_vector_machines.py * Update support_vector_machines.py Co-authored-by: Christian Clauss --- machine_learning/support_vector_machines.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/machine_learning/support_vector_machines.py b/machine_learning/support_vector_machines.py index 53b446ef9..3bf54a691 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 @@ -12,7 +11,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 +19,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 +38,6 @@ def test(X_new): 'versicolor' >>> test([6,3,4,1]) 'versicolor' - """ iris = load_iris() # splitting the dataset to test and train @@ -55,4 +53,6 @@ def test(X_new): if __name__ == "__main__": + import doctest + doctest.testmod()