GradientDescentExample icon indicating copy to clipboard operation
GradientDescentExample copied to clipboard

Error

Open ghost opened this issue 5 years ago • 4 comments

Hello,

I am trying to run this python code but I am receiving an error in the following line of code

print "Starting gradient descent at b = {0}, m = {1}, error = {2}".format(initial_b, initial_m, compute_error_for_line_given_points(initial_b, initial_m, points))

ghost avatar Aug 24 '20 17:08 ghost

Hi @Mayssa-1195, what version of Python are you using? What is the error?

mattnedrich avatar Aug 30 '20 16:08 mattnedrich

I am using Python version 3.8.3. This is the error:

File "gradient_descent_example.py", line 39 print "Starting gradient descent at b = {0}, m = {1}, error = {2}".format(initial_b, initial_m, compute_error_for_line_given_points(initial_b, initial_m, points)) ^ SyntaxError: invalid syntax

ghost avatar Aug 30 '20 16:08 ghost

Some of the code doesn't work in Python 3. If you change the print statements to function calls, like

print("Starting gradient descent at b = {0}, m = {1}, error = {2}".format(initial_b, initial_m, compute_error_for_line_given_points(initial_b, initial_m, points)))

That may be enough to get things working.

mattnedrich avatar Aug 30 '20 16:08 mattnedrich

@mattnedrich Okay Thank you ! I will try it

ghost avatar Aug 30 '20 16:08 ghost