我不断收到此错误
ValueError::形状(2,)和(10,10)不对齐:2(dim 0)!= 10(dim 0)
我尝试将输入转换为矩阵,并在matmul中切换一些值
import numpy as np
import pandas as pd
def ridge_regression_weights(input_x, output_y, lambda_param):
lambda_p_value = lambda_param
X = input_x
X = np.squeeze(np.asarray(X))
y = output_y
y = np.squeeze(np.asarray(y))
trans_x = np.transpose(X)
XTX = np.matmul(trans_x, X)
Left = np.linalg.inv(lambda_p_value + XTX)
Right = np.matmul(output_y, trans_x)
RidgeRegression = np.matmul(Right, Left)
print(RidgeRegression)
应该没有任何错误