psf/black code formatting (#1277)

This commit is contained in:
William Zhang
2019-10-05 01:14:13 -04:00
committed by Christian Clauss
parent 07f04a2e55
commit 9eac17a408
291 changed files with 6014 additions and 4571 deletions

View File

@ -16,21 +16,22 @@ def collect_dataset():
The dataset contains ADR vs Rating of a Player
:return : dataset obtained from the link, as matrix
"""
response = requests.get('https://raw.githubusercontent.com/yashLadha/' +
'The_Math_of_Intelligence/master/Week1/ADRvs' +
'Rating.csv')
response = requests.get(
"https://raw.githubusercontent.com/yashLadha/"
+ "The_Math_of_Intelligence/master/Week1/ADRvs"
+ "Rating.csv"
)
lines = response.text.splitlines()
data = []
for item in lines:
item = item.split(',')
item = item.split(",")
data.append(item)
data.pop(0) # This is for removing the labels from the list
dataset = np.matrix(data)
return dataset
def run_steep_gradient_descent(data_x, data_y,
len_data, alpha, theta):
def run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta):
""" Run steep gradient descent and updates the Feature vector accordingly_
:param data_x : contains the dataset
:param data_y : contains the output associated with each data-entry
@ -79,10 +80,9 @@ def run_linear_regression(data_x, data_y):
theta = np.zeros((1, no_features))
for i in range(0, iterations):
theta = run_steep_gradient_descent(data_x, data_y,
len_data, alpha, theta)
theta = run_steep_gradient_descent(data_x, data_y, len_data, alpha, theta)
error = sum_of_square_error(data_x, data_y, len_data, theta)
print('At Iteration %d - Error is %.5f ' % (i + 1, error))
print("At Iteration %d - Error is %.5f " % (i + 1, error))
return theta
@ -97,10 +97,10 @@ def main():
theta = run_linear_regression(data_x, data_y)
len_result = theta.shape[1]
print('Resultant Feature vector : ')
print("Resultant Feature vector : ")
for i in range(0, len_result):
print('%.5f' % (theta[0, i]))
print("%.5f" % (theta[0, i]))
if __name__ == '__main__':
if __name__ == "__main__":
main()