#theta = theta - alpha*(theta*X-Y)*X theta = 1.0 #(alpha 阿尔法) alpha = 0.1 #100次遍历 for i in range(100): #sum/3.0表示求加权平均值 theta = theta + np.sum(alpha*(Y-dot(X,theta))*X)/3.0 print(theta)
3.打印结果:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
接下来这段原码是实现100,从100递减执行
j = 79 for i in range(79): the_date = datetime.date.today() yesterday = the_date - datetime.timedelta(days=j) currentDate = yesterday start_date = currentDate end_date = currentDate yesterday = start_date - datetime.timedelta(days=1) # 当前时间戳-日志查询结束时间 startTimeStamp = int(time.mktime(time.strptime(str(start_date), "%Y-%m-%d"))) endTimeStamp = startTimeStamp + 86399 print("数据开始时间:", start_date) print("数据结束时间:", end_date) print("开始时间戳:", startTimeStamp) print("结束时间戳:", endTimeStamp) print("昨日日期:", yesterday) j -= 1 print("jjjjjjjjjjjj:", j) print() print() print()
原文参考:https://www.cnblogs.com/guanguan-com/archive/2004/01/13/13698758.html