现在我有一个散点3D图,所有三个变量x,y,z都是自变量。我想要拟合一个表面平面来大致看到哪个点是异常值,而不是在飞机上。
我的脚本如下所示:
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
import pylab
from matplotlib import cm
x_axis = np.array([-1.0421, 0.628354, 8.79899, 0.359502, -0.952719, -0.54148,
0.604585, 0.739086, 8.62336, 6.29254, 1.3942, 3.82348, -0.214241,
4.86446, 2.56733, 2.97113, -0.395414, 0.848251])
y_axis=np.array([-1131.02, -1111.02, -1076.85, -1125.94, -1140.41, -1130.37, -1114.58,
-1148.05, -1103.2, -1109.89, -1131.98, -1114.59, -1093.26, -1108.23,
-1121.88, -1111.72, -1143.87, -1126.38])
z_axis =np.array([0.76, 0.75, 0.12, 1.07, 1.06, 0.63, 0.14, 0.79, 0.16, 0.14, 0.81, 0.36, 0.09,
0.26, 0.51, 0.28, 0.92, 0.66])
fig = plt.figure(num=None, figsize=(9, 7), facecolor='w', edgecolor='k')
ax = fig.add_subplot(111, projection='3d')
ax.scatter(x_axis, y_axis, z_axis, c='brown', marker='o', s=25)
plt.show()
我的全部内容只是看看有多少异常值以及这些点可以形成一个表面的“好”。如果只有2或3个大纲,我可以告诉x,y,z有很强的相关性。我的观点是看他们中的三个是否形成了相关性。