zoukankan      html  css  js  c++  java
  • 从头开始使用梯度下降优化在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
  • 相关阅读:
    古典密码仿射密码Affine
    git 修改远程仓库地址的方法
    git 修改已经 commit 的用户名和邮箱
    git 调整commit之间的顺序
    Go 逃逸分析
    docker 镜像中的 @sha256:cbeaf907fc78ac97ce7b625e4bf0de16e3ea725daf6b04f930bd14c67c671ff9 (digest)是什么意思
    Docker镜像列表中的<none>:<none>是什么镜像
    github 下fork后如何同步源的新更新内容
    SQL 中 exists 的用法
    OLEDB的Excel的IMEX和HDR是什么意思
  • 原文地址:https://www.cnblogs.com/dr-xsh/p/13211737.html
Copyright © 2011-2022 走看看