From e47a8a5be33ed1ca187fd34e0fd2aa6521a80fe0 Mon Sep 17 00:00:00 2001 From: LordSomen Date: Sat, 14 Jul 2018 23:33:00 +0530 Subject: [PATCH] continuing with svm --- SVM/svm_model.py | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/SVM/svm_model.py b/SVM/svm_model.py index 712d425..4c33c99 100644 --- a/SVM/svm_model.py +++ b/SVM/svm_model.py @@ -19,4 +19,30 @@ #%% X_scaled = StandardScaler(X) svm_clf.fit(X,Y) -svm_clf.predict([[5.5,1.7]]) \ No newline at end of file +svm_clf.predict([[5.5,1.7]]) + +#%% +from sklearn.datasets import make_moons +from sklearn.pipeline import Pipeline +from sklearn.preprocessing import PolynomialFeatures + +X,Y = make_moons() +print(X) +print(Y) + +#%% +polynomial_svm_clf = Pipeline(( + ("poly_features",PolynomialFeatures()), + ('scaler',StandardScaler()), + ('linear_svc',LinearSVC(C=10,loss="hinge")), +)) + +polynomial_svm_clf.fit(X,Y) + +#%% +from sklearn.svm import SVC +poly_kernel_svm_clf = Pipeline(( +("scaler", StandardScaler()), +("svm_clf", SVC(kernel="poly", degree=3, coef0=1, C=5)) +)) +poly_kernel_svm_clf.fit(X, Y) \ No newline at end of file