赞
踩
# 导入相关包 import numpy as np import pandas as pd import matplotlib as mpl import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D x = np.arange(-1,3,0.05) y = np.arange(-1,3,0.05) w, b = np.meshgrid(x, y) SSE = (2 - w - b) ** 2 + (4 - 3 * w - b) ** 2 ax = plt.axes(projection='3d') ax.plot_surface(w, b, SSE, cmap='rainbow') #生成z方向投影,投到x-y平面 ax.contour(w, b, SSE, zdir='z', offset=0, cmap="rainbow") #x轴标题 plt.xlabel('w') #y轴标题 plt.ylabel('b') plt.show()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。