Radial Basis Function Network

#RBF Network 前面的一篇SVM中,最后的分割函数: git

使用高斯核函数方式把数据维度扩展到无限维度进而获得一条粗壮的分界线。 仔细看一下这个分割函数,其实就是一些Gaussian函数的线性组合,y就是增加的方向。 Gaussian函数还有另一个叫法——径向基函数,这是由于这个base function的结果只和计算这个x和中心点xn的距离有关,与其余的无关。 从其余方面来看SVM,先构造一个函数:

g(x) = y_nexp(-γ|x - x_n|^2)$$**指数求出来的其实就是x点和中心点的类似度,类似度越高,那么=晚y这个方向投票的票数就会越多。不一样的g(x)有不一样的权重,他们的线性组合就成了SVM,g(x)函数称为是radial function。因此Gaussian SVM就是把一些radial function联合起来作linear aggregation。**
![](https://upload-images.jianshu.io/upload_images/10624272-6588d51666aadb65.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
RBF Network就是SVM的延伸,目的就是找到全部radial hypotheses的linear aggregation,获得更好的网络模型。
![](https://upload-images.jianshu.io/upload_images/10624272-ccba9c461dd31303.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
能够看到这两种网络其实很相似,Neural Network的隐藏层是权值和数据作內积非线性转换再uniform的组合获得最后的输出,而对于RBF Network隐藏层是求高斯距离在作aggregation的方法。比较大的不一样点就在于hidden层的不一样了。![](https://upload-images.jianshu.io/upload_images/10624272-287a9913f1ff0e26.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-dc8b471b19c9f71b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**β就是每个radial function的权值,μ就是中心点,m为中心点的个数,主要的,对比一下以前的SVM,β就是αy,μ就是支持向量。因为是一个分类问题,因此最后的output function就是sign函数了。**
![](https://upload-images.jianshu.io/upload_images/10624272-85380a75f0a2e592.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
以前讲过,一个核函数不是随便乱选的,要知足两个条件:对称,半正定。对于SVM里面的核函数,其实ius把当前的数据提高到某一个很高很高的维度,而后作切片把数据分出来,polynomial function也是同样的,只不过是有限维度的。**而RBF其实就是在当前的空间作类似度处理,而那些kernel其实就是转换到z空间来计算核函数以表征两个向量的类似度。因此RBF和kernel都是衡量类似度的方式。虽然SVM和RBF Network都很类似,甚至能够说最后的决策函数基本一致的,可是他们的学习过程是很不同的,一个是直接x空间,一个是转换到z空间。**
![](https://upload-images.jianshu.io/upload_images/10624272-b576a77a0f50e51f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
衡量类似性并不止一种RBF方法,余弦类似度这些也能够衡量向量之间的类似度。
>>**回过头来思考一下SVM,其实支持向量机就是先经过凸优化的一些方法找到有投票权利的点,以后给出相应的权值,最后决策就是这些有投票权利的点进行决策;对于其余线性模型,其实主要的不一样就是他们每个点都有投票的权利,这就致使很远的点都会干扰到边界。而RBF Network事实上作的事情和SVM有点像,由于RBF函数是指数增加,若是这个点很远的话会很是小,近乎就是0了,因此也起到了弱化远的点投票权,强化近的点投票权的能力。**
#RBF Network Learning
RBF Network的决策函数:
![](https://upload-images.jianshu.io/upload_images/10624272-8abbf9c46c2dcc7d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
μ就是中心点,中心点是本身选择的。有一种选择中心点的方法,就是全部的点都做为中心点,那么每个样本对于预测都会有影响,β就是影响的程度。若是影响的程度都是同样的,那么就是1了,β = 1*y,最后相乘作uniform aggregation以后sign获得结果。这种咱们称为full RBF Network。
![](https://upload-images.jianshu.io/upload_images/10624272-65af45410e3db116.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
这个时候,full RBF Network就能够表示为:
![](https://upload-images.jianshu.io/upload_images/10624272-3314b0cbfa87a3b6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**这是一个指数函数,距离越远,那么衰减的就越快,x与中心点的距离越近那么就越大,距离越远就越小。也就是说,若是咱们的样本点是N个,那么起了关键做用的通常就是最近的那个点而已,固然,不必定是最近的一个点,能够是最近的K个点,用这k个点来代替N个点,当前的点周围最近的k个点哪一个类别最多,那么这个当前这个点就是属于哪一个类别的。这种算法就叫K近邻算法。**
![](https://upload-images.jianshu.io/upload_images/10624272-abdb46d10cc14581.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
k nearest neighbor一般比nearest neighbor model效果更好,计算量上也比full RBF Network要简单一些。值得一提的是,k nearest neighbor与full RBF Network都是比较“偷懒”的方法。由于它们在训练模型的时候比较简单,没有太多的运算,可是在测试的时候却要花费更多的力气,甚至能够说是几乎没有运算在里面,只须要作一些简单的数据处理便可,找出最相近的中心点,计算相对复杂一些。
若是是作回归问题,咱们就只须要去掉output:
![](https://upload-images.jianshu.io/upload_images/10624272-fe041c0e4a3a4b9e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
很明显,这样就是一个线性回归的问题了,每个RBF  其实能够看作就是一个矩阵好比第一个元素x1,那么通过RBF的转换以后:
$$z_1 = [RBF(x_1,x_1), RBF(x_1, x_2), RBF(x_1,x_3),RBF(x_1,x_3)...RBF(x_1,x_N)]

那么Z就是z的按列排序了,按照线性回归的解公式:github

β = (Z^TZ)^{-1}Z^Ty

上述矩阵Z是一个方阵,大小是N,有多少个中心点那么就有多少个N。若是每个x都是不同的,那么这个矩阵就是能够逆的矩阵了,毕竟x是训练数据,同样的就没有意义了。 算法

化简一下:

β = Z^{-1}y

咱们以x1为例子,那么解就是: 数组

这个结果对于咱们来讲很是奇怪,若是这样的话那么对于全部的x都有:

g_{RBF}(x_n) = y_n$$全部Ein = 0,这样对于机器学习来讲并非一个好事情,由于这样很大几率会出现过拟合。固然,某些状况下仍是颇有用的,好比函数拟合或者是作autoencode。
![](https://upload-images.jianshu.io/upload_images/10624272-e9efee11a1452a4f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
为了不过拟合,使用ridge regression的方法:
![](https://upload-images.jianshu.io/upload_images/10624272-30432669c3cd30c8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-9578945ba63a7e31.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
L2范式正则化。Z矩阵是由一系列Gaussian函数组成,每一个Gaussian函数计算的是两个样本之间的distance similarity。这里的Z与以前咱们介绍的Gaussian SVM中的kernel K是一致的。当时使用ridge regression获得的解:
![](https://upload-images.jianshu.io/upload_images/10624272-60898386ba1feba5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**比较一下kernel ridgeregression与regularized full RBF Network的β解,形式上类似但不彻底相同。这是由于regularization不同,在kernel ridgeregression中,是对无限多维的特征转换作regularization,而在regularized full RBF Network中,是对有限维(N维度)的特征转换作regularization。所以,二者的公式解有细微差异。**
![](https://upload-images.jianshu.io/upload_images/10624272-79b266ba3b47b3f3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**对于解决过拟合,还有另外的一种方法,能够选择K个具备表明性的点来表明这N个点,这样减小了中间点减小了权重的数量,VC维就减小了,能够起到regularization的做用。**
![](https://upload-images.jianshu.io/upload_images/10624272-2afdb9fca006deed.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**本来的问题是求解中心点μ,β权重,如今β能够经过回归求解,那么只须要求μ了。**
#K Mean Algorithm
选择表明的缘由,就是由于这些点有很高的类似性,因此可使用一个中心点来表明,从全部的点中选择几个有表明性的点。
![](https://upload-images.jianshu.io/upload_images/10624272-24a890bb6d46805d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**首先聚类算法是一种非监督的算法,不须要有label。须要肯定的通常就是两个变量,分群值Sm,没一个分类能够表示为S1,S2,S3,S4...Sm,另外一个就是中心值μm,μ1,μ2,μ3,μ4...μm,每个分群就对应着中心,要求的就是这个中心。对于这类问题的优化,就可使用square error function了。优化的步骤也是同样,求导,梯度降低或者梯度为0求最优值解。**
![](https://upload-images.jianshu.io/upload_images/10624272-5696f6057cead3d3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
刚刚也说过了,既然是衰减的形式,那么只须要取最大的就行了,最大也就意味着这须要求距离最近的便可。因此,表达式里面只有属于这个类别的数据求error。
最后就是求导作优化了:
![](https://upload-images.jianshu.io/upload_images/10624272-c119d97943482ab3.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**两个变量组合的优化问题,一般的方法就是对这两个变量分别求。仔细观察一下这两个变量,能够发现,只要肯定了μ,就能够肯定S;或者只要肯定了S,求个平均也能够获得μ。因此假设μ已是固定的了,那么能够依次迭代x,和哪一个μ的距离最小就属于哪一个类别。**
![](https://upload-images.jianshu.io/upload_images/10624272-aa609845a7ead7c4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**若是类别S是肯定的,那么目标就是找到对应的μ中心点,显然这个,求个导的事,梯度降低就能够解决了。**
![](https://upload-images.jianshu.io/upload_images/10624272-618b92228598d4f6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
因此这就成了一个鸡生蛋蛋生鸡的问题,因此通常一开始咱们会选择随机的几个点做为中心μ,而后按照上诉步骤优化。
>>###优化有结果吗?
>>这个优化的过程好像有些不同,求导等于0应该是直接求出了最优的解,linear regression就是这个道理,可是为何要一直这样迭代呢?这是由于求出来的这个μ并非一个全局的μ,只是在当前对于每个群S的一个最优,可是这个S并非最优的,以前也说了:**这个S和μ是互相牵制的,鸡生蛋蛋生鸡的问题,S能够获得μ,μ也能够获得S。因此整个过程通俗点就是经过μ求局部最优的S,经过S有球局部的最优μ,不断的迭代,慢慢的跑到全局。可是也没有能够跑到局部呢?这个是有可能的,这于初值有关,因此Kmean均值算法也是一个初值敏感的算法。对于局部这个问题,有一种解法就是能够合并最近的几个质心。事实上若是中心比较小,好比3个这样,通常都不会有局部出现,由于$$\sum_{m=1}^M(x_n - μ_m)^2$$不会这么的弯曲。**
中止是必定的,由于不管是经过S优化μ仍是μ优化S都朝Ein = 0为目的,若是Ein增长了是不会继续的,因此最后必定会到达一个平衡点。
#The process of  the RBF Network
既然中心有其余算法能够帮忙解决了,那么整个算法也就清晰了:
![](https://upload-images.jianshu.io/upload_images/10624272-88c33dd8b29df039.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
求解优化的过程当中,可使用validation来求解最优的λ和M。
![](https://upload-images.jianshu.io/upload_images/10624272-d463a4157f1644a0.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
#RBF Network and KMeans in action
![](https://upload-images.jianshu.io/upload_images/10624272-142851b7a6d23522.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
k值的大小和初始位置的不一样都会影响聚类的结果。
把这些机构k均值使用到RBF里面:
![](https://upload-images.jianshu.io/upload_images/10624272-7a32d978f9c5a778.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-6bb82eb88a192090.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
对于正则化也有不一样的影响。
#coding
###KMeans
接下来就是代码实现KMeans算法了。KMeans算法其实很简单,首先随机获得几个中心点,根据中心点预测作聚类算法便可。
```
def loadDataSet():
    '''loading data......'''
    data = dataSet.load_iris()
    dataset = data.data
    target = data.target
    PCA = pca.PCA(n_components=2)
    dataset = PCA.fit_transform(dataset)
    return np.mat(dataset), np.mat(target)
    pass
```
加载数据,iris数据集进行降维操做便于可视化。
```
def distEclud(vecA, vecB):
    '''calculate the distance from vecA to vecB'''
    return np.sqrt(np.sum(np.power(vecA - vecB, 2)))
    pass

def randCent(dataSet, k):
    '''create the center'''
    n = np.shape(dataSet)[1]
    centroids = np.mat(np.zeros((k, n)))
    for j in range(n):
        minJ = np.min(dataSet[:, j])
        rangeJ = float(max(dataSet[:, j]) - minJ)
        centroids[:, j] = minJ + rangeJ * np.random.rand(k, 1)
    return centroids

```
计算距离,随机选择中心点。随机选择中心点这里是先计算了每个维度的范围,以后在这个范围里面随机选择。
```
def KMeans(dataSet, k, distMeas = tool.distEclud, createCent = tool.randCent):
    '''KMeans Algorithm is running......'''
    m = np.shape(dataSet)[0]
    clusterAssment = np.mat(np.zeros((m, 2)))
    centroids = createCent(dataSet, k)
    clusterChanged = True
    while clusterChanged:
        clusterChanged = False
        for i in range(m):
            minDist = np.inf
            minIndex = -1
            for j in range(k):
                distJI = distMeas(centroids[j,:], dataSet[i,:])
                if distJI < minDist:
                    minDist = distJI
                    minIndex = j
            if clusterAssment[i, 0] != minIndex:
                clusterChanged = True
            clusterAssment[i, :] = minIndex, minDist**2
        for cent in range(k):
            ptsInClust = dataSet[np.nonzero(clusterAssment[:, 0].A == cent)[0]]
            centroids[cent, :] = np.mean(ptsInClust, axis=0)
    dataFrame = pd.DataFrame(data=np.hstack((dataSet, clusterAssment[:,0])))
    return dataFrame, centroids

```
选择和calculate distance的算法都是动态的方式,便于之后的改进。整个过程也比较简单,离哪一个近就属于哪一个类别。
###RBF Network
####①获取中心点
```
_,center = kMeans.KMeans(np.mat(x_train), k)
```
刚刚写好的KMeans就是这个做用。
####②计算β值
```
beta = rbf(x_train, center, y_train, gama=gamma, lamda=lamda)
```
rbf函数的实现:
```
def rbf(x_train, center, y_train, gama = 0.001, lamda = 0.01):
    M = center.shape[0]
    N = len(x_train)
    Z = np.zeros((M, N))
    for i in range(M):
        for j in range(N):
            Z[i][j] = Gaussian(x_train[j], center[i], gama)
    I1 = np.eye(N, k = 0)
    beta = np.linalg.inv(np.dot(Z.T, Z) + lamda * I1)
    beta = np.dot(beta, Z.T)
    y_train = np.mat(y_train)
    beta = np.dot(y_train, beta)
    return beta
    pass
```
```
def Gaussian(vecA, vecB, gama):
    x_x = np.abs(np.sum(vecA - vecB))
    x_x_2 = np.power(x_x, 2)
    return np.exp(-1.0 * gama * x_x_2)
    pass
```
首先是计算Z矩阵,就是φ(x)的矩阵。其实就是和上面步骤如出一辙的,使用的是线性回归,$$β = (Z^TZ + λI)^{-1}Z^Ty$$使用直接就能够算,要是逻辑回归也是同样。
###③预测
```
def predict(beta, x_train, center, gama):
    result = []
    for x in x_train:
        x = np.mat(x)
        sum = 0
        for i, vecB in enumerate(center):
            sum += beta[0,i]*Gaussian(x, vecB, gama)
        result.append(sum)
    return result
    pass
```

**为了方便调用,整合成一个函数:**
```
def RBF(y_test, x_test, y_train, x_train, gamma = 0.001, lamda = 0.01, k = 4):
    Again = True
    while Again == True:
        _,center = kMeans.KMeans(np.mat(x_train), k)
        beta = rbf(x_train, center, y_train, gama=gamma, lamda=lamda)
        Again = False
        for i in range(beta.shape[1]):
            if np.isnan(beta[0, i]):
                Again = True
    result = predict(beta, x_train, center, gamma)
    for i in range(len(result)):
        if result[i] > 0:
            result[i] = 1
        else:
            result[i] = -1
    posibility = 0
    for i in range(len(result)):
        if result[i] == y_train[i]:
            posibility += 1
    train_accuracy = posibility/len(result)
    result = predict(beta, x_test, center, gamma)

    for i in range(len(result)):
        if result[i] > 0:
            result[i] = 1
        else:
            result[i] = -1
    posibility = 0
    for i in range(len(result)):
        if result[i] == y_test[i]:
            posibility += 1
    test_accuracy = posibility/len(result)
    return train_accuracy, test_accuracy

```
能够计算不一样gamma,lamda,k的影响。
###④获取数据
```
def load_data():
    data = dataset.load_breast_cancer().data
    target = dataset.load_breast_cancer().target
    for i in range(len(target)):
        if target[i] == 0:
            target[i] = -1
    x_train, x_test, y_train, y_test = train_test_split(data, target, random_state=42, shuffle=True, test_size=0.4)
    return x_train, x_test, y_train, y_test
    pass
```
###⑤启动函数
```
if __name__ == '__main__':
    x_train, x_test, y_train, y_test = load_data()
    gamma = [1,0.1,0.01,0.001,0.0001]
    lamda = gamma
    train_accuracy = []
    test_accutacy = []
    c = ['red', 'blue', 'orange', 'green', 'yellow', 'black']
    for n, i in enumerate(gamma):
        for j in lamda:
            train, text = RBF(x_test=x_test, y_test=y_test, x_train=x_train, y_train=y_train, gamma=i, lamda=j)
            print('gama : ',i, ' lamda : ', j, ' train_accuracy : ', train, ' text_accuray : ', text)
            train_accuracy.append(train)
            test_accutacy.append(text)
        plt.plot(lamda, train_accuracy, c = c[n], label = 'gamma:'+str(i) + ' (train)')
        plt.plot(lamda, test_accutacy, c = c[n], linestyle='--', label = 'gamma:'+str(i) + ' (test)')
        plt.xlabel('lambda')
        plt.ylabel('accuracy')
        plt.legend(loc = 'upper right')
        train_accuracy = []
        test_accutacy = []
    plt.show()

    for n, i in enumerate(lamda):
        for j in gamma:
            train, text = RBF(x_test=x_test, y_test=y_test, x_train=x_train, y_train=y_train, gamma=j, lamda=i)
            print('lamda : ',i, ' gama : ', j, ' train_accuracy : ', train, ' text_accuray : ', text)
            train_accuracy.append(train)
            test_accutacy.append(text)
        plt.plot(gamma, train_accuracy, c = c[n], label = 'lamda:'+str(i) + ' (train)')
        plt.plot(gamma, test_accutacy, c = c[n], linestyle='--', label = 'lamda:'+str(i) + ' (test)')
        plt.xlabel('gamma')
        plt.ylabel('accuracy')
        plt.legend(loc = 'upper right')
        train_accuracy = []
        test_accutacy = []
    plt.show()

    ks = [2,3,4,5,6,7]
    train_accuracy = []
    test_accutacy = []
    for i in range(6):
        for n, i in enumerate(ks):
            train, text = RBF(x_test=x_test, y_test=y_test, x_train=x_train, y_train=y_train, gamma=0.0001, lamda=0.01, k=i)
            print('k == ' + str(i))
            train_accuracy.append(train)
            test_accutacy.append(text)
        plt.plot(ks, train_accuracy, c = c[n], label = 'train')
        plt.plot(ks, test_accutacy, c = c[n], linestyle='--', label = 'test')
        plt.xlabel('the number of k')
        plt.ylabel('accuracy')
        plt.legend(loc = 'upper left')
        plt.show()
        train_accuracy = []
        test_accutacy = []
    pass
```
#效果的讨论
**在运行函数获得结果后进行分析。**
##①当γ固定了,看看lamda变化对于结果的影响。
![](https://upload-images.jianshu.io/upload_images/10624272-c7ccbb3e9a62733d.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-bea21533047ced19.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**其实仍是很正常的,随着gamma的减小,准确率慢慢提上去了,虚线的测试数据,直线是准确率。Gaussian函数:**$$g(x) = exp(-γ|x_n - μ|^2)$$γ越小,**就至关于σ变大,高斯函数的标准差变大那么这个函数就会变的更加平滑,泛化能力会很强。其实就是regularization的过程。**
**观察上图是能够获得λ对于总体的影响不会太大。基本是平缓的。**
##②当λ固定了,看看γ变化对于结果的影响。
![](https://upload-images.jianshu.io/upload_images/10624272-1068f82b15b63ef9.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-fdbe6122ee34f505.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**γ越小效果越好,可是若是γ很是小,那么λ对于模型的影响几乎是没有影响。**
##③对于k的数量和准确率的讨论
**效果不太稳定,我多作了几回。**
![](https://upload-images.jianshu.io/upload_images/10624272-6473cc9ae0e47246.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-f9ae2f31198e2d64.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-4ebf0f271d759e0a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-ed0b4d219bd902e8.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-fedafb9be9fc6108.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
![](https://upload-images.jianshu.io/upload_images/10624272-28cceea27f9c07ef.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
**效果很是很是不稳定,我以前怀疑是线性回归的解不稳定的缘故,以前学习到病态矩阵,也就是近似奇异矩阵的矩阵,而regularization L2正则化就是为了使得病态矩阵转换成正常矩阵,因此增大了λ,显然并无什么卵用。虽然总体效果不错。上面的结果就已是λ增大的结果了。**
####因此最后还有两个问题没有解决,一个就是λ为何对于模型的影响很很小,另外一个上面没有提到,为何测试数据的准确率会大于训练数据的准确率?这还打的明显,不知道是否是没有作交叉验证的结果,由于懒。。。。以前看到的解释是:
>>若是程序很好的实现了模型,那么就是模型不适合你的数据,由于这代表存在以下问题:每次训练,都使得训练以后的模型对测试的 1折效果很好,而对用于训练的9折效果惨淡,也就是模型落入了局部极值点而非全局极值点。这颇有多是模型在具体数据下的失效问题。

**可是这个问题已经重复过了不少次,一直在使用test_train_split区分,同时也有shuffle。事实上在γ比较小的时候,测试数据就超过了训练数据的准确率,上面γ的变化能够看到。**
>>####最后附上GitHub代码:https://github.com/GreenArrow2017/MachineLearning/tree/master/MachineLearning/RBFNetwork
相关文章
相关标签/搜索