728x90 반응형 SVC2 [Machine Learning] SVM in Python (2) - Margin, Regularization, Non-linear SVM, Kernel Predefined visualization function간단한 시각화를 위한 함수를 정의했다.def plot_svc_decision_boundary(svm_clf, xmin, xmax): w = svm_clf.coef_[0] b = svm_clf.intercept_[0] # At the decision boundary, w0*x0 + w1*x1 + b = 0 # => x1 = -w0/w1 * x0 - b/w1 x0 = np.linspace(xmin, xmax, 200) decision_boundary = -w[0]/w[1] * x0 - b/w[1] margin = 1/w[1] gutter_up = decision_boundary + margin gutt.. 2023. 5. 11. [Machine Learning] SVM in Python (1) Decision Boundary Synopsissklearn의 iris dataset으로 간단히 binary classification을 해보자.import numpy as npimport matplotlib.pyplot as pltfrom sklearn.svm import SVCfrom sklearn import datasetsfrom sklearn.metrics import confusion_matrix SVC의 defalut kernel은 'rbf'이지만 linear로 먼저 살펴보자# Load Iris datasetiris = datasets.load_iris()X = iris["data"][:, (2, 3)] # petal length, petal widthy = iris["target"]# setosa 와 versicolor.. 2023. 5. 10. 이전 1 다음 728x90 반응형