import numpy as np
def linear_regression_gradient_descent(X, y, alpha, iterations):
# 补全代码
m, n = X.shape
theta = np.zeros((n,1)) # 包括截距项 theta_0
for _ in range(iterations):
predictions = X.dot(theta)
errors = predictions - y
gradient = X.T.dot(errors) / m
theta -= alpha * gradient
return np.round(theta.flatten(), 4)
# 主程序
if __name__ == "__main__":
# 输入矩阵和向量
matrix_inputx = input()
array_y = input()
alpha = input()
iterations = input()
# 处理输入
import ast
matrix = np.array(ast.literal_eval(matrix_inputx))
y = np.array(ast.literal_eval(array_y)).reshape(-1,1)
alpha = float(alpha)
iterations = int(iterations)
# 调用函数计算逆矩阵
output = linear_regression_gradient_descent(matrix,y,alpha,iterations)
# 输出结果
print(output)