Refactor sum_of_square_error function in linear_regression.py

This commit is contained in:
Julien RICHARD 2024-10-01 14:55:03 +02:00
parent a09a72816e
commit a33e39ae2c
No known key found for this signature in database

View File

@ -67,13 +67,6 @@ def sum_of_square_error(data_x, data_y, len_data, theta):
:param len_data : len of the dataset :param len_data : len of the dataset
:param theta : contains the feature vector :param theta : contains the feature vector
:return : sum of square error computed from given feature's :return : sum of square error computed from given feature's
>>> data_x = np.array([[1, 2], [1, 3], [1, 4]])
>>> data_y = np.array([[2], [2], [2]])
>>> theta = np.array([[0.0, 0.0]])
>>> len_data = len(data_x)
>>> sum_of_square_error(data_x, data_y, len_data, theta).round(2)
2.0
""" """
prod = np.dot(theta, data_x.transpose()) prod = np.dot(theta, data_x.transpose())
prod -= data_y.transpose() prod -= data_y.transpose()