Skip to content

Commit 9bb57fb

Browse files
support_vector_machines.py increase error tolerance to suppress convergence warnings (TheAlgorithms#1929)
* Update support_vector_machines.py * Update support_vector_machines.py Co-authored-by: Christian Clauss <cclauss@me.com>
1 parent a859934 commit 9bb57fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

‎machine_learning/support_vector_machines.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from sklearn.datasets import load_iris
22
from sklearn import svm
33
from sklearn.model_selection import train_test_split
4-
import doctest
54

65

76
# different functions implementing different types of SVM's
@@ -12,15 +11,15 @@ def NuSVC(train_x, train_y):
1211

1312

1413
def Linearsvc(train_x, train_y):
15-
svc_linear = svm.LinearSVC()
14+
svc_linear = svm.LinearSVC(tol=10e-2)
1615
svc_linear.fit(train_x, train_y)
1716
return svc_linear
1817

1918

2019
def SVC(train_x, train_y):
2120
# svm.SVC(C=1.0, kernel='rbf', degree=3, gamma=0.0, coef0=0.0, shrinking=True,
2221
# probability=False,tol=0.001, cache_size=200, class_weight=None, verbose=False,
23-
# max_iter=-1, random_state=None)
22+
# max_iter=1000, random_state=None)
2423
# various parameters like "kernel","gamma","C" can effectively tuned for a given
2524
# machine learning model.
2625
SVC = svm.SVC(gamma="auto")
@@ -39,7 +38,6 @@ def test(X_new):
3938
'versicolor'
4039
>>> test([6,3,4,1])
4140
'versicolor'
42-
4341
"""
4442
iris = load_iris()
4543
# splitting the dataset to test and train
@@ -55,4 +53,6 @@ def test(X_new):
5553

5654

5755
if __name__ == "__main__":
56+
import doctest
57+
5858
doctest.testmod()

0 commit comments

Comments
 (0)