SVM
- can be used for both classifications & regression
['mean radius' 'mean texture' 'mean perimeter' 'mean area' 'mean smoothness' 'mean compactness' 'mean concavity' 'mean concave points' 'mean symmetry' 'mean fractal dimension' 'radius error' 'texture error' 'perimeter error' 'area error' 'smoothness error' 'compactness error' 'concavity error' 'concave points error' 'symmetry error' 'fractal dimension error' 'worst radius' 'worst texture' 'worst perimeter' 'worst area' 'worst smoothness' 'worst compactness' 'worst concavity' 'worst concave points' 'worst symmetry' 'worst fractal dimension']
- classes = ['malignant', 'benign']
-
sklearn
import sklearn from sklearn import datasets from sklearn import svm
- SVM create a hyperplane, that divides your data
- The hyperplane is the same distance from the two closest data points from both classes (red & green) in this case.
NOTE: Meaning we could generate multiple hyperplanes eg;
- The best hyperplane to use is the one where the distance between our classes is the greatest. In our case The best to use is a..
- if we get this type of data what happens? kernel trick
-
In this case we use kernel trick
-
Kernel, simply take the x1 's and x2 of each data point and comes up with an x3. For 3D
- This shows how a 2D is converted to a 3D.
-
Using a soft margin
model = svm.SVC(kernel="linear", C=1)
-
If this occurs like in our case where by a RED DATA POINT has strayed. We ignore it to get a better result.
-
a few points maybe ignored
NOTE: In a hard margin this is not allowed.