Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

thanks for your response. But I still am not able to calculate mu. The issue is that I need to use the sigma_squared ('estimate_data_noise') which

thanks for your response. But I still am not able to calculate "mu." The issue is that I need to use the sigma_squared ('estimate_data_noise') which is defined from a separate function than the function which calculates 'mu'. Any idea how that could work? Thank you! ### YOUR SOLUTION HERE input_x = data[['GrLivArea','YearBuilt']].head(100).values output_y = data['SalePrice'].head(100).values lambda_param = .1 ##calculation for mu def calculate_map_coefficients(input_x, output_y, lambda_param, sigma_squared): xT = np.transpose(input_x) lambda_mul_singma = lambda_param * sigma_squared; fist_inv = np.linalg.inv(lambda_mul_singma + np.matmul(xT, input_x)) mu = np.matmul(np.matmul(fist_inv, xT), output_y) return mu ##calculation for sigma_squared def estimate_data_noise(input_x, output_y, weights): n = len(input_x[:, 0]) d = len(input_x[0, :]) diff = [] for element in range(len(output_y)): print(element) diff.append((output_y[element] - input[element] @ weights) ** 2) return sum(diff) / (n - d)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions