幽魂倪

导航

从头开始使用梯度下降优化在Python中实现多元线性回归(后续)

from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3Dsequence_containing_x_vals = list(X_train.transpose()[0])
sequence_containing_y_vals = list(X_train.transpose()[1])
sequence_containing_z_vals = list(y_train)fig = pyplot.figure()
ax = Axes3D(fig)ax.scatter(sequence_containing_x_vals, sequence_containing_y_vals,
sequence_containing_z_vals)
ax.set_xlabel('Living Room Area', fontsize=10)
ax.set_ylabel('Number of Bed Rooms', fontsize=10)
ax.set_zlabel('Actual Housing Price', fontsize=10)



=>预测目标变量的可视化:

# Getting the predictions...
X_train = np.concatenate((np.ones((X_train.shape[0],1)), X_train)
,axis = 1)
predictions = hypothesis(theta, X_train, X_train.shape[1] - 1)from matplotlib import pyplot
from mpl_toolkits.mplot3d import Axes3Dsequence_containing_x_vals = list(X_train.transpose()[1])
sequence_containing_y_vals = list(X_train.transpose()[2])
sequence_containing_z_vals = list(predictions)fig = pyplot.figure()
ax = Axes3D(fig)ax.scatter(sequence_containing_x_vals, sequence_containing_y_vals,
sequence_containing_z_vals)
ax.set_xlabel('Living Room Area', fontsize=10)
ax.set_ylabel('Number of Bed Rooms', fontsize=10)
ax.set_zlabel('Housing Price Predictions', fontsize=10)



实际房价与预计房价
  1. 均方误差:4086560101.2158(以美元为单位)
  2. 均方根误差:63926.2082(以美元为单位)
  3. R均分:0.7329

posted on 2020-06-30 08:50  幽魂倪  阅读(210)  评论(0编辑  收藏  举报