Gradient Descent Calculation

Start Timer

0:00:00

Upvote
2
Downvote
Save question
Mark as completed
View comments (5)

You are given a list of [x,y] coordinates in a matrix called X.

Write a function using gradient descent to return a tuple describing the line of best fit for the given coordinates. The first number in the tuple should be the line’s slope. The second number in the tuple should be its y-intercept.

You may not import any libraries.

Example:

Input:

coordinates = [(0, 1), (1, 3), (2, 2), (3, 4), (4, 6), (5, 5), (6, 7), (7, 9), (8, 8), (9, 10), (10, 12), (11, 11), (12, 13), (13, 15), (14, 14), (15, 16), (16, 18), (17, 17), (18, 19)]

Output:

(1, 1) 
.
.
.
.
.


Comments

Loading comments