题
6.1
6.2
from sklearn import svm
import numpy as np
from matplotlib import pyplot as plt
good_x=[[0.697,0.460],[0.774,0.376],[0.634,0.264],[0.608,0.318],[0.556,0.215],[0.403,0.237],[0.481,0.149],[0.437,0.211]]
good_y=[1 for i in range(8)]
bad_x=[[0.666,0.091],[0.243,0.267],[0.245,0.057],[0.343,0.099],[0.639,0.161],[0.657,0.198],[0.360,0.370],[0.593,0.042],[0.719,0.103]]
bad_y=[0 for i in range(9)]
x=good_x+bad_x
y=good_y+bad_y
clf=svm.SVC(kernel='rbf')#高斯核
clf.fit(x,y)
clf.predict(x)
array([1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0])
from sklearn import svm
import numpy as np
from matplotlib import pyplot as plt
good_x=[[0.697,0.460],[0.774,0.376],[0.634,0.264],[0.608,0.318],[0.556,0.215],[0.403,0.237],[0.481,0.149],[0.437,0.211]]
good_y=[1 for i in range(8)]
bad_x=[[0.666,0.091],[0.243,0.267],[0.245,0.057],[0.343,0.099],[0.639,0.161],[0.657,0.198],[0.360,0.370],[0.593,0.042],[0.719,0.103]]
bad_y=[0 for i in range(9)]
x=good_x+bad_x
y=good_y+bad_y
clf=svm.SVC(kernel='linear')#线性核
clf.fit(x,y)
clf.predict(x)
array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
6.3(待补)
6.4
这里理解的线性判别分析是简单的可在原始样本空间进行划分。线性核支持向量机则需要将样本从原始空间映射到高维特征空间才可进行划分,所以等价是在样本可在原始样本空间划分时等价。
6.5
RBF网络,用径向基函数计算每个隐层神经元的中心到样本的距离,这里若将隐层神经元个数设置为训练样本数,且每个训练样本对应一个神经元中心,再以高斯径向基为激活函数的RBF恰好与高斯核SVM的预测函数相同。
6.6
SVM的决策只基于少量的支持向量,若噪音样本出现在支持向量中,容易对决策造成影响,所以SVM对噪音敏感。