更多编程教程请到:菜鸟教程 https://www.piaodoo.com/
友情链接:
高州阳光论坛https://www.hnthzk.com/ 人人影视http://www.sfkyty.com/python使用梯度下降算法实现一个多线性回归,供大家参考,具体内容如下
图示:


import pandas as pd
import matplotlib.pylab as plt
import numpy as np
# Read data from csv
pga = pd.read_csv("D:\python3\data\Test.csv")
# Normalize the data 归一化值 (x - mean) / (std)
pga.AT = (pga.AT - pga.AT.mean()) / pga.AT.std()
pga.V = (pga.V - pga.V.mean()) / pga.V.std()
pga.AP = (pga.AP - pga.AP.mean()) / pga.AP.std()
pga.RH = (pga.RH - pga.RH.mean()) / pga.RH.std()
pga.PE = (pga.PE - pga.PE.mean()) / pga.PE.std()
def cost(theta0, theta1, theta2, theta3, theta4, x1, x2, x3, x4, y):
Initialize cost
J = 0
The number of observations
m = len(x1)

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



