超平面相对于离群点的运动

问题描述 投票:0回答:1

我试图了解异常值对超平面位置的影响。

使用Sklearn回归器作为模型。

alpha_lst = [0.0001,1,100]
outlier = [(0,2),(21, 13), (-23, -15), (22,14), (23, 14)]
for i in range(len(alpha_lst)):
    plt.figure(figsize = (17,14))
    k = 0
    X= b * np.sin(phi)
    Y= a * np.cos(phi)
    for j in outlier:
        plt.subplot(3,5,k+1)
        k+=1 
        X = np.append(X,j[0]).reshape(-1,1)
        Y = np.append(Y,j[1]).reshape(-1,1)
        clf = SGDRegressor(alpha=alpha_lst[i], eta0=0.001, learning_rate='constant',random_state=0)
        clf.fit(X,Y)
        coef = clf.coef_
#        print('coef',coef)
        intercept = clf.intercept_
        y_min = np.amin(X)
        y_max = np.amax(X)
        hyper_plane = draw_hyper_plane(coef,intercept,y_min,y_max)

        plt.scatter(X,Y,color='blue')

    plt.show()
def draw_hyper_plane(coef,intercept,y_max,y_min):
            points=np.array([[((-coef*y_min - intercept)/coef), y_min],[((-coef*y_max - intercept)/coef), y_max]])
            plt.plot(points[:,0], points[:,1])

每张图中还有一个异常值。

异常值会影响超平面吗?如果是,那么如何?

Plot describes the position of hyperplane when model is trained using Sklearn regressor

python linear-regression outliers
1个回答
0
投票

离群值始终会影响拟合:在直观上,它们会将模型拉向拟合空间中的离群值。 2D绘图中的外观将取决于模型的类型。

[不知道使用的模型就不能说更多。

© www.soinside.com 2019 - 2024. All rights reserved.